Skip to content

feat(security): isolate secrets from agent context and redact from logs#5

Open
geminixiang wants to merge 2 commits into
mainfrom
claude/secure-agent-secrets-Rs2bY
Open

feat(security): isolate secrets from agent context and redact from logs#5
geminixiang wants to merge 2 commits into
mainfrom
claude/secure-agent-secrets-Rs2bY

Conversation

@geminixiang

Copy link
Copy Markdown
Owner
  • Add SecretRedactor to log.ts: registers secret values and redacts them
    from all log output (tool results, agent responses, user messages, errors)
  • Add registerSecretEnvVar() to sandbox.ts: strips registered secret env
    vars from the environment passed to agent-executed bash commands, so the
    LLM cannot exfiltrate tokens via echo $MOM_SLACK_BOT_TOKEN
  • Register all platform tokens (Slack/Telegram/Discord) at startup in
    main.ts for both log redaction and env var stripping

https://claude.ai/code/session_018zMoUT3oHWybsQRUBJfMaF

claude added 2 commits March 20, 2026 06:03
- Add SecretRedactor to log.ts: registers secret values and redacts them
  from all log output (tool results, agent responses, user messages, errors)
- Add registerSecretEnvVar() to sandbox.ts: strips registered secret env
  vars from the environment passed to agent-executed bash commands, so the
  LLM cannot exfiltrate tokens via `echo $MOM_SLACK_BOT_TOKEN`
- Register all platform tokens (Slack/Telegram/Discord) at startup in
  main.ts for both log redaction and env var stripping

https://claude.ai/code/session_018zMoUT3oHWybsQRUBJfMaF
Extract secret registry into src/redact.ts so it can be shared between
the log layer and the tool layer without circular dependencies.

Wrap every tool's execute() in withRedaction() (tools/index.ts) so that:
- Text content blocks returned to the LLM are redacted
- Error messages thrown from tools (e.g. bash non-zero exit with output)
  are also redacted before reaching the LLM context window

This closes the remaining leak path where a secret could silently survive
in context.jsonl even though it was already scrubbed from logs.

https://claude.ai/code/session_018zMoUT3oHWybsQRUBJfMaF
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