Skip to content

skills(running-in-ci): close the env-filter loophole for ALL_INPUTS secrets - #599

Merged
max-sixty merged 2 commits into
mainfrom
daily/review-runs-26392626323
May 25, 2026
Merged

max-sixty merged 2 commits into
mainfrom
daily/review-runs-26392626323

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Summary

Tighten the Secrets rule in running-in-ci to head off a specific leak path that triggered during the 2026-05-24 weekly run on this repo. The current rule lists env/printenv as forbidden but is silent on names-only filters like env | cut -d= -f1, which the agent treats as a safe escape hatch when investigating the workflow environment.

What happened

During the weekly integration-test recipe (§1 troubleshooting), the agent ran:

env | cut -d= -f1 | sort | grep -iE 'claude|anthropic|oauth|token'

The intent was "names only, no values." The actual output included the CLAUDE_CODE_OAUTH_TOKEN and github_token values in cleartext — they landed in the session-log artifact for that run. (Filed separately as #598 with rotation guidance.)

Why the filter doesn't work

claude-code-action exposes ALL_INPUTS to the agent process as a multi-line JSON blob:

ALL_INPUTS={
  "claude_code_oauth_token": "sk-ant-oat01-…",
  "github_token": "ghp_…",
  …
}

env emits the value verbatim, including its embedded newlines. From cut's perspective, each continuation line of the JSON looks like its own variable: the secret string is before the first = on that line (often there's no = at all), so cut -d= -f1 keeps the entire line. The downstream grep -iE 'claude|...|token' then matches the credential lines exactly and prints them.

