Skip to content

interactive: pass GitHub Actions context env vars to sandbox - #664

Merged
max-sixty merged 3 commits into
mainfrom
hourly/review-27077703125
Jun 7, 2026
Merged

max-sixty merged 3 commits into
mainfrom
hourly/review-27077703125

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

Every skill running under the interactive harness sees empty $GITHUB_RUN_ID, $GITHUB_REPOSITORY, $GITHUB_WORKFLOW, etc. — the sandbox launch in interactive/action.yaml uses sudo -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_ID
  • review-reviewers/SKILL.md and review-runs/SKILL.md: grep -qF "$GITHUB_RUN_ID" /tmp/findings.md guard, hourly/review-$GITHUB_RUN_ID / daily/review-runs-$GITHUB_RUN_ID branch names
  • notifications/SKILL.md: repos/$GITHUB_REPOSITORY/actions/runs API call, $GITHUB_RUN_ID self-filter
  • triage/SKILL.md: repos/$GITHUB_REPOSITORY/issues/... API call

When $GITHUB_RUN_ID is empty, the defense-in-depth guard grep -qF "$GITHUB_RUN_ID" /tmp/findings.md becomes grep -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 returns GITHUB_RUN_ID= (empty). Same for GITHUB_REPOSITORY, GITHUB_WORKFLOW, GITHUB_RUN_ATTEMPT.

Visible outcome — a fabricated ## Run 27075391434 — 2026-06-06T22:16:36Z heading in the evidence gist for max-sixty/cargo-affected. The run ID 27075391434 doesn't exist (404 on both repos/max-sixty/tend/actions/runs/27075391434 and the cargo-affected equivalent). The actual review-reviewers run for that matrix leg was 27075279216 at 22:11:18Z. The fabricated heading's Workflow: 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 env allowlist in interactive/action.yaml. These are public values (not secrets) that the agent's skills already assume are present.

+          GITHUB_ACTIONS="$GITHUB_ACTIONS" CI="${CI:-true}" \
+          GITHUB_RUN_ID="$GITHUB_RUN_ID" GITHUB_RUN_ATTEMPT="$GITHUB_RUN_ATTEMPT" \
+          GITHUB_REPOSITORY="$GITHUB_REPOSITORY" GITHUB_REPOSITORY_OWNER="$GITHUB_REPOSITORY_OWNER" \
+          GITHUB_WORKFLOW="$GITHUB_WORKFLOW" GITHUB_SERVER_URL="$GITHUB_SERVER_URL" \
+          GITHUB_EVENT_NAME="$GITHUB_EVENT_NAME" GITHUB_SHA="$GITHUB_SHA" GITHUB_REF="$GITHUB_REF" \

Plus an in-place comment explaining why the GHA vars need re-passing (sudo env replaces the env, doesn't extend it).

Gate assessment

  • Confidence: High. Mechanism observed directly (empty env vars in this run) and an outcome failure observed in the gist (fabricated run heading). Structural failure — same conditions produce the same failure every interactive run; only the LLM's stochastic ability to derive the correct ID from gh run list masks it. The Claude (non-interactive) and Codex harnesses don't have this issue because they don't isolate via sudo env.
  • Magnitude: Targeted fix — a single edit to one file, adding well-known env vars to a passthrough list. Affects every interactive-harness skill, which is appropriate given that every skill references these vars.
  • Both gates pass at High evidence (2 observations: outcome + mechanism) × Targeted fix.

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.

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 tend-agent added the claude-behavior Behavioral issues found by review-reviewers label Jun 7, 2026

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread interactive/action.yaml Resolved
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]>
@max-sixty

Copy link
Copy Markdown
Owner

should we add everything GITHUB_* apart from the token?

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Mostly yes, but GITHUB_TOKEN isn't the only one to exclude. The runner-write file paths are command-injection channels into the workflow's subsequent steps — the sandbox writing to them lands lines that the runner processes after our step exits:

  • GITHUB_ENV — appended K=V lines become env vars in later steps
  • GITHUB_PATH — appended lines get prepended to PATH in later steps
  • GITHUB_OUTPUT — sets step outputs
  • GITHUB_STATE — saves state for the post step
  • GITHUB_STEP_SUMMARY — markdown rendered in the job-summary UI

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 GITHUB_* is informational (GITHUB_ACTOR, GITHUB_API_URL, GITHUB_REF_NAME, GITHUB_WORKSPACE, …) and safe to pass. A small denylist also picks up future additions automatically:

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?

@max-sixty

Copy link
Copy Markdown
Owner

OK. I don't exactly get how passing GITHUB_STEP_SUMMARY is a security risk, but OK

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.
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Fair pushback — GITHUB_STEP_SUMMARY is the weakest of the five and isn't really a security risk on its own. The summary file is rendered markdown after the job finishes; writes there don't mutate later steps' env, PATH, outputs, or post-step state the way the other four do, so it isn't a privilege-escalation channel into the runner user.

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 $GITHUB_STEP_SUMMARY, and if the sandbox can append there it can splice content into the supervisor's own audit trail (or fill the 1 MiB cap and squeeze the supervisor's appends out). I'd rather the summary be one trusted writer than two.

Happy to drop it if you'd rather have parity with GITHUB_* everywhere — let me know.

Pushed the denylist switch as 1500531. The two earlier explicit-allowlist commits in this PR (291249e, 0dc3721) are now superseded but kept for review-history continuity; happy to squash on merge.

@max-sixty
max-sixty merged commit 0326c17 into main Jun 7, 2026
5 checks passed
@max-sixty
max-sixty deleted the hourly/review-27077703125 branch June 7, 2026 08:49
@max-sixty max-sixty mentioned this pull request Jun 11, 2026
max-sixty added a commit that referenced this pull request Jun 11, 2026
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]>
max-sixty added a commit that referenced this pull request Jun 11, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-behavior Behavioral issues found by review-reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants