fix: resolve symlink bypass in write deny list on macOS#61
Merged
teknium1 merged 1 commit intoNousResearch:mainfrom Feb 27, 2026
Merged
fix: resolve symlink bypass in write deny list on macOS#61teknium1 merged 1 commit intoNousResearch:mainfrom
teknium1 merged 1 commit intoNousResearch:mainfrom
Conversation
On macOS, /etc is a symlink to /private/etc. The _is_write_denied()
function resolves the input path with os.path.realpath() but the deny
list entries were stored as literal strings ("/etc/shadow"). This meant
the resolved path "/private/etc/shadow" never matched, allowing writes
to sensitive system files on macOS.
Fix: Apply os.path.realpath() to deny list entries at module load time
so both sides of the comparison use resolved paths.
Adds 19 regression tests in tests/tools/test_write_deny.py.
0xbyt4
added a commit
to 0xbyt4/hermes-agent
that referenced
this pull request
Feb 26, 2026
These tests documented the macOS symlink bypass bug with platform-conditional assertions. The fix and proper regression tests are in PR NousResearch#61 (tests/tools/test_write_deny.py), so remove them here to avoid ordering conflicts between the two PRs.
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
_is_write_denied()was bypassed on macOS for all/etc/*paths/etcis a symlink to/private/etc. The function resolved the input path withos.path.realpath()but deny list entries were stored as literal strings (/etc/shadow), so the resolved path/private/etc/shadownever matched.os.path.realpath()to deny list entries at module load time so both sides use resolved pathsAffected paths (were unprotected on macOS)
/etc/shadow,/etc/passwd,/etc/sudoers/etc/sudoers.d/*,/etc/systemd/*Test plan
tests/tools/test_write_deny.py— all passing on macOS