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

Context Window Poisoning

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

A technique that hides malicious instructions inside content an AI assistant automatically reads, such as comments, documentation, logs, or metadata. The model treats the text as part of the task context, which can steer code generation or reasoning without any direct prompt injection from the user.

What Context Window Poisoning Is

Context window poisoning is not a separate exploit primitive so much as a way of smuggling instruction-like text into the material an AI system reads as context. The danger is that the model may treat hidden or embedded content as legitimate task input, which can bend its output even when the user never typed the malicious instruction directly.

It is especially relevant in environments where the model ingests documents, code comments, logs, tickets, wiki pages, metadata, or retrieved knowledge. In those settings, the attacker is targeting the model’s interpretation layer, not necessarily the user prompt itself.

Why It Works in AI Workflows

The technique exploits a basic property of large language model systems, the model is optimized to continue, transform, and reconcile whatever appears in the active context window. If untrusted content is mixed with trusted instructions, the model may struggle to separate provenance, intent, and priority unless the application explicitly enforces those boundaries.

That makes the issue broader than classic prompt injection. Context poisoning can arrive through files, retrieval pipelines, memory stores, or copied artifacts, and it becomes more dangerous when the system automatically reuses that content across turns or tasks. AI Agent Memory Poisoning Guide is a useful companion for understanding how poisoned context can persist and reappear across sessions.

Where the Attack Surface Appears

The attack surface is any place where untrusted text can be elevated into working context. Common examples include repository files, build artifacts, support transcripts, long-lived memory, scraped web pages, inline comments, and metadata fields that downstream tools faithfully preserve. Once that content is ingested, the model may act on it as if it were part of the task.

That is why retrieval design matters as much as prompt hygiene. OWASP Agentic Top 10 ASI06 Guide explains the memory and context poisoning failure mode in more depth, while LLM Security Guide places it in the wider set of LLM abuse patterns, including context overflow, data leakage, and output handling failures.

How Defenders Reduce the Blast Radius

The practical defence is to treat context as an untrusted supply chain. Systems should separate trusted instructions from retrieved or user-supplied content, label provenance clearly, and avoid giving arbitrary text equal standing with system or developer instructions. Where memory is involved, write permissions, retention, rollback, and review are just as important as model choice.

Strong segmentation helps too. OWASP Top 10 for Agentic Applications Guide is useful here because it frames memory poisoning alongside adjacent agent risks such as tool misuse and identity abuse, which often appear together once an agent can read, store, and act on contaminated context. For the broader threat framing, the MITRE ATLAS adversarial AI threat matrix captures context poisoning as part of a larger adversarial AI technique set, which helps teams map detection and red-team coverage.

Risk and Threat Considerations

Context window poisoning matters because it can quietly redirect model behaviour without changing the user’s visible prompt. That makes it attractive for stealthy manipulation, data exfiltration, unsafe code generation, and policy bypass, especially where the system automatically trusts retrieved or persisted content.

Failure mechanism: Malicious text is absorbed into the model’s working context, then competes with or overrides genuine instructions, retrieved facts, or policy constraints during generation.

Impact: The model may produce unsafe outputs, leak sensitive information, misuse tools, or repeat attacker-supplied instructions as if they were trustworthy context.

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 MITRE ATLAS address the attack and risk surface, while NIST AI RMF and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI06 — Memory & Context PoisoningContext poisoning is the named OWASP agentic AI risk.
Recommendation — Segment trusted instructions from retrieved context and validate memory writes before reuse.
NIST AI RMFGV — GovernAI risk governance should control provenance and reuse of context inputs.
Recommendation — Define governance for trusted context sources, memory retention, and review responsibilities.
MITRE ATLAST1588 — Acquire CapabilitiesATLAS models adversarial AI techniques that include context manipulation and poisoning.
Recommendation — Map poisoned-context techniques into your AI threat model and test them in red-team scenarios.
CIS Controls v8CIS-14 — Security Awareness and Skills TrainingHuman review of contaminated content and handling rules supports safer AI workflows.
Recommendation — Train developers and operators to identify untrusted inputs that can enter model context.

Practitioner Guidance

What to watch for: The main operational clue is not just strange model output, but suspicious content entering the pipeline in places the application later treats as authoritative. Review ingestion paths, retrieval sources, memory writes, and any workflow that copies text from external systems into model context.

Practitioner takeaway: Treat context provenance as a control surface, not a formatting detail, because the security boundary is often the path by which text becomes trusted context, not the prompt field alone.

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 30, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org