action.yaml:229 pins CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: "0" to dodge a different Linux bash bug (anthropics/claude-code#35701), so the agent's subprocess inherits ALL_INPUTS directly — there is no upstream scrub catching this.

Change

One paragraph in plugins/tend-ci-runner/skills/running-in-ci/SKILL.md:

  • Names the structural leak path (multi-line JSON in ALL_INPUTS)
  • Calls out the specific filter pattern that looks safe but isn't
  • Keeps the rule absolute: no introspection of the process env, period

Classification

  • Structural failure: the env layout is deterministic across runs; the same filter leaks the same secrets every time.
  • Gate 1 — Confidence: Critical (real production tokens emitted into an artifact). 1 occurrence is the bar.
  • Gate 2 — Magnitude: targeted one-paragraph rule clarification; no new section or workflow change.

Test plan

  • Maintainer review — the rule reads as universally applicable to every consumer, not tend-specific.
  • Pre-commit clean.

🤖 Generated with Claude Code

…ecrets

The Secrets rule already forbids `env`/`printenv`/etc., but a name-only
filter like `env | cut -d= -f1` reads as a safe escape hatch — it isn't.
claude-code-action injects ALL_INPUTS as a multi-line JSON env value
embedding claude_code_oauth_token and github_token; newlines defeat the
filter and the secrets leak verbatim into the session log.

Run 26358181381 hit exactly this path. The rule is now absolute and names
the leak path so future runs don't re-derive the bypass.
@tend-agent tend-agent added the review-runs Findings from review-runs skill label May 25, 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.

The rule itself reads well — making the prohibition absolute and re-grounding "expose secrets" → "introspect the process env" closes the door on the workaround. One concern on the second example, inline.

## Restrictions

- **Secrets**: Never run commands that expose secrets (`env`, `printenv`, `set`, `export`, `cat`/`echo` on credential files). Never include tokens or credentials in responses or comments.
- **Secrets**: Never run commands that introspect the process env (`env`, `printenv`, `set`, `export`) or `cat`/`echo` credential files. The rule is absolute — names-only filters like `env | cut -d= -f1` or `env | grep -E '^[A-Z]+='` do not make these commands safe, because `claude-code-action` injects `ALL_INPUTS` as a multi-line JSON env value embedding `claude_code_oauth_token` and `github_token` in cleartext. The JSON's newlines turn each token-bearing line into its own `env` output line, where the value sits *before* the `=` and a name-stripping filter leaks it verbatim into the session log. Never include tokens or credentials in responses or comments.

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.

The env | grep -E '^[A-Z]+=' example doesn't fit the explanation that follows. The regex requires names of only uppercase letters — ALL_INPUTS (with an underscore) doesn't match it, so the multi-line-JSON leak path described in the bullet wouldn't fire on this filter at all. And the grep keeps full NAME=VALUE lines for any matching variable — it isn't a name-stripping filter, so the surrounding "value sits before the =" reasoning doesn't apply either. The single cut -d= -f1 example is enough to anchor the rule; suggesting we drop the second one (or replace it with another genuine name-stripper like env | sed 's/=.*//' that fails for the same reason as cut).

Suggested change
- **Secrets**: Never run commands that introspect the process env (`env`, `printenv`, `set`, `export`) or `cat`/`echo` credential files. The rule is absolute — names-only filters like `env | cut -d= -f1` or `env | grep -E '^[A-Z]+='` do not make these commands safe, because `claude-code-action` injects `ALL_INPUTS` as a multi-line JSON env value embedding `claude_code_oauth_token` and `github_token` in cleartext. The JSON's newlines turn each token-bearing line into its own `env` output line, where the value sits *before* the `=` and a name-stripping filter leaks it verbatim into the session log. Never include tokens or credentials in responses or comments.
- **Secrets**: Never run commands that introspect the process env (`env`, `printenv`, `set`, `export`) or `cat`/`echo` credential files. The rule is absolute — name-stripping filters like `env | cut -d= -f1` do not make these commands safe, because `claude-code-action` injects `ALL_INPUTS` as a multi-line JSON env value embedding `claude_code_oauth_token` and `github_token` in cleartext. The JSON's newlines turn each token-bearing line into its own `env` output line, where the value sits *before* the `=` and a name-stripping filter leaks it verbatim into the session log. Never include tokens or credentials in responses or comments.

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.

Agreed — the ^[A-Z]+= regex skips ALL_INPUTS outright (the underscore breaks [A-Z]+), and grep keeps full NAME=VALUE lines so it isn't a name-stripper anyway. Dropped the second example in f4b6ae3.

Why: env | grep -E '^[A-Z]+=' doesn't match ALL_INPUTS (the underscore
breaks [A-Z]+), and grep keeps full NAME=VALUE lines anyway — it isn't a
name-stripper, so the surrounding "value sits before the =" reasoning
doesn't apply to it. The cut -d= -f1 example is enough to anchor the
rule.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@max-sixty
max-sixty merged commit 6db0b52 into main May 25, 2026
5 of 6 checks passed
@max-sixty
max-sixty deleted the daily/review-runs-26392626323 branch May 25, 2026 16:41
@max-sixty max-sixty mentioned this pull request May 27, 2026
max-sixty added a commit that referenced this pull request May 27, 2026
## Why

Cut the 0.1.2 release so consumer repos (and tend's own nightly regen)
pick up the new
`claude-interactive` harness and per-workflow `harness`/`model`
overrides.

## What's new since 0.1.1

**New `claude-interactive` harness**
(`max-sixty/tend/[email protected]`) — opt-in
alternative to the released `claude` harness. PTY-supervised interactive
`claude` via
`script(1)`, end-of-turn detected through Stop/StopFailure hooks. Built
as the
trial path ahead of Anthropic's June 15 billing split between Agent-SDK
metering and
the flat Claude Code subscription. Smoke tested end-to-end on tend
itself. PRs:
#609, #611, #613, #614, #615, #616.

**Per-workflow `harness` / `model` override** — adopters can flip a
single workflow
to a different harness or model without changing `.config/tend.yaml`
defaults. #612.

**Skill refinements** — nightly upstream-bot rebases (#605),
running-in-ci PR bar
(#604) and recheck (#573), env-filter loophole fix (#599),
authorAssociation warning
(#600), review-gates Gate 1 (#602).

**Bug fix** — mention queue-delay now uses `comment.updated_at` so edit
events report
accurately (#595).

## Compatibility

Released `claude` harness path is byte-identical; `claude-interactive`
is strictly
additive and opt-in. Consumer repos that don't touch `harness:` see no
change beyond
the new skill text and the mention-edit fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-runs Findings from review-runs skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants