Scope FORGEJO_ACCESS_TOKEN to the claude invocation only #12
No reviewers
Labels
No labels
shellcheck
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
bc1bb/claude-code-audit!12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/token-env-leak-v2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #4 —
FORGEJO_ACCESS_TOKENwas being exported to every child process spawned by the script (git,python3,timeout,awk, etc.) due toset -aduring.envsourcing.Two-line fix:
export -n FORGEJO_ACCESS_TOKENimmediately afterset +arevokes the export flag. The variable stays accessible within the shell but is no longer inherited by subprocesses.FORGEJO_ACCESS_TOKEN="$FORGEJO_ACCESS_TOKEN" timeout ...in the Forgejo invocation passes the token as an inline env var scoped to that process tree only (timeoutinherits it and passes it down toclaude).The non-Forgejo path receives no token at all.
Note on the updated pipeline shape
Since the previous attempt (PR #11), master gained a
timeoutwrapper aroundclaude. The inline assignment is placed beforetimeoutrather thanclaudedirectly, sincetimeoutis what actually spawnsclaude— the env var propagates correctly through that chain.Test plan
FORGEJO_ACCESS_TOKENabsent fromgit fetchenvironment (verifiable withGIT_TRACE=1or a debug hook in an audited repo)Found by
Automated audit by Claude Code (issue #4)