Security: Hook writes to predictable path without symlink protection (possible file clobber)#70
Merged
JuliusBrussee merged 2 commits intoJuliusBrussee:mainfrom Apr 15, 2026
Conversation
The SessionStart hook writes to `~/.claude/.caveman-active` using `fs.writeFileSync` on a predictable path. If that path is replaced with a symlink, Node will follow it and overwrite the symlink target. A local attacker (or another process running as the same user) could abuse this to modify unintended files writable by the user. Affected files: caveman-activate.js, caveman-mode-tracker.js Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
The SessionStart hook writes to `~/.claude/.caveman-active` using `fs.writeFileSync` on a predictable path. If that path is replaced with a symlink, Node will follow it and overwrite the symlink target. A local attacker (or another process running as the same user) could abuse this to modify unintended files writable by the user. Affected files: caveman-activate.js, caveman-mode-tracker.js Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
10 tasks
JuliusBrussee
added a commit
that referenced
this pull request
Apr 15, 2026
…ession Writes were hardened via safeWriteFlag (PRs #70/#71) but readers still trusted whatever the flag contained. A local attacker with write access to ~/.claude/ could symlink the flag at a secret file and have the per-turn reinforcement inject its bytes into model context, or the statuslines echo ANSI escapes to the terminal on every keystroke. - caveman-config.js: new readFlag() — lstat symlink refuse, 64-byte cap, O_NOFOLLOW, VALID_MODES whitelist. Returns null on any anomaly. - caveman-mode-tracker.js: per-turn reinforcement routes through readFlag() instead of fs.readFileSync. - caveman-statusline.sh / .ps1: symlink + size refuse, strip to [a-z0-9-], whitelist-validate before rendering. - compress.py (3 synced copies): is_sensitive_path() denylist refuses .env*, .netrc, keys/certs, ~/.ssh|.aws|.gnupg|.kube|.docker, and any basename containing secret/credential/password/apikey/token/privatekey (separator-insensitive). Fails loudly before read — no silent exfil of credentials to the Anthropic API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Problem
The SessionStart hook writes to
~/.claude/.caveman-activeusingfs.writeFileSyncon a predictable path. If that path is replaced with a symlink, Node will follow it and overwrite the symlink target. A local attacker (or another process running as the same user) could abuse this to modify unintended files writable by the user.Severity:
mediumFile:
hooks/caveman-activate.jsSolution
Before writing, use
lstatSyncto reject symlinks, open files with flags that avoid following links where possible, and enforce restrictive permissions (e.g., create with mode0o600). Consider writing to a temporary file and atomic-renaming after validation.Changes
hooks/caveman-activate.js(modified)hooks/caveman-mode-tracker.js(modified)Testing