Skip to content

fix(secrets): record key names in secrets.generate so audit secrets attributes reads - #1115

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-audit-secrets-keys
Nov 27, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a-protected-audit-secrets-keys

Conversation

@sandstream

Copy link
Copy Markdown
Owner

What

kit secrets (CLI) and the MCP kit_secrets tool now record the declared key names in their secrets.generate audit event, under name (one key) or names (several), the shape src/secrets-write-record.ts already writes for writes and src/audit-secrets.ts already reads. kit audit secrets then attributes each read to its keys instead of listing it as unattributed. No value is logged.

Why

Found by the kit-research note kms-decrypt-evidence-vs-kit (Measurement, sections 1 and 2). src/subcommand-help.ts:120 and src/audit-secrets.ts:4-5 promise "who/what touched each key + when", but:

  • the CLI event carried only {store, template} (src/commands/secrets.ts:196-201);
  • the MCP path wrote metadata: {} (src/mcp-server.ts:354-356).

Measured on main: {"summary":{"totalEvents":0,"keyCount":0}, "unattributed":[{"operation":"secrets.generate","detail":"store=env env=dev"}]}.

How

  • src/secrets-write-record.ts: the name/names rule moves into a small pure helper, keyNameMetadata, which secretWriteEvent now uses too (same output as before). The comment explaining why it is not key/keys (sanitizeMetadata would redact them) moves with it.
  • src/commands/secrets.ts and src/mcp-server.ts: spread keyNameMetadata(Object.keys(secrets.keys)) into the event.

The names recorded are the keys declared in [secrets.keys], i.e. the ones the run tried to resolve. The event is written before resolution, so a key that failed to resolve is still listed; the event's success says whether the run as a whole succeeded.

Not changed (owner decision)

Whether these events are written at all when [governance] is off is unchanged: with the default config (DEFAULT_GOVERNANCE.enabled: false), withGovernance returns before any audit, so kit secrets still writes no event. Changing that is an owner decision, so this PR leaves it alone.

Also out of scope, as the note says: even with names, the honest answer is "no read through kit"; reads of .env.local by other processes stay invisible.

Tests

src/audit-secrets.test.ts runs kit secrets (cmdSecrets) and the MCP kit_secrets tool against a governed project with two declared keys, then runs groupBySecret(readSecretAuditEvents()). Both fail on main (the event lands in unattributed) and pass here. They also assert no declared value appears in the log.

Merge

These paths are protected (.github/kit-protected-paths.json, secrets: src/secrets-write-record.ts, and the secrets.generate audit contract read by src/audit-secrets.ts), so the owner merges this PR.

Platforms

Linux tested locally; CI covers Linux and Windows. macOS is unverified (no CI job runs it); the change is audit metadata only.


Generated by Claude Code

…ttributes reads

kit audit secrets promises "who/what touched each key + when", but the
secrets.generate event carried no key names (CLI: store only; MCP:
empty metadata), so every read landed in unattributed.

Both paths now record the declared key NAMES under name/names, the
shape secrets-write-record already uses for writes and audit-secrets
already reads. No value is logged. Whether events are written with
governance off is unchanged.

Found by kit-research note kms-decrypt-evidence-vs-kit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream-kit-reviewer sandstream-kit-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kit review gate at 5eb911fc401c: not approved.

  • touches protected paths (secrets), which the owner approves: src/commands/secrets.ts, src/secrets-write-record.ts

@sandstream
sandstream merged commit ee5ac98 into main Nov 27, 2026
33 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a-protected-audit-secrets-keys branch November 27, 2026 11:27
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.

2 participants