fix(permissions): stop decoy raw keys from shadowing real tool paths - #351
Open
Mr-Neutr0n wants to merge 1 commit into
Open
fix(permissions): stop decoy raw keys from shadowing real tool paths#351Mr-Neutr0n wants to merge 1 commit into
Mr-Neutr0n wants to merge 1 commit into
Conversation
The permission checker resolved file paths (and commands) from raw tool_input before the validated model, while execution runs on parsed_input only. A model-supplied file_path key that Pydantic drops (read_file/write_file/edit all use path) therefore shadowed the real path during evaluation, letting deny-ruled paths slip through in full_auto mode via prompt injection (issue HKUDS#348). Parsed fields are now authoritative; raw keys remain a fallback for dynamic-schema tools such as MCP proxies whose models expose no path attributes. Adds engine-level regressions reproducing the PoC pair for read_file and write_file; both fail on vulnerable code. Signed-off-by: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.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.
Fixes #348
Root cause
_resolve_permission_file_pathinsrc/openharness/engine/query.pychecked rawtool_inputkeys (file_pathfirst) before the validated model, but execution runs onparsed_inputonly —tool.execute(parsed_input, ...). Since every built-in file tool's schema field ispath(read_file, write_file, edit), a model-suppliedfile_pathkey is dropped by Pydantic as an unknown field while still winning the permission check. Deny rules evaluated the decoy; execution touched the real path.The same raw-first pattern existed in
_extract_permission_command.Change
Both resolvers now treat validated model fields as authoritative and fall back to raw keys only for dynamic-schema tools (MCP proxies) whose parsed models expose no path/command attributes:
Verification
Engine-level regressions reproduce the issue PoC without any live model endpoint:
{"file_path": "README.md", "path": "work/blocked/secret.txt"}under a deny rule → blocked (was: returned file contents)This change was prepared with AI assistance under human direction and review.