Skip to content

feat: redact known secret formats from transcripts before publishing - #5

Open
mvanhorn wants to merge 1 commit into
spacefast:mainfrom
mvanhorn:fix/push-session-redact-secrets
Open

mvanhorn wants to merge 1 commit into
spacefast:mainfrom
mvanhorn:fix/push-session-redact-secrets

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

Shared sessions no longer carry API keys, tokens and passwords from the transcript. Before rendering, push-session replaces known secret formats with [redacted: <kind>], and the dry run tells you how many it caught before anything uploads. It is on by default; --no-redact keeps the raw transcript.

Why this matters

Coding-agent transcripts are full of tool output: cat .env, gh auth token, curl calls with Authorization headers, connection strings. Today that text is published verbatim, and the README can only warn ("Sessions can contain code, file paths, commands, and secrets"). On one machine, agent sessions from the past month held 39 strings shaped like Anthropic API keys, and each of them would have reached the share link.

Demo

Simulated demo (HyperFrames), built from a real dry run on a fixture session with fake keys:

demo

Changes

  • src/redact.js is a pure pass over every string in the loaded messages (text, tool input, tool output) plus the session title. It runs once in run() before renderSessionWithArtifacts, so pages, artifacts and the viewer get the same redacted data.
  • Rules are high-confidence only: Anthropic, OpenAI, GitHub, GitLab, Slack, Stripe live, AWS access key ID, Google and npm token formats; PEM private-key blocks; Authorization: Bearer|Basic values; URL passwords; and KEY=value or "key": "value" where the key name looks secret. There is no entropy guessing.
  • To keep code readable, unquoted right-hand sides that are expressions are left alone: process.env.API_KEY, getToken(), /regex/, $VAR, <token> and other placeholders.
  • --dry-run and the publish summary print redactions: N (kind: n, ...), and --json adds redactions and redactionCounts. Local session files are never modified.

Recovered artifact and Site source files are not scanned in this change. Sites already filter by filename.

Testing

  • npm run check passes 94 tests, including a new test/redact.test.js with a positive case and a near-miss per rule, plus CLI cases for the dry-run counts and --no-redact.
  • On a fixture session with fake keys, the dry run reports redactions: 4 (anthropic: 1, github: 1, bearer: 1, url-password: 1), and --no-redact reports 0.
  • On real local sessions, a 1,002-entry session that contains two live Anthropic keys reports anthropic: 2. A long coding session full of source code came out with no false hits after the expression and placeholder rules went in.

Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Transcripts often carry API keys, bearer headers and .env values from tool
output. Replace known token formats, PEM private keys, Authorization values,
secret-named assignments and URL passwords with [redacted: <kind>] before
rendering. On by default; --no-redact opts out. Dry runs and publishes report
the count per kind.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93f7bd48-458e-40a3-b106-96c187aee079
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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