Repository navigation
interactive: pass GitHub Actions context env vars to sandbox - #664
Conversation
The `sudo -u "$SANDBOX" env VAR=...` launch in interactive/action.yaml replaces the environment with only what's listed. Standard GHA context vars (GITHUB_RUN_ID, GITHUB_REPOSITORY, GITHUB_WORKFLOW, …) were not on the list, so they reached the agent's bash as empty strings. Skills depend on them for branch names, self-check-run dedup, gist audit-trail headings, and owner-correct URL construction. Without them, the `grep -qF "$GITHUB_RUN_ID"` defense-in-depth guard becomes `grep -qF ""` which matches anything and silently passes, letting a hallucinated run ID survive into the evidence gist (observed: a fabricated `## Run 27075391434` heading whose Workflow link 404s). These vars are public, not secrets.
tend-agent
left a comment
There was a problem hiding this comment.
One coverage gap: GITHUB_EVENT_PATH isn't in the new allowlist, but plugins/tend-ci-runner/skills/review/SKILL.md:33 reads it to compute EVENT_ACTION (used to bypass the same-SHA exit when a PR transitions out of draft via ready_for_review). With it empty under interactive, that detection silently falls back to /dev/null and a draft-to-ready transition won't trigger the intended full review. The file lives under RUNNER_TEMP (runner-owned but readable to the sandbox user — same as the rest of _temp), so passing the path through should work.
Reviewer flagged that `review/SKILL.md` reads `$GITHUB_EVENT_PATH` to detect
`ready_for_review` transitions (`EVENT_ACTION=$(jq -r '.action // ""' <
"${GITHUB_EVENT_PATH:-/dev/null}")`). Without it in the sudo env allowlist,
the fallback to `/dev/null` silently swallows the bypass and draft-to-ready
transitions never trigger a full review.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
should we add everything |
|
Mostly yes, but
On current runners these files are owned by the runner user and the sandbox UID likely can't write them, but the value points at the path either way and the mode isn't a guarantee we control. Conservative default is to keep them out of the passthrough. Everything else under GHA_VARS=()
while IFS= read -r name; do
case "$name" in
GITHUB_TOKEN|GITHUB_ENV|GITHUB_PATH|GITHUB_OUTPUT|GITHUB_STATE|GITHUB_STEP_SUMMARY) continue ;;
esac
GHA_VARS+=("$name=${!name}")
done < <(compgen -e | grep '^GITHUB_')
sudo -u "$SANDBOX" env \
HOME="$AGENT_HOME" \
…existing entries… \
"${GHA_VARS[@]}" \
script -qefc "$WRAPPER" "$LOG" &Want me to push that shape onto this branch? |
|
OK. I don't exactly get how passing |
The two prior commits maintained an explicit list of GITHUB_* vars to
pass through `sudo env`. Switch to a denylist so future runner additions
(GITHUB_TRIGGERING_ACTOR, GITHUB_REF_PROTECTED, etc.) reach the agent
without per-var edits here.
Excluded:
- GITHUB_TOKEN: replaced by a dummy; real PAT lives in the proxy.
- GITHUB_{ENV,PATH,OUTPUT,STATE,STEP_SUMMARY}: paths the runner re-reads
after this step exits. Today the runner owns those files and the
sandbox UID can't open them for write, but the value still names the
channel.
|
Fair pushback — The reason I left it on the denylist is integrity, not security: the supervisor itself writes the transcript tail, the token-usage table, and the skill step-summary into Happy to drop it if you'd rather have parity with Pushed the denylist switch as |
Bumps the generator version to 0.1.4, syncs the lockfile, and adds the 0.1.4 CHANGELOG section (published as the GitHub Release notes on tag push). Notable changes since 0.1.3: - Claude harnesses switch to `bypassPermissions` (#677) - GitHub Releases publish from `CHANGELOG.md` on tag push (#678) — this release is the first live exercise of that workflow - Interactive sandbox receives GitHub Actions context env vars (#664) - install-tend bot-token step restructured around scope-audit remediation (#680) - Review skill checks the rollup before APPROVE (#667); running-in-ci/triage/ci-fix skill refinements (#661, #666, #669, #670, #671) > _This was written by Claude Code on behalf of max_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <[email protected]>
Regenerates the eight `tend-*.yaml` workflows with `uvx [email protected] init` — a pure ref bump, `@0.1.3` → `@0.1.4`, in each workflow plus its generated-by header. Also bumps the hand-maintained `review-reviewers.yaml`, which `tend init` doesn't regenerate. Until this merges, tend's deployed workflows run the 0.1.3 harness; notable in 0.1.4 is the switch to `bypassPermissions` (#677) and the GitHub Actions context env vars in the interactive sandbox (#664). > _This was written by Claude Code on behalf of max_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <[email protected]>
Problem
Every skill running under the interactive harness sees empty
$GITHUB_RUN_ID,$GITHUB_REPOSITORY,$GITHUB_WORKFLOW, etc. — the sandbox launch ininteractive/action.yamlusessudo -u "$SANDBOX" env VAR=..., which replaces the environment with only what's explicitly listed. The standard GitHub Actions context vars are not in the list, so they reach the agent's bash as empty strings.Many skills reference these vars directly:
running-in-ci/SKILL.md:$GITHUB_RUN_ID(self-check-run dedup in CI polling),$GITHUB_WORKFLOW,$GITHUB_REPOSITORY(artifact lookup, owner-correct URLs),git worktree add … -b skills/<topic>-$GITHUB_RUN_IDreview-reviewers/SKILL.mdandreview-runs/SKILL.md:grep -qF "$GITHUB_RUN_ID" /tmp/findings.mdguard,hourly/review-$GITHUB_RUN_ID/daily/review-runs-$GITHUB_RUN_IDbranch namesnotifications/SKILL.md:repos/$GITHUB_REPOSITORY/actions/runsAPI call,$GITHUB_RUN_IDself-filtertriage/SKILL.md:repos/$GITHUB_REPOSITORY/issues/...API callWhen
$GITHUB_RUN_IDis empty, the defense-in-depth guardgrep -qF "$GITHUB_RUN_ID" /tmp/findings.mdbecomesgrep -qF "", which matches any non-empty file and silently passes. The skill then PATCHes the gist with whatever heading the LLM hallucinated for the run ID.Evidence
Direct mechanistic confirmation in this run: probing
echo "GITHUB_RUN_ID=$GITHUB_RUN_ID"in the agent's bash returnsGITHUB_RUN_ID=(empty). Same forGITHUB_REPOSITORY,GITHUB_WORKFLOW,GITHUB_RUN_ATTEMPT.Visible outcome — a fabricated
## Run 27075391434 — 2026-06-06T22:16:36Zheading in the evidence gist formax-sixty/cargo-affected. The run ID27075391434doesn't exist (404 on bothrepos/max-sixty/tend/actions/runs/27075391434and the cargo-affected equivalent). The actual review-reviewers run for that matrix leg was27075279216at 22:11:18Z. The fabricated heading'sWorkflow:link points at the dead run ID, leaving a broken audit trail entry that prior runs use to count cumulative occurrences.The carry observation logged in the prior run (
27076519178) flagged this and set a 2/2 threshold; this run is the second observation. Source: evidence gist.Fix
Add the standard GitHub Actions context vars to the
sudo envallowlist ininteractive/action.yaml. These are public values (not secrets) that the agent's skills already assume are present.Plus an in-place comment explaining why the GHA vars need re-passing (
sudo envreplaces the env, doesn't extend it).Gate assessment
gh run listmasks it. The Claude (non-interactive) and Codex harnesses don't have this issue because they don't isolate viasudo env.What's out of scope
Not touching the skill-level
grep -qF "$GITHUB_RUN_ID"guard. With the env var actually populated, the guard works as designed. Strengthening it (e.g.[ -n "$GITHUB_RUN_ID" ] || exit 1) is defense-in-depth but adds churn for a hole that's now closed at the source.Not touching the
claude-code-action-based action.yaml — that harness doesn't strip env vars and isn't affected.