# Your AI Agent Remembers Every Secret It Sees

> AI coding agents can leak secrets when shell output containing credentials enters the conversation context sent to a model.

[Canonical HTML page](https://trustcyber.ca/insights/agentic-ai-secret-leakage/)

- Author: Junior Williams
- Type: Insight brief
- Published: 2026-02-24
- Modified: 2026-02-24
- Topics: Agentic AI, Secrets management

## What this examines

The article explains how AI coding agents can leak secrets when shell-command output containing credentials becomes part of the conversation context sent to a model provider. The article argues that prompt rules are probabilistic and insufficient; reliable protection requires deterministic hooks and defense in depth.

## Why it matters

The source proposes three layers: pre-tool-use blocking of dangerous commands, post-tool-use detection of leaked credential patterns, and documentation that teaches safe alternatives. It also recommends dynamic secret-name discovery, false-positive testing, monitoring, and immediate rotation on detection.

## Key ideas

- Any secret printed to stdout can become model context in agentic coding workflows.
- Rules such as "never retrieve secrets" reduce probability but do not enforce behavior.
- PreToolUse hooks can block commands before secret values are exposed.
- PostToolUse hooks can detect likely leaked credentials and trigger rotation.
- The practical security goal is reducing probability, detecting quickly, and limiting blast radius.

## Resources

- [Read the original on LinkedIn](https://www.linkedin.com/pulse/your-ai-agent-remembers-every-secret-sees-junior-williams-idf5c/)
