Join our Newsletter — 33% off our NHI Course
Home› Glossary› Agentic AI & Autonomous Identity› Context Window Leakage
Agentic AI & Autonomous Identity

Context Window Leakage

← Back to Glossary
By NHI Mgmt Group Updated October 23, 2026 Domain: Agentic AI & Autonomous Identity

Context window leakage is the unintended exposure of sensitive information to an AI model through the text or data included in its active prompt context. In agentic AI and MCP workflows, this can reveal secrets, personal data, policies, or internal instructions across sessions, tools, or chained prompts, creating governance and security risk.

What context window leakage means in practice

context window leakage happens when content that should have stayed private becomes part of the model’s active working context, so the model can echo, transform, or carry it into later outputs. In agentic systems, that leakage can occur across user turns, tool calls, shared memory, or chained prompts.

The important point is that the model is not “stealing” data on its own, it is being shown information that should not have been in the prompt context in the first place. That makes prompt construction, context assembly, and memory handling core security concerns, especially when the context includes secrets, policy text, or sensitive customer data.

Why this leakage becomes a security problem

Once sensitive material enters the active context, it can be surfaced in responses, summarized into logs, reused by downstream tools, or carried into later steps of an agent workflow. That turns a local prompt issue into a broader confidentiality and governance problem, because the exposure can cross session boundaries and affect multiple users or systems.

The danger is amplified when the context contains credentials, internal instructions, or privileged operational detail. Even if the model does not output the entire secret verbatim, partial disclosure can still reveal enough structure, policy language, or reference material to help an attacker, or to create compliance exposure if the content includes personal data.

Common ways leakage enters LLM and agent workflows

Leakage often begins with overbroad prompt assembly, weak separation between users, or memory that is too persistent for the task. In agentic systems, the problem can also arise when tool outputs are fed back into the model without filtering, when system instructions are mixed with user content, or when shared scratchpads are reused across conversations.

It is also common in retrieval-augmented and orchestration-heavy setups, where the model receives more context than the immediate task requires. That broad context increases the chance that unrelated secrets, policy text, or previously handled sensitive data will be retained long enough to influence later reasoning or output.

For a deeper treatment of memory isolation, cross-user leakage, and retention controls, see the AI Agent Memory Security Guide.

How organisations reduce exposure from context leakage

The practical defence is to treat context as a controlled security boundary, not as a convenient text buffer. Sensitive data should be excluded by default, session scope should be minimised, and model-visible context should be filtered so that only the minimum necessary information is passed forward.

Governance also matters because the same leakage pattern can affect prompts, memory stores, retrieval layers, and agent tool chains. Teams should know which data classes are forbidden from context, which messages may be persisted, and which outputs must be redacted or blocked before they reach logs, dashboards, or downstream automations. For broader LLM security patterns and controls, the LLM Security Guide is a useful reference.

Risk and Threat Considerations

Context window leakage is risky because it can expose secrets or internal instructions without requiring a classic intrusion. A malicious user, a compromised tool, or an overly permissive agent chain can convert ordinary prompt handling into a data-exposure path.

Failure mechanism: Sensitive data is inserted into active context, then reused, echoed, or retained in ways that expand its visibility across turns, tools, or users.

Impact: Credentials, personal data, policy content, and internal instructions may be disclosed, enabling privilege abuse, privacy violations, or follow-on compromise.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI06 — Memory & Context PoisoningContext leakage is a memory and context handling failure in agentic systems.
Recommendation — Isolate agent memory and block sensitive data from entering reusable context.
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageSensitive secrets in prompt context can be exposed through model outputs or reuse.
NHI-08 — Environment IsolationCross-user and cross-session leakage reflects weak isolation between contexts.
Recommendation — Prevent secrets from being placed into prompts or shared context. Separate sessions, tenants, and memory stores to stop context bleed.
NIST SP 800-53 Rev 5AC-6 — Least PrivilegeMinimising what enters context aligns with limiting unnecessary access to sensitive information.
AU-2 — Event LoggingPrompt and memory handling need auditability so leakage paths can be investigated.
SI-4 — System MonitoringLeakage patterns and abnormal prompt flows require monitoring for detection.
Recommendation — Restrict prompt and tool access to only the data needed for the task. Log prompt assembly and tool flows to support leakage investigation. Monitor model inputs and outputs for sensitive-data exposure patterns.

Practitioner Guidance

Why practitioners should care: Context leakage is often a design problem rather than a model problem, so teams need to manage what enters the prompt as carefully as they manage what leaves it. If a workflow relies on shared memory, long-lived context, or tool-fed prompts, the review should focus on data minimisation and boundary control.

What to watch for: Repeated inclusion of secrets, verbose system prompts, cross-user memory reuse, and tool outputs that are passed back into the model without scrubbing. These are the conditions that most often turn an otherwise normal interaction into an exposure event.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 23, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org