Secret Masking
Last updated
How secrets in tool output are masked before they reach the model, logs or a channel.
Since v1.3.11 secrets in tool output are masked before they reach the model, logs, action history or a channel (
internal/utils/secret, patterns in configs/jsons/secret_patterns.json). Detection is format matching only — private key blocks, credentials in URLs, Bearer / Basic / token values, netrc passwords, and provider token formats such as AWS access keys, GitHub, GitLab, Slack, Stripe, npm and Hugging Face tokens, and LLM API keys — and no LLM decides what to mask.| Item | Detail |
|---|---|
| Format | First 3 characters + ******** + last 3; a value shorter than 9 characters keeps only its first 3, and one of 3 characters or fewer becomes ******** alone. A PEM private key block is masked as one value, not line by line |
| Tool results and errors | Masked in toolregister.Dispatch, shared by the agent loop and the external MCP server |
| Streamed progress | Masked chunk by chunk through secret.Stream (in runToolExec and run_command's progress writer); a private key block split across chunks is dropped whole |
| Background reports | Masked in FinishBackground / UpdateBackground before the report is stored |
| Writing a mask back | write_file write_content / patch_contents[].new_string and a run_command argv that contain a masked value this daemon produced are refused with [Invalid], so a mask is never written over the real secret. Only the masked strings are remembered, never the originals |
A command that needs a key reads and uses it inside the same
run_command, for example ['sh', '-c', 'set -a; . ./.env; set +a; curl ...'] or security find-generic-password, so the value never passes through a tool result.