Skip to content

feat(harness-ops): add a live behavior probe for the subprocess env scrub - #12723

Merged
kyle-sexton merged 5 commits into
mainfrom
feat/12702-env-scrub-behavior-probe
Nov 3, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
feat/12702-env-scrub-behavior-probe

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #12702

Summary

Adds an env-scrub area to /harness-ops:behavior-probes: a live case with a paired control that checks CLAUDE_CODE_SUBPROCESS_ENV_SCRUB keeps a planted fake credential away from a Bash child. Lanes rely on the scrub, and until now only that the variable was set was tested, so a Claude Code release could change the behavior with no check failing.

Fix

  • cases/lib/plant-check.py reads two channels independently (its own /proc/self/environ, and every other readable /proc/<pid>/environ), compares sha256 hashes, and prints a fixed marker naming both. It cannot read its own environ: it crashes with no marker, which the case reads as inconclusive.
  • scripts/probe.py gains plant_env (a fresh secrets.token_hex(32) value per run, reaching only the child environment, with only its hash on disk) and target.result_match. A plant_env case must be verdict_only, in validate and again in run_case before planting.
  • Scrub on passes only on own=not-found others=not-found. The control passes only on own=found others=found, and the scrub-on pass holds only while the control passes.
  • The planted variable is AWS_SECRET_ACCESS_KEY, a variable the docs say the scrub removes. What the scrub removes and keeps is left to the linked docs section, not restated.

Verification

  • probe.py validate: 50 cases, 0 problems.
  • probe.test.sh: 80 tests pass, run by the orchestrator on this head.
  • Live run of the two new cases, by the worker: both pass on Claude Code 2.1.317 (record 20). Not repeated by the orchestrator or the verifier.
  • Two fresh-context verifier passes, 8 of 8 and then 9 of 9 criteria, the second on 19ccaf93d5.

Known limits:

  • The planted variable is a stand-in; planting CLAUDE_CODE_OAUTH_TOKEN would replace the turn's own authentication, so no run shows the scrub removing that token.
  • The control's others=found can come from any other process holding the value, such as the Bash tool's own shell. It shows /proc reads cross a process boundary, not that claude's environ was the one read; record 20 says so. The control's claim line in expect.json reads stronger than that.
  • A successful read of an empty /proc/self/environ would print own=not-found; not exercised.
  • The probe runs on request. /harness-ops:changelog flags it only when a release note matches its tags.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD

kyle-sexton and others added 5 commits November 2, 2026 23:44
…ential

Tests only asserted that lanes set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB, so a
release could change what it does with no check failing. Add an env-scrub
area to behavior-probes: a real turn with a random fake credential planted,
a checker that compares hashes of its environment and every readable
/proc/<pid>/environ, and a paired control with the scrub off.

The runner gains plant_env, a fresh per-run value that reaches only the child
environment, and target.result_match, which reads a tool result not of the
expected shape as inconclusive rather than fail.

Both cases passed live on Claude Code 2.1.317 (record 20).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD
The checker stopped at its own environment, so the scrub-off control never
showed another process's environ is readable, and an unreadable /proc let
the scrub-on case pass falsely.

The checker now reports its own environment and other processes' environ
separately, leaving its own process out of the scan, and crashes with no
marker when it cannot read /proc/self/environ. The control passes only when
both channels find the value; the scrub-on case only when neither does.

run_case refuses a plant_env case that is not verdict_only before planting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q4SUwLX9M3bKXJidsD
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 3, 2026 05:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T05:23:38.316824Z f84f0d5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed f84f0d5d2f7afdba0b621635135145fd664a2e31: read 14 of 14 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #12723 (env-scrub behavior probe)

No security issues found.

Scope. I read every hunk in the full diff. That covers 12 of the 14 listed files. The other two are prompt.md and settings.json in the control case, which are identical copies of the scrub-on case's files and are counted with them. Both copies are inert at their paths: a prompt file and an empty {} settings file inside a case directory. None of the changed files is under a trusted path, and the PR touches no plugin manifest, workflow, trust control or merge hold.

