fix(agent-setup, github-app-token): guard against inherited GH_CONFIG_DIR outside AGENT_HOME #2
Reference in New Issue
Block a user
Delete Branch "gb_flea/skills:gandalf/gh-config-dir-isolation"
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 a cross-agent token contamination class where an inherited
GH_CONFIG_DIRfrom a prior session or a sibling agent's workspace causedgenerate-token.shto write.gh-tokeninto a foreign agent's workspace directory instead of the correct one.Confirmed live impact: while generating a GitHub App token, a stale inherited
GH_CONFIG_DIRpointed to a different agent's workspace (…/ccfa5281…/.github/), silently writing the token there. PinningGH_CONFIG_DIRto$AGENT_HOMEfixed it. These guards prevent recurrence.Changes
1.
agent-setup/scripts/setup.sh— guard before derivationInsert an early check immediately after the
AGENT_HOMEvalidation, beforeexport GH_CONFIG_DIR=...is set:This ensures a contaminated inherited value is cleared before the script re-derives the correct one.
2.
agent-setup/SKILL.md— fix dotfile source pathChange the
## Usageexample fromsource ~/.envtosource "$AGENT_HOME/.env"— the script writes to$AGENT_HOME/.env, not~/.env;~is not guaranteed to equal$AGENT_HOME.3.
github-app-token/scripts/generate-token.sh— hard guard + pinned auth(a) After resolving
GH_TOKEN_DIR, add adie()guard that refuses to write whenGH_CONFIG_DIRis outsideAGENT_HOME:(b) Pin
GH_CONFIG_DIRon thegh auth logininvocation so it cannot fall back to any inherited config dir:Verification
bash -n agent-setup/scripts/setup.sh✅bash -n github-app-token/scripts/generate-token.sh✅export GH_CONFIG_DIR=/tmp/someone-elses/.github AGENT_HOME=/tmp/mesetup.sh— warns and overrides ✅generate-token.shvalidation block —die()s with "Refusing to write token to a foreign workspace" ✅GH_CONFIG_DIRunset and a validAGENT_HOME, behaviour is unchanged ✅Related
No secrets in this PR.
Co-Authored-By: Paperclip noreply@paperclip.ing
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.