Repository navigation
fix(security): enforce read + shell guards on @-inline and custom-command expansion - #379
Merged
Merged
Conversation
…mand expansion _expand_at_refs and custom _read_ref bypassed _check_read_path, inlining ~/.ssh, ~/.gnupg and history.db into the prompt. Route both through _check_read_path (resolve-first, symlink-safe). custom _run_shell bypassed _check_shell, letting !`rm -rf /` / !`curl ..|sh` in templates execute with no approval. Check first, fail closed. Add parity tests: sensitive @-refs blocked, symlinks blocked, benign inlines still work, destructive custom shell refused without execution.
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.
Closes audit findings #1 + #2.
_expand_at_refs (agent.py) and _read_ref (custom_commands.py) used plain Path.read_text with no sensitive-path check, so @~/.ssh/id_rsa and history.db inlined straight into the prompt while read_file refused them. Both now route through _check_read_path (resolve-first, symlink-safe).
_run_shell (custom_commands.py) ran sh -c with no destructive-command check, so !
rm -rf // !curl ..|shin a template executed pre-prompt. Now checks _check_shell first, fail-closed.Tests: 7 new parity tests in tests/test_security.py (sensitive @-refs blocked, symlinks blocked, benign still inlines, destructive custom shell refused without execution).
Gates: 162 passed (security+custom_commands+trust+custom_command_shell), ruff + format clean, mypy clean on touched files.