Skip to content

Redact a passphrase in a recorded or exported command - #1523

Closed
cpruijsen wants to merge 2 commits into
CopilotKit:mainfrom
cpruijsen:redact-passphrase-in-commands
Closed

cpruijsen wants to merge 2 commits into
CopilotKit:mainfrom
cpruijsen:redact-passphrase-in-commands

Conversation

@cpruijsen

Copy link
Copy Markdown

What this changes

scrubCommand in server/src/telemetry/scrub.ts removes credentials from a Bot's shell command before Action Recording keeps it and before the OTLP export sends it. Three of its rules find a credential by the name it is passed under, from the SECRET_NAME list. That list had no PASSPHRASE, so these commands kept the passphrase in clear:

  • gpg --batch --yes --passphrase hunter2 --decrypt secrets.txt.gpg
  • BORG_PASSPHRASE=hunter2 borg create /mnt/backup::today ~/docs
  • PASSPHRASE=hunter2 duplicity /home/me file:///mnt/backup
  • MAVEN_GPG_PASSPHRASE=hunter2 mvn deploy

I added PASSPHRASE to SECRET_NAME, so the JSON key, NAME=value and --name value rules now redact a passphrase. --passphrase-fd 0 and --passphrase-file pw.txt do not change. Like PASSWORD_FILE= today, an assignment to a longer name that contains PASSPHRASE is also redacted, for example PASSPHRASE_FILE=pw.txt and BORG_PASSPHRASE_FD=3.

I kept this to PASSPHRASE, the name these tools use. PASSCODE, which shared/recorder-masking.ts and server/src/approvals/policy.ts also list, is one more word in the same list if you want it.

I did not open an issue first. The README asks for an issue or coordination before substantial work, and this change is one word in one list.

Where it runs

  • New state that outlives a request? None. scrubCommand is a pure function of the command it gets.
  • What happens on the second replica? It turns the same command into the same text as the first.
  • Anything serialised? None.
  • Anything fanned out to a browser? None.
  • New listener, port, or schedule? None.

Boundary and audit

  • Every acting call still goes through the gateway: resolve, decide, audit, then act. The change alters only the command text that is recorded and exported, not whether a command runs.
  • New refusals and new failures each write a row. The change adds no refusal and no failure.
  • Nothing new is trusted from the client that the server can resolve itself. The same command string goes through the same rules.

Changelog

  • One entry under Unreleased, in Smaller changes.

Proof

Action Recording rows for a Bot's computer, on PostgreSQL 17 with pgvector:

main
gpg --batch --yes --passphrase hunter2a --decrypt secrets.txt.gpg
BORG_PASSPHRASE=hunter2b borg create /mnt/backup::today ~/docs
PASSPHRASE=hunter2c duplicity /home/me file:///mnt/backup
MAVEN_GPG_PASSPHRASE=hunter2e mvn deploy

this change
gpg --batch --yes --passphrase [REDACTED] --decrypt secrets.txt.gpg
BORG_PASSPHRASE=[REDACTED] borg create /mnt/backup::today ~/docs
PASSPHRASE=[REDACTED] duplicity /home/me file:///mnt/backup
MAVEN_GPG_PASSPHRASE=[REDACTED] mvn deploy
  • Both runs sent seven passphrase commands through each caller of scrubCommand: the four above, GPG_PASSPHRASE=, gpg --passphrase= and a JSON body. I checked the Action Recording rows for a Bot's computer, the rows for host/run_command and the request bodies at a local OTLP/HTTP collector. On main, all 7 secrets reached all three. With this change, none did.
  • bun test server/tests/enterprise-controls.test.ts: 57 pass. With scrub.ts from main and the new rows kept: 54 pass, 3 fail, which are the gpg, BORG_PASSPHRASE and JSON rows. The --passphrase-fd 0 row passes on both.
  • bun test server/tests/otel-export-scrubbing.test.ts, which now also exports a gpg passphrase command to its collector: 1 pass. With scrub.ts from main it fails, and the passphrase is in the request body.
  • bun run format:check, bun run lint, bun run typecheck, bun run typecheck:tests and bun run build exit 0.
  • bun test server/ with PostgreSQL 17: 8,161 pass, 26 skip, 6 fail. The 6 fail the same way on main in that container, which cannot start a computer for them ("The computer did not start.").

scrubCommand redacts a credential by the name it is passed under, and
the list of names had no PASSPHRASE. So `gpg --passphrase secret`,
`BORG_PASSPHRASE=secret` and `PASSPHRASE=secret` were kept in clear in
Action Recording and in the copy exported to a telemetry collector.

Add PASSPHRASE to SECRET_NAME. The JSON key, NAME=value and flag rules
all read that list. `--passphrase-fd 0` and `--passphrase-file` are
unchanged.
@cpruijsen

Copy link
Copy Markdown
Author

Closing: #1530 removed server/, so scrubCommand is no longer in this repo, and shared/recorder-masking.ts already masks passphrase keys.

@cpruijsen cpruijsen closed this Nov 15, 2026
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.

1 participant