Skip to content

Redact credentials the harness did not inject from raw artifacts - #112

Merged
leggetter merged 2 commits into
mainfrom
redact-minted-credentials
Nov 6, 2026
Merged

leggetter merged 2 commits into
mainfrom
redact-minted-credentials

Conversation

@leggetter

Copy link
Copy Markdown
Collaborator

Closes #110

What this fixes

Credentials the harness did not inject were not redacted from raw artifacts. Redaction worked by the values of the env vars the harness puts into the sandbox, plus a few vendor key shapes. The Hookdeck CLI key that hookdeck ci mints inside the sandbox is neither: the CLI writes it to ~/.config/hookdeck/config.toml, it has no prefix (the CLI only checks it is at least 12 characters), and no env var the harness can see holds it. An agent that printed the config file put the key in the transcript.

What changed

  • Values read from the sandbox (harness/sandbox-credentials.ts). After each attempt's agent run, while the container still exists and before the guards and scorer, the harness reads every Hookdeck CLI config file in the places the CLI looks (~/.config/hookdeck, $XDG_CONFIG_HOME, $HOOKDECK_CONFIG_FILE, any .hookdeck/ in the workspace). Their credential values (api_key, guest_url, *_token, *_secret) are added to the redaction set for every artifact the cell writes: the result file, its superseded attempts and errored-cell evidence. Each distinct value gets a numbered marker (<redacted:hookdeck-cli-config:api_key-1>, -2), so two minted keys stay distinguishable. The read never throws. If it does not complete, it says so on stderr with the exit code only and still uses whatever it read.
  • Redaction by assignment (harness/redact.ts). A value of 16 or more characters, containing a letter and a digit, is found by the name it is assigned to and then redacted by value everywhere it appears in the artifact. The forms are api_key = '…', NAME_KEY=…, "secret": "…", "webhook_secret_key": "…", "secret_access_key": "…", --webhook-secret … and Bearer …. header_key, plain key, references such as ${VAR}, $VAR and process.env.X, and placeholder words are left alone. Markers are numbered per artifact, so a transcript still shows whether two places held the same secret, which matters when the failure being read is a source configured with the wrong one.
  • Check before upload (scripts/check-artifacts.ts, lib/artifact-check.ts). A new workflow step re-applies the redaction passes to the files about to be uploaded and fails if anything would still be removed. It prints file, kind and count, never a value. When it fails, the job fails and both raw uploads are skipped. The cell's score is unchanged, but it is not published either: publish-results reads rows from those artifacts, so the cell counts as missing, and an earlier row stands in only where the missing-cell floor allows (Publish partly failed runs, never cancelled ones, and name what is missing #103). "Check the regression suite passed" still runs in that case, so a red regression cell is reported as one.
  • AGENTS.md: a Traps entry on where these credentials come from and what to update when that changes.

Verification

  • pnpm install, pnpm -r build, pnpm typecheck and pnpm format:check pass. pnpm check passes: framework 144 tests, core 115, sandbox 31, web 71. actionlint passes on the workflow.
  • New tests in test/minted-credentials.test.ts use fake values only. They cover each assignment form including the secret_key family, header names and references that must be left alone, idempotence, numbered markers, parsing the CLI config, the real discovery command run against a temporary HOME and workspace, discovery failing or timing out safely, discovered values reaching the result file, a superseded attempt and errored-cell evidence, and the upload check. Reverting each layer fails the tests that cover it.
  • Re-running the new redaction over a set of downloaded raw artifacts left no CLI keys and no values in webhook_secret_key or Outpost destination credentials.secret fields. A second pass changes nothing, so the upload check passes on what the harness writes.

Not covered

  • Artifacts already uploaded are not changed by this PR.
  • A config written to an arbitrary --hookdeck-config path outside the home directory and the workspace is not read. The assignment layer is the backstop for it.
  • The job log is not in scope. The engine writes agent error events to stderr, and these redaction passes do not apply there.
  • apps/framework/test/ is not in the framework tsconfig (unchanged), so the new tests run under vitest without being type-checked.

🤖 Generated with Claude Code

leggetter and others added 2 commits November 5, 2026 21:15
Raw artifacts were redacted by the values of the env vars the harness
injects, plus a few vendor key shapes. Credentials the harness did not
inject were not redacted from raw artifacts: `hookdeck ci` mints a CLI
key inside the sandbox and writes it to the CLI config file, and an agent
that printed the file put that key in the transcript. It has no prefix
and is in no env var the harness can see.

- Read the Hookdeck CLI config files out of each attempt's sandbox
  before it is torn down, and add their credential values to the
  redaction set for every artifact the cell writes: the result file,
  its superseded attempts and errored-cell evidence.
- Redact any value assigned to a credential-marking name (`api_key =
  '...'`, `KEY=...`, `"secret": "..."`, `--webhook-secret ...`,
  `Bearer ...`), everywhere it appears in the artifact. Distinct values
  get distinct numbered markers so a transcript still shows whether two
  places held the same secret.
- Add `check-artifacts`, which re-applies the redaction passes to the
  files about to be uploaded. The workflow runs it before both raw
  uploads and skips them if it finds anything, failing the job rather
  than the cell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad check

Follow-up to review of the raw-artifact redaction.

- Match `secret_key`, `secret_access_key` and Hookdeck's own
  `webhook_secret_key` in the JSON/YAML assignment pattern. It required
  `secret` to be followed directly by the quote, so values in those
  fields were not redacted. `header_key` and plain `key` stay excluded.
- Run "Check the regression suite passed" when the credential check has
  failed, so a red regression cell is still reported as one.
- Log to stderr when reading the sandbox's CLI config does not complete,
  with the exit code only and never the output, and keep what was read.
- Number discovered credentials per cell, so two minted keys stay
  distinguishable in a transcript, and precompute first-seen positions
  when numbering assigned values.
- Correct the docs: a failed credential check skips the uploads, and
  because publish-results reads rows from those artifacts the cell is
  not published either; it counts as missing, or an earlier row stands
  in under the missing-cell floor. State the assignment thresholds (16 or
  more characters, a letter and a digit) and that values are found by
  name and then redacted by value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leggetter
leggetter merged commit 8c681f2 into main Nov 6, 2026
1 check passed
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.

Raw artifacts published CLI keys that agents minted inside the sandbox

1 participant