[security]fix path rule enforcement for file tools#32
Merged
Conversation
arik08
pushed a commit
to arik08/MyHarness
that referenced
this pull request
Apr 26, 2026
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.
Summary
This PR fixes a security-sensitive permission enforcement gap in built-in file tools. The query runner only forwarded
file_pathinto the permission layer, while several core file tools usepath, which meant configuredpermission.path_rulescould be bypassed for those calls. In practice, that allowed blocked reads in default mode and blocked writes infull_auto; this patch normalizes the effective target path before evaluation and adds regression coverage for both cases.Related Issue
No linked public issue. This PR addresses a local file-access boundary failure in the documented
permission.path_rulescontrol.Changes
src/openharness/engine/query.pyso built-in tools using eitherfile_pathorpathare evaluated consistently.cwdbefore applying deny rules, so permission decisions are made against the real absolute target path.read_filecall in default modewrite_filecall infull_autoREADME.mdby making implementation and security expectations match again.Security Context
The root cause was an argument-name mismatch in the permission boundary.
PermissionCheckersupports path-level rules, but the query runner only passedfile_pathinto that layer. Several core file tools instead usepath, so the real filesystem target never reached permission evaluation.That mismatch had direct security impact:
read_fileis treated as read-only, so the bypass allowed reads from denied paths in default modewrite_fileand similar mutating tools could reach denied paths once the session was infull_autoSteps to Reproduce
7f7081b8a5f8bcd9dde26094aa470f20bd02098c.PYTHONPATH=src uv run python.PermissionChecker(mode=PermissionMode.DEFAULT, path_rules=[{"pattern": "/etc/*", "allow": False}])._execute_tool_call(..., "read_file", {"path": "/etc/hosts", "offset": 0, "limit": 1})./etc/hosts.PermissionChecker(mode=PermissionMode.FULL_AUTO, path_rules=[{"pattern": "/tmp/*", "allow": False}])._execute_tool_call(..., "write_file", {"path": "/tmp/openharness-path-rule-bypass.txt", "content": "poc"})./tmp/.Security Impact
full_auto, allowing tampering with local project state or other writable host files outside the intended repository scope.CVSS / CWE
High7.8CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:LCWE-284: Improper Access ControlTesting
uv run --extra dev ruff check src/openharness/engine/query.py tests/test_engine/test_query_engine.pyPYTHONPATH=src uv run --extra dev pytest tests/test_engine/test_query_engine.py tests/test_permissions/test_checker.pyType of Change
Checklist
General
Code Changes
permission.path_rulesbehavior now matches the implementation for these built-in file-tool inputs.Doc Changes
SECURITY.mdis still missing and should be added in a follow-up by maintainers.Maintainer Note
The repository does not appear to publish a
SECURITY.mdfile or another documented private disclosure path today. AddingSECURITY.mdwith a reporting contact or policy would make future security reports easier to handle privately.Signed-off-by: 13ernkastel LennonCMJ@live.com