feat(policy): classify the streaming SFTP verbs before the tools land - #212
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
sftp:uploaddestructive(has a floor)sftp:downloadsafesftp:upload-filesafesftp:download-filesafesftp:listsafesafeis inside the stockoperatorbinding. So without a floor, wiring the tools would hand a role that was never granted a disk-writing tool exactly that —sftp:download-filewrites into the operator's transfer root,sftp:upload-filewrites on the remote host.Both now carry a
destructivefloor.sftp:listkeepssafe, and I was wrong about itI had planned a
read-onlyfloor for it. That was wrong twice:SYNTHETIC_CLASSESis applied as a floor —CLASS_RANK[floor] > CLASS_RANK[highest.class]— soread-only(rank 0) against asafe(rank 1) baseline can never fire. It would have been dead code.viewerlist a remote directory — is a lowering, and this file already refuses exactly that forsftp:downloadandsession: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 todaytable now record this so the next reader does not re-derive it.Tests
destructivesftp:listpinned atsafe, alongsidesftp:downloadandsession:closesftp:upload-file $(sudo id)staysprivileged, so the new verbs do not become a way to launder a commandtest:unit893 passing.Remaining in this piece
The tool half:
sanitizeRemotePath(which does not exist in the repo yet), thetransferRoot/transferMaxBytes/transferTimeoutMsconfig plumbing, the three tool handlers, and #207's ordering — resolve read-only, then policy, then stage only after approval.