Repository navigation
fix(harness): strip file:// scheme before sensitive-path probing - #292
Open
raymondginger2018-sudo wants to merge 1 commit into
Open
raymondginger2018-sudo wants to merge 1 commit into
raymondginger2018-sudo wants to merge 1 commit into
Conversation
file: URLs passed as tool path/argument values missed the denylist suffix probe: the raw string "file:///home/u/.ssh/id_rsa" never suffix-matches "/home/u/.ssh/id_rsa", so is_sensitive_path returned False and _extract_file_targets still extracted the value as a filesystem path -> denylist bypass under FULL_AUTO. Normalize the boundary value once (_strip_file_scheme): case-insensitive file: scheme strip (plain, //host/share UNC and //localhost forms) plus percent-decoding, before the existing suffix probe. Scope stays minimal: only the file: form is rewritten; http(s)/ws(s) and other URL schemes, plain filesystem paths and relative names keep byte-identical behavior. Tests: 7 new cases (non-path keys, percent-encoding, localhost/UNC, Windows drive form, nested arguments) plus two negative controls (remote URLs and prose mentioning file: are not paths).
Contributor
Author
|
@Zongwei9888 Hi! This PR fixes a denylist bypass in the sensitive-path probe ( |
This branch has not been deployed
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
is_sensitive_path()probes candidate paths by suffix matching after_normalize_path(). Afile://URL — e.g.file:///home/u/.ssh/id_rsa— never suffix-matches the denylist entry/home/u/.ssh/id_rsa, sois_sensitive_path()returnsFalseand a protected-path denylist entry can be bypassed under permissive permission modes (FULL_AUTO/AUTOPILOT) by simply wrapping the path in afile:scheme. The same bypass works for percent-encoded (file:///home/u/.ssh/%69d_rsa), UNC (file://host/share/...),localhost, and Windows drive (file:///C:/Users/...) forms, and for nested tool-callargumentsunder non-path keys.Fix
_normalize_path()now strips a leadingfile:scheme (case-insensitive, including//host/shareUNC and//localhostforms) and percent-decodes the result before the denylist suffix probe (new helper_strip_file_scheme,urllib.parse.urlparse+unquote)._path_values()additionally yields string values that start withfile:even when the key does not match_PATH_KEY, closing nested-argument bypasses.No allowlist semantics, no other scheme handling, and no probe ordering is changed.
Tests
7 new module-level tests in
tests/test_harness_permissions.py:file://URL under a non-path key is deniedlocalhostand UNC forms are deniedfile://in nestedargumentsis deniedhttp(s)://URLs are not treated as paths (no false positives)file://URL is not treated as a pathRED/GREEN paired verification on this branch (Python 3.12–3.14): pre-fix 5 failed / 2 passed (RED) → post-fix 7/7 passed (GREEN). The two false-positive guards were already passing and stay passing.
Security Considerations
~/.ssh/id_rsacan be read/written by a craftedfile://argument.file:scheme is stripped;http(s)://URLs and prose mentions are regression-tested to remain non-paths...traversal, symlink escapes (covered by separate tests, incl.test_denylist_follows_symlinks), and Windows 8.3 short-name / NTFS stream aliasing.Local CI preflight on this revision: all legs green except pre-existing Windows-environmental reds (xdist worker collapse on py3.12; pre-existing platform red family on py3.13/3.14 — proven identical on pristine base
4ff321ecvia failed-set differential, net new reds attributable to this diff = 0).@Zongwei9888 requesting a security review — this touches the sensitive-path denylist boundary.