Skip to content

feat(policy): classify the streaming SFTP verbs before the tools land - #212

Merged
tufantunc merged 1 commit into
mainfrom
feat/sftp-tools-b2b
Sep 10, 2026
Merged

feat(policy): classify the streaming SFTP verbs before the tools land#212
tufantunc merged 1 commit into
mainfrom
feat/sftp-tools-b2b

Conversation

@tufantunc

Copy link
Copy Markdown
Owner

The authorization half of the streaming file tools, split out so the class decision is reviewable on its own rather than arriving inside 1700 lines of tool code. Nothing emits these verbs yet.

What the classifier does today, measured

verb class today
sftp:upload destructive (has a floor)
sftp:download safe
sftp:upload-file safe
sftp:download-file safe
sftp:list safe

safe is inside the stock operator binding. So without a floor, wiring the tools would hand a role that was never granted a disk-writing tool exactly that — sftp:download-file writes into the operator's transfer root, sftp:upload-file writes on the remote host.

Both now carry a destructive floor.

sftp:list keeps safe, and I was wrong about it

I had planned a read-only floor for it. That was wrong twice:

  1. SYNTHETIC_CLASSES is applied as a floorCLASS_RANK[floor] > CLASS_RANK[highest.class] — so read-only (rank 0) against a safe (rank 1) baseline can never fire. It would have been dead code.
  2. The effect it was reaching for — letting a viewer list a remote directory — is a lowering, and this file already refuses exactly that for sftp:download and session:close, on the grounds that lowering a class is a widening and a security release is the wrong place for one.

Whether a viewer should be able to list a directory is a role-binding question. It does not belong in the same change as a new tool surface. The comment and the keeps the class it has today table now record this so the next reader does not re-derive it.

Tests

  • both new verbs pinned at destructive
  • sftp:list pinned at safe, alongside sftp:download and session:close
  • the verbs matched against the strings the tools will emit
  • a floor still cannot lower what the arguments raisesftp:upload-file $(sudo id) stays privileged, so the new verbs do not become a way to launder a command

test:unit 893 passing.

Remaining in this piece

The tool half: sanitizeRemotePath (which does not exist in the repo yet), the transferRoot / transferMaxBytes / transferTimeoutMs config plumbing, the three tool handlers, and #207's ordering — resolve read-only, then policy, then stage only after approval.

The authorization half of the streaming file tools, separated so the class
decision is reviewable on its own rather than arriving inside 1700 lines of
tool code.

`sftp:upload-file` and `sftp:download-file` get a `destructive` floor. Each
writes a file — the first on the remote host, the second inside the
operator's transfer root — and measured against the classifier today, both
come out `safe` from the verb alone. `safe` is inside the stock `operator`
binding, so without this a role that was never granted a disk-writing tool
would have got one the moment the tools were wired.

`sftp:list` keeps `safe`. I had planned a `read-only` floor for it and that
was wrong twice over. SYNTHETIC_CLASSES is applied as a floor and can only
raise, so `read-only` against a `safe` baseline is inert. And the effect it
was reaching for — letting a `viewer` list a remote directory — is a
lowering, which this file already refuses for `sftp:download` and
`session:close` on the grounds that lowering a class is a widening. Whether
a viewer should list a directory is a role-binding question, and it does not
belong in the same change as a new tool surface. The comment and the
`keeps the class it has today` table now say so, so the next reader does not
re-derive it.

Tests: both new verbs pinned at `destructive`, `sftp:list` pinned at `safe`
alongside its two neighbours, the verbs matched against the strings the
tools will emit, and — the one that matters — a floor still cannot lower
what the arguments raise, so `sftp:upload-file $(sudo id)` stays
`privileged` rather than the new verbs becoming a way to launder a command.

Nothing emits these verbs yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tufantunc
tufantunc merged commit f14ec6e into main Sep 10, 2026
10 checks passed
@tufantunc
tufantunc deleted the feat/sftp-tools-b2b branch September 10, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant