Conversation
…the read grant find's global options (-L/-H/-P, -D, -O, and the BSD -E/-X/-d/-s/-x) precede the starting points, but _stage_targets treated every leading dash token as the start of find's predicates and returned no read targets. With none, the session grant's root check in permissions.py passed vacuously: 'find -L /etc -name shadow' and 'find -H ~/.ssh -type f' auto-ran under 'read-only command (session grant)' while the unprefixed forms correctly asked for approval. That is exactly the escape OPE-130 was created to close. Parse find's global options ahead of the path list (-D consumes its debugopts value; -f names the starting point itself), then collect starting points until the first predicate. The unprefixed behavior is unchanged. Tests: read_targets now names the starting point for prefixed forms; the session grant asks for the out-of-root prefixed reads and still auto-runs them inside the root.
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.
Problem
The read-only session grant vets what a command may do, then holds the files it reads to the session's granted roots (OPE-130). For
find,_stage_targetstreated every token starting with-as the start of find's predicates andbreaked out of the path scan:But find's global options (
-L,-H,-P,-D,-O, and the BSD-E/-X/-d/-s/-x) also start with-and precede the starting points. With one,read_targets()returned[], so the root check atpermissions.py:463-465passed vacuously and the command auto-ran underread-only command (session grant):That is exactly the escape OPE-130 was created to close: a grant the user reads as "stop asking about my project files" also covered
~/.aws/credentialsand~/.ssh/id_rsa— and the self-protection floor guards those against modification, not reads.Fix
Parse find's global options ahead of the path list in a dedicated
_find_targets():-H/-L/-Pand the BSD-E/-X/-d/-s/-xtake no value-Dconsumes its debugopts value-Ocarries its level attached (-O3)-fnames the starting point itself (BSD).(inside every session root)Tests
tests/test_readonly_scoping.py:read_targetsnames the starting point for every global-option spelling, and still returns nothing when no path is givenfind -L /etc,find -H ~/.ssh,find -P ~/.aws,find -D search ~/.aws,find -O3 /etc) while still auto-running the in-root forms (find -L . -name '*.py',find -D search src)Full backend suite: 2649 passed, 14 skipped; the only failures are the two pre-existing
test_tool_result_cap.pymacOS marker-path failures also present on cleanmain.