FORGEJO_ACCESS_TOKEN unnecessarily exported to all subprocess environments via set -a #4
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#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Problem
audit.shusesset -abefore sourcing.env, which automatically exports every variable — includingFORGEJO_ACCESS_TOKEN— to the environment of all child processes spawned during the script's lifetime. This includesgit,python3,awk,grep,sed,wc, and any other utilities called throughout the script, most of which have no need for the token.Location
audit.sh, line 55 (set -a) and line 57 (set +a), combined with all subsequent child process invocations (e.g.,git -C "$repo" fetch,python3 -u -c ...,awk, etc.)Risk
On Linux, a process's environment is visible via
/proc/<pid>/environto any process running as the same user. Sensitive variables exported to short-lived subprocesses increase the window and surface area during which the token could be read by a co-resident process. Additionally, if any child process ever forks into an attacker-controlled context (e.g., a malicious git hook in an audited repository), the token is immediately available in that context's environment.Suggested fix direction
Use
set +aimmediately after sourcing.env(already done), then explicitly passFORGEJO_ACCESS_TOKENonly to theclaudeinvocation that requires it, usingenv FORGEJO_ACCESS_TOKEN="$FORGEJO_ACCESS_TOKEN" claude ...rather than relying on the inherited environment. Alternatively, unset the token after theclaudecall completes.Severity
minor
Found by
Automated audit by Claude Code