Back to feed
Dev.to
Dev.to
8/2/2026
Stop Leaking Secrets into your LLM Context Windows

Stop Leaking Secrets into your LLM Context Windows

Short summary

The article explains how AI agents with tool access can leak secrets (API keys, session tokens) into LLM context windows and provider logs. It introduces the Tool Output Entropy Sanitizer, an MCP server that uses Shannon entropy with a sliding-window approach to detect and redact high-entropy strings before they reach the model. Redacted segments are replaced with structured placeholders to preserve reasoning context for the agent.

  • AI agents can leak secrets into LLM context windows via tool outputs, exposing them in provider logs
  • Regex-based detection fails for non-standard secret formats; entropy-based detection is more robust
  • Tool Output Entropy Sanitizer uses sliding-window Shannon entropy (threshold 4.5) to redact secrets before they reach the LLM

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more