Repository navigation
feat(secrets): record every secret read in the audit chain, governance on or off - #1126
Merged
sandstream merged 6 commits intoNov 27, 2026
Conversation
…e on or off kit secrets with the default config wrote no audit event: the only record of a read was the governed secrets.generate, and withGovernance returns before any audit when governance is off. Reads now append a secrets.read event (key names, store, kit surface, detected harness, declared agent; never a value) through the same hash-chained append writes use, before the value is fetched. A read that cannot be recorded is refused. Covers kit secrets (sync, validate, onecli), MCP kit_secrets, kit run and kit_run, the exec-broker, kit check's vault probes, kit fix and the branch-protection audit. A source scan keeps every resolveViaBackend call behind a recorded read. Found by kit-research note kms-decrypt-evidence-vs-kit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
kit review gate at 074c93c12c1a: not approved.
- checks did not pass: windows shard 4/4, windows-native
- touches protected paths (permissions, secrets), which the owner approves:
src/audit-secrets.ts,src/check-secrets.test.ts,src/check-secrets.ts,src/commands/secrets.ts,src/exec-broker/broker.test.ts,src/exec-broker/broker.ts,src/secrets-read-record.test.ts,src/secrets-read-record.ts,src/secrets-sync.ts,src/secrets.ts
kit secrets sync --dry-run still resolves every value, so it now appends a secrets.read record (names only). The preview test keeps asserting that no value is written and nothing else changes, and that the record names the key without its value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
kit review gate at 4ef7091992d8: not approved.
- touches protected paths (permissions, secrets), which the owner approves:
src/audit-secrets.ts,src/check-secrets.test.ts,src/check-secrets.ts,src/commands/secrets.ts,src/exec-broker/broker.test.ts,src/exec-broker/broker.ts,src/secrets-read-record.test.ts,src/secrets-read-record.ts,src/secrets-sync.ts,src/secrets.ts
Base automatically changed from
claude/web-kit-status-sync-p6fg9a-protected-audit-secrets-keys
to
main
November 27, 2026 11:27
…-sync-p6fg9a-protected-secret-read-events # Conflicts: # src/run.ts
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
…secret-read-events
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
There was a problem hiding this comment.
kit review gate at ac2f1d592b71: not approved.
- checks did not pass: build-and-test, checks (format, lint, build, gates), linux shard 4/4
- touches protected paths (permissions, secrets), which the owner approves:
src/audit-secrets.ts,src/check-secrets.test.ts,src/check-secrets.ts,src/commands/secrets.ts,src/exec-broker/broker.test.ts,src/exec-broker/broker.ts,src/secrets-read-record.test.ts,src/secrets-read-record.ts,src/secrets-sync.ts,src/secrets.ts
…cret-read-events Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/COMMANDS.md sits exactly at the 600-line file-size gate on main, so the 11 lines this branch added there failed `kit standards --enforce`. The paragraph describes what a read writes to the audit log, which is what DATA_FLOW.md (linked from the top of COMMANDS.md) documents per operation. COMMANDS.md keeps a single, folded sentence in the `kit run` section with a link to it. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published. |
There was a problem hiding this comment.
kit review gate at 867bced4761b: not approved.
- touches protected paths (permissions, secrets), which the owner approves:
src/audit-secrets.ts,src/check-secrets.test.ts,src/check-secrets.ts,src/commands/secrets.ts,src/exec-broker/broker.test.ts,src/exec-broker/broker.ts,src/secrets-read-record.test.ts,src/secrets-read-record.ts,src/secrets-sync.ts,src/secrets.ts
sandstream
deleted the
claude/web-kit-status-sync-p6fg9a-protected-secret-read-events
branch
November 27, 2026 13:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1115 (base branch
claude/web-kit-status-sync-p6fg9a-protected-audit-secrets-keys). Protected — owner merges (src/secrets*,src/check-secrets.ts,src/audit-secrets.ts,src/exec-broker/).Found by kit-research note
kms-decrypt-evidence-vs-kit(Plan item 4, owner-approved): a read through kit should be a request someone can see later, per key, names only.What governance gates today, and why reads were invisible
DEFAULT_GOVERNANCEinsrc/governance.tsshipsenabled: false, andwithGovernance(src/governance-middleware.ts) returns before any audit:What governance adds when it is on, per
docs/COMMANDS.md: "Enabled governance checks permissions, revocation, budget, and configured secret expiration before execution." plus "Governance and resource rules record their own audit events when enabled." Its events go throughlogAuditEvent, which also stamps[governance.agent]and does the opt-in remote push ([governance.audit].remote).The only record of a
kit secretsread was that governedsecrets.generate, so the default config recorded nothing. Writes were already recorded without governance throughappendAuditEventDirect(src/secrets-write-record.ts). The hash chain and the HMAC anchor are not governance-only:appendSerializedanchors both paths.Change
New
src/secrets-read-record.ts: onesecrets.readevent per store, appended throughappendAuditEventDirect(same chain, same anchor as writes), before the value is fetched or handed on. Metadata:name/names(key names),store,via(the kit surface),harness(Claude Code or Codex, fromdetectAgentSession), andagent_id/agent_namefrom[governance.agent]where the caller has the config. Never a value, never a digest of one. Time is the event timestamp.kit secrets,secrets sync,secrets onecli register, MCPkit_secretsgenerateSecrets(src/secrets.ts)kit secrets validate,kit fixdeploy step, branch-protection auditresolveRecorded(one key)kit run, MCPkit_run(andkit setupcommands)executeCommand(src/run.ts): the.env.localnames given to the childbrokerExec: the requested env names handed torun()kit checkvault probes (op read,get-secret-value, …)checkSecrets: names of non-env/configkeys it probeskit secrets incidentsecrets.incidentwith namesgate-envsrc/commands/gate.tscmdGateEnvblocks plaintext writes to.env*) and never resolves or injects a secretA source-scan test fails if
resolveViaBackend(is called from any file other than the five that record the read first.Fail closed. If the record cannot be appended (damaged chain, unwritable log, missing sealed log), kit refuses the read:
kit secretswrites no.env.local,kit rundoes not start the child, the broker does not callrun(). The append failure also turns the exit code non-zero (src/audit-loss.ts). Owner decision point: this means a broken.kit-audit.jsonlnow blockskit secrets/kit runwith governance off, where before it did not. The record is written before the fetch, so it can over-report (a read that then fails), never under-report.Unchanged and still governance-only: permission/revocation/budget/approval checks, the agent stamp on governed events, the remote push. With governance on,
kit secretsnow writes both the governedsecrets.generateand the newsecrets.read.kit audit secretsnow includessecrets.readand printsvia=/harness=.Before / after
Scratch project, governance off (default), fixture values
fixture-not-a-secret-0001and4821,kit secretsthenkit run -- node -e "":New tests (
src/secrets-read-record.test.ts) run against the base:On this branch:
# tests 9 # pass 9 # fail 0(adds harness attribution for Claude Code and Codex, per-store grouping, and theresolveViaBackendsource scan). Existing tests that counted audit lines (run-policy-contract,broker) now account for the read event.kit secrets sync --dry-runstill resolves every value, so it now leaves onesecrets.readrecord (names only);command-validation.test.tsallows exactly that and checks the value is absent. Full Linux suite locally: 13344 pass, 2 fail (audit-external-process-interruptionSIGTERM/SIGINT, which fail identically on the base in this container).Harnesses
The record is written by kit itself, so it happens under any harness or a plain terminal.
harnessis named for Claude Code (CLAUDECODE=1) and Codex (CODEX_THREAD_ID), the two kit has measured. Cursor, Cline, Copilot, Gemini CLI and Augment (the other harnesses inAGENT_TARGETS) are recorded withviaand the declared agent, but noharnessname: kit has no measured env marker for them.Coverage limit
Reads through kit only. A process that opens
.env.localitself is not visible; that is PR 4's subject (inject at exec time).Platforms
Tested on Linux. Paths use
node:path(dirname/resolve;devNullfromnode:osfor sync). No shell or POSIX-only call added. Windows runs in CI. macOS is unverified.node scripts/prepush.mjs --allow "enforcement gate liveness": all steps pass locally except the known local-onlykit review --enforcetool gaps and Semgrep (not installed).adr check: no new violations.Generated by Claude Code