fix: harden path sandboxing with symlink protection, safe defaults, and sensitive file guards#204
Closed
anandgupta42 wants to merge 10000 commits intomainfrom
Closed
fix: harden path sandboxing with symlink protection, safe defaults, and sensitive file guards#204anandgupta42 wants to merge 10000 commits intomainfrom
anandgupta42 wants to merge 10000 commits intomainfrom
Conversation
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.
What does this PR do?
Hardens the security posture of Altimate Code's path sandboxing and permission system, addressing the same class of vulnerabilities that led to CVEs in Codex (GHSA-w5fx-fh39-j5rw, CVSS 8.6) and Claude Code (CVE-2025-54794, CVSS 7.7). Reviewed by 6 AI models (Claude, GPT 5.2 Codex, Gemini 3.1 Pro, Kimi K2.5, MiniMax M2.5, GLM-5).
Five areas of improvement:
Symlink escape protection —
Filesystem.containsReal()resolves symlinks viarealpathSyncbefore checking containment. Rejects paths with unresolved..segments to prevent divergence betweenrealpathSync(lexical..normalization) and kernel behavior (follows symlink then applies..). Also addsisAbsolute(rel)check for Windows cross-drive bypass.Safe permission defaults — Destructive shell/git commands (
rm -rf,git push --force,git reset --hard) now prompt before execution instead of running silently. Database DDL (DROP DATABASE,DROP SCHEMA,TRUNCATE) is blocked entirely. Users can override in config.Sensitive file guards — New
assertSensitiveWrite()check on write, edit, apply_patch, and move operations that prompts before modifying.env*,.ssh/,.aws/,.git/, credential files, and private keys (.pem,.key) — even inside the project boundary. Case-insensitive on macOS/Windows.Critical fix:
realpathSyncvs kernel divergence — Gemini 3.1 Pro discovered thatrealpathSync("project/symlink/..")returnsproject/(lexical) while the kernel writes to the parent of the symlink target (outside project). Fixed by rejecting any unresolved path containing..segments.Documentation — Updated SECURITY.md, permissions docs with 3 recommended configs and rule ordering guidance, and security FAQ with new sections on sensitive file prompts, default command protections, and best practices.
UX Impact
..segment rejection..— only catches crafted pathsaskrm -rf,git push --force, etc. now prompt instead of running silently. "Allow always" available.denyDROP DATABASE,TRUNCATEblocked entirely. Override in config if needed..env,.ssh/,.aws/, credential files prompts. "Allow always" per-file for the session.Key UX decisions:
askinstead ofdenyfor shell/git commands — Blockingrm -rf ./buildorgit push --forceafter rebase would break common workflows. Prompting lets users approve safely..envfile per session, not on every edit..githubNOT in sensitive dirs — CI/CD workflow editing is a core use case; prompting every time would cause approval fatigue.DROP DATABASE,DROP SCHEMA,TRUNCATEare almost never intentional in agent context.Type of change
Issue for this PR
Closes #202
How did you verify your code works?
symlink/../kernel divergence attackFile.read/File.list.git,.ssh,.aws,.env*, credentials, private keys.pem,.key,.p12,.pfx)assertSensitiveWriteprompting for sensitive files, no-op for normal filesChecklist
🤖 Generated with Claude Code