feat(security): isolate secrets from agent context and redact from logs#5
Open
geminixiang wants to merge 2 commits into
Open
feat(security): isolate secrets from agent context and redact from logs#5geminixiang wants to merge 2 commits into
geminixiang wants to merge 2 commits into
Conversation
- 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
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.
from all log output (tool results, agent responses, user messages, errors)
vars from the environment passed to agent-executed bash commands, so the
LLM cannot exfiltrate tokens via
echo $MOM_SLACK_BOT_TOKENmain.ts for both log redaction and env var stripping
https://claude.ai/code/session_018zMoUT3oHWybsQRUBJfMaF