fix(file-tools): ensure OS-agnostic sensitive path protection - #10682
Open
Junass1 wants to merge 1 commit into
Open
fix(file-tools): ensure OS-agnostic sensitive path protection#10682Junass1 wants to merge 1 commit into
Junass1 wants to merge 1 commit into
Conversation
Collaborator
|
Related to #4993 — both address cross-platform path guard bypass where backslash-normalized paths on Windows skip POSIX-sensitive path checks in |
Contributor
|
Thanks for identifying the Windows-sensitive-path gap. The premise still holds on current main: Problems
Suggested changes
This is an automated hermes-sweeper review. |
14 tasks
7 tasks
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
Normalize
_check_sensitive_path()comparisons so sensitive POSIX targets stay blocked even when Hermes is running on a Windows host.Problem
_check_sensitive_path()comparedrealpath()/normpath()output directly against POSIX-sensitive prefixes and exact paths such as:/private/etc//private/var//var/run/docker.sockOn Windows hosts, those path helpers can produce backslash-normalized paths, which makes direct string comparisons host-OS dependent and risks missing sensitive POSIX targets.
Fix
~resolvedand literal-path comparisons in_check_sensitive_path()Tests
Added regression coverage for Windows-host semantics by monkeypatching
realpath()/normpath()to return backslash-normalized paths and verifying that:/var/run/docker.sockis still blocked/private/etc/hostsis still blocked/tmp/safe_file.txtis still allowedVerification
Passed locally via:
uv run pytest tests/tools/test_file_write_safety.py -quv run pytest tests/tools/test_write_deny.py -q