-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(tasks): per-actor sandbox GitHub identity on multiplayer transitions #71941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6ddd067
e3de07c
e648d50
c13eb28
f4ac78d
5a21130
3c47784
46c9daa
71ec01e
7ac8834
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/bin/bash | ||
| # gh guard. | ||
| # | ||
| # Installed first on PATH inside the cloud sandbox image as /opt/posthog/bin/gh. | ||
| # The backend delivers the per-actor GitHub token via BASH_ENV, which only | ||
| # non-interactive `bash -c` honors — the agent runs its tool commands in an | ||
| # interactive shell, so `gh` there would otherwise have no token. This shim | ||
| # sources the same credential script the shells do, so `gh` authenticates as the | ||
| # current actor regardless of shell mode, and honors logout (an emptied file | ||
| # exports nothing, leaving gh unauthenticated rather than falling back to a stale | ||
| # token). All arguments pass straight through to the real gh. | ||
|
|
||
| native_gh="" | ||
| for candidate in /usr/bin/gh /usr/local/bin/gh /bin/gh; do | ||
| if [ -x "$candidate" ] && [ "$candidate" != "/opt/posthog/bin/gh" ]; then | ||
| native_gh="$candidate" | ||
| break | ||
| fi | ||
| done | ||
| if [ -z "$native_gh" ]; then | ||
| echo "gh-guard: could not locate the real gh binary" >&2 | ||
| exit 127 | ||
| fi | ||
|
|
||
| # Re-source the backend-managed credentials fresh on every call (the file is | ||
| # rewritten on each refresh / actor transition). The script's sourced branch | ||
| # unsets then re-exports GH_TOKEN/GITHUB_TOKEN from the env file. | ||
| if [ -f /tmp/agentsh-bash-env.sh ]; then | ||
| # shellcheck source=/dev/null | ||
| . /tmp/agentsh-bash-env.sh | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIDo not execute `/tmp/agentsh-bash-env.sh` from the gh shim. Move the minimal credential-file parsing needed by gh into a root-owned, immutable script/image layer, or otherwise have a trusted supervisor pass the current token to gh without sourcing any sandbox-writable script. Ensure a prior actor cannot alter the code that reads a later actor's credential file.Severity: high | Confidence: 91% | React with 👍 if useful or 👎 if not |
||
| fi | ||
|
|
||
| exec "$native_gh" "$@" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime-installed
ghshim sources/tmp/agentsh-bash-env.shbefore it invokesgh. That file is in the shared sandbox filesystem and is writable by the previous Slack actor's agent. An attacker can persist commands in it, then when a more-privileged user sends the next follow-up and their token is written to/tmp/agent-github-env, the shim executes those commands in the privileged command environment. This lets the prior actor use or exfiltrate the new actor's GitHub credential, defeating the per-actor rebind on resumed snapshots.Prompt To Fix With AI
Severity: high | Confidence: 91% | React with 👍 if useful or 👎 if not