What I checked:

  • Planted value handling (probe.py). plant() creates a fresh probe-fake- + secrets.token_hex(32) value for each run and writes only its sha256 into the temp workdir. The value goes only into resolved["env"], which feeds child_env() at probe.py:701 (the env passed to the child claude). Rows are built from case, so the value never reaches a saved row. A plant_env case must be verdict_only, and this is checked twice: in case_problems and again in run_case before anything is planted. So no stream or tool output that could carry the value is kept. plant_env also cannot name a variable in ENV_ALLOWLIST, so a case cannot overwrite a passed-through variable such as the turn's authentication.
  • Checker (cases/lib/plant-check.py). It reads /proc/self/environ and every other /proc/<pid>/environ the user can read. It only hashes each value and compares the hash to the planted one, and it prints one fixed marker. No environment content from the operator's other processes is printed or written, so it cannot leak real secrets.
  • Permissions. Both cases run under dontAsk. The only allowed tool is Bash(python3 ${PROBE_WORKDIR}/plant-check.py), and Read, Grep and Glob are disallowed. That stops the model turn from reading the hash file or anything else.
  • Instruction surface. The SKILL.md and records.md changes only add text. They remove or soften no standing rule.
  • Untrusted input. The cases run only when an operator asks. No PR, issue or comment author can reach the new code path.
  • Embedded text. There are no directives in the PR context.

Spend (not a finding): each live case run is capped at max_budget_usd: 0.5 and 3 turns, drawn from prepaid API credit or subscription usage, and runs only when an operator asks.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed f84f0d5d2f7afdba0b621635135145fd664a2e31: read 14 of 14 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read all 14 changed files. Two pairs are identical copies (prompt.md and settings.json in the two env-scrub case directories), so files_read counts the first file of each pair. Reusing those files at the control path doesn't change what they do: the two cases differ only in expect.json, as intended.

What I checked

  • Control isolation. The control case can only show the scrub making the difference if the scrub variable isn't already set. child_env passes only ENV_ALLOWLIST, which doesn't include CLAUDE_CODE_SUBPROCESS_ENV_SCRUB. build_argv uses --setting-sources project,local from a fresh temp directory, so a user-level env setting can't turn the scrub on. The variable is the only difference between the two cases.
  • Where the planted value can go.
    • It goes only into resolved["env"], and rows are built from case, so the value never enters a row.
    • run_case rejects a case that isn't verdict-only before anything is planted, so live_runner never saves a raw stream for these cases.
    • stderr is discarded and --no-session-persistence is set.
    • Only the sha256 is written to disk.
    • The plant_env check against ENV_ALLOWLIST covers ANTHROPIC_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, HOME and CLAUDE_CONFIG_DIR, so a planted variable can't replace the turn's authentication.
  • The result_match gate. It runs before satisfies, so a denial, a sandbox error, or a crash in plant-check.py (unreadable own environ, missing hash file) comes out inconclusive, never pass or fail. When match is absent, the validation falls back to "dry run", which is the text dry_run produces itself, so it stays consistent.
  • The checker. plant-check.py matches on the hash of each variable's value, skips its own PID, and treats unreadable environs of other processes as not found. The tests run it for real across all four channel combinations and the case where its own environ is unreadable.

Closing issue #12702, acceptance criteria

  1. Scrub on, value not readable from the child's own environment or another process's /proc/<pid>/environ: met. ShippedEnvScrubCaseTests and PlantCheckTests would fail if this broke.
  2. A paired control with the scrub off: met. control is wired up and the control passes only on own=found others=found, which is tested.
  3. A random, fake value that never reaches a log or record: met. PlantEnvTests covers the row, the prompt, the scaffold environment and refusal before planting.
  4. Results recorded with the Claude Code version: met. Rows go through base_row and verdict, and the record lists 2.1.317.
  5. The list of what the scrub keeps comes from the docs and isn't restated: met. The cases list nothing, and SKILL.md and record 20 point to the docs section with an as-of date and a recheck trigger.

Not verified: the live run in record 20 and the "80 tests pass" result come from the PR author. I had no shell and ran nothing.

No embedded instructions were found in the PR context or the prior-findings file.

Spend: each live run of these cases uses prepaid API credit, capped at max_budget_usd 0.5 per case. They run only on request. This isn't a hold.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 7a1e859 Nov 3, 2026
56 of 68 checks passed
@kyle-sexton
kyle-sexton deleted the feat/12702-env-scrub-behavior-probe branch November 3, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(harness-ops): add a live behavior probe for the subprocess env scrub

1 participant