TL;DR: AI agents can leak secrets when access, memory and output paths stay broader than the task needs, Codenotary reports. Context scrubbing and output filtering have to work with issuance-time scope to keep secrets out of logs, chat and external services.
Editorial analysis by NHI Mgmt Group, based on content published by Codenotary: “Preventing AI Agents from Leaking Your Secrets”.
Key questions
Q: Why do AI agents complicate identity governance compared with human users?
A: AI agents complicate identity governance because they act autonomously, can change tasks quickly, and often use multiple secrets, APIs, and delegated privileges across systems.
Q: What are the signs that shadow AI is leaking secrets?
A: Look for prompts containing API keys, tokens, connection strings, customer data, or regulated information, especially when the same workstation also runs local models or AI plugins.
Q: How should security teams keep AI agents useful without letting them see secrets?
A: Use a credential broker or proxy so the agent can make authorised requests without ever handling the underlying tokens, API keys, or certificates.
Practitioner guidance
- Restrict agent read access to the minimum needed Remove broad file, shell and service access from general-purpose assistants and grant only the resources required for the specific task.
- Sanitise context before the model sees it Filter configuration files, environment variables and prompt content so secrets are removed before they enter the agent’s working memory.
- Filter outputs before they leave the workflow Mask secrets in responses, logs and shared channels so a helpful answer cannot become a disclosure path.
Bottom line: AI agents leak secrets when access, memory and output channels are wider than the task actually requires.
Glossary terms: AI Agent Secret Leakage, Task-Scoped Access, Context Cleaning, Output Filtering
Explore further
View Full Forum → | NHI Foundation Course → | Our Services → | Read the full analysis →
Secret leakage in AI agents is an identity and privilege problem before it is a data-loss problem. The decisive issue is not whether the model is clever enough to summarise safely, but whether the agent was ever allowed to see the secret in the first place. Once an autonomous system can read, remember and relay protected values, conventional human-centric confidentiality controls lose their leverage. Practitioners should govern AI agents as scoped identities with explicit authority boundaries.
A few things that frame the scale:
- 70% of organisations grant AI systems more access than they would give a human employee performing the exact same job, according to the 2026 Infrastructure Identity Survey.
A question worth separating out:
Q: How should organisations respond when AI-generated code exposes a secret?
A: Contain the exposure immediately by rotating or revoking the credential, then trace where it appeared in prompts, logs, repositories, and collaboration tools. After containment, review why the secret reached the workflow in the first place and tighten the control that failed, not just the one that detected it.
👉 Read our full editorial: AI agents can leak secrets without layered safeguards