LLM Context is the set of text a large language model receives for a single request, including system instructions, user prompts, conversation history, retrieved documents and tool outputs. The model cannot reliably separate trusted instructions from data, so injected content can steer it. Limit what sensitive data enters context and enforce access controls before retrieval.
What LLM Context Includes and Why It Matters
LLM context is not just the user’s latest prompt. It is the whole instruction and data bundle that shapes the model’s next response, which means a single request can inherit system rules, chat history, retrieved files, and tool output all at once. That breadth is useful, but it also makes context a security boundary, because the model may treat untrusted text as if it were instruction.
Practically, the key issue is not whether the content is “in the prompt”, but whether it should have been there at all. If sensitive material, hidden instructions, or unreviewed retrieval results enter context, they can influence the model even when they were meant to be passive data.
Context Windows, Instruction Conflicts, and Prompt Injection
LLMs do not reliably separate trusted instructions from surrounding text. When untrusted content is placed in the same context window as system guidance, the model can follow injected instructions, ignore earlier constraints, or blend data and policy in unsafe ways. That is why prompt injection is fundamentally a context problem, not only a content moderation problem.
This is especially important in systems that assemble context from multiple sources, such as retrieved documents, agent memory, or tool responses. A malicious or simply careless document can introduce instructions that compete with the intended task, and the model may act on them because it has no native trust model for “this is data, not direction.”
For reader navigation on this subject, see Permission-Aware RAG Guide for how retrieval must respect access boundaries before content ever reaches the model. The same risk appears in EchoLeak (Microsoft 365 Copilot) 2025, which shows how crafted content in context can drive zero-click leakage.
What Should and Should Not Enter Context
Because context is consumed as a single working set, exposure control matters before retrieval, not after generation. Sensitive records, secrets, and broad historical conversation data all increase the blast radius if the model is later steered, prompted to reveal prior content, or asked to summarise material it should never have seen.
Good context design therefore treats inclusion as a decision, not a default. Ask whether a document, message, or tool output is required for the request, whether it should be visible to that user, and whether it changes the answer enough to justify the exposure. In many systems, the safest context is the smallest one that still lets the model complete the task accurately.
That principle aligns with access-controlled retrieval, where the model only sees what the requester is already allowed to see. It also reduces the chance that system instructions are diluted by excess history, copied secrets, or unrelated operational noise.
Detection, Review, and Recovery After Context Exposure
When context handling fails, the damage may not be obvious immediately. A model can answer incorrectly, reveal hidden material, or leak data indirectly through summaries, citations, or tool actions. Review therefore needs to cover both the prompt path and the data path: what was retrieved, what was inserted into context, and whether the output reflects injected or unexpected instructions.
Post-incident analysis should look for unusual retrievals, repeated attempts to override instructions, and outputs that mirror suspicious phrasing from external text. If secrets, credentials, or private documents were present in context, assume they may have been exposed even if the model did not emit them verbatim, because the request itself may have altered later behaviour or persisted unsafe state in logs and traces.
For a concrete example of context leakage in a real deployment, McKinsey AI platform breach shows how chat data and sensitive content can be exposed when platform boundaries are weak.
Risk and Threat Considerations
LLM context creates a direct exposure path because the model will often process everything it sees as candidate input, including malicious instructions hidden inside apparently harmless text. That makes context poisoning, prompt injection, and over-broad retrieval especially dangerous in enterprise assistants and agentic workflows.
Failure mechanism: An attacker places crafted text into a retrieved document, email, ticket, or tool response, then relies on the model to treat that content as instruction or authoritative context.
Impact: The model may reveal sensitive data, ignore policy, call tools incorrectly, or propagate compromised instructions into later actions and outputs.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST SP 800-53 Rev 5 and OWASP ASVS set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | AC-6 — Least Privilege | Limits which retrieved data can enter model context. |
| IA-5 — Authenticator Management | Protects secrets and tokens that may otherwise enter context. | |
| SI-10 — Information Input Validation | Addresses untrusted text entering systems and influencing processing. | |
| Recommendation — Apply AC-6 to restrict retrieval and context assembly to the minimum necessary data. Apply IA-5 to control, rotate, and protect credentials before they can leak into prompts or logs. Apply SI-10 to validate and filter untrusted input before it can influence model execution. | ||
| OWASP ASVS | V4 — API and Web Service | Context often arrives via APIs and service responses that need authorization and integrity checks. |
| V16 — Security Logging and Error Handling | Supports review of retrieval, prompt, and output events after context exposure. | |
| Recommendation — Apply V4 controls to ensure only authorised service data reaches the model context. Apply V16 to log context assembly and investigation-relevant model interactions. | ||
Practitioner Guidance
Why practitioners should care: Context is the model’s working memory, so mistakes here become model behaviour problems, not just data handling problems. The most effective control is to decide upstream what is eligible to enter context, then enforce that decision consistently across retrieval, memory, and tool output.
Common misunderstanding: Many teams focus on prompt wording alone, but the real risk often comes from the surrounding data supply chain. If retrieval, history, or tool responses are not filtered and permissioned, the model can be steered even when the user prompt looks benign.
Practitioner takeaway: Treat context as a controlled intake surface, not a dumping ground for everything the system can access.
Related resources from NHI Mgmt Group
- Guide: Brave Search and Ask Brave Explained
- Why do extra prompts or context sometimes make LLM outputs worse?
- What breaks when LLM gateway logging does not capture identity context?
- What breaks when secrets are passed through an LLM context?
- How can organisations reduce risk when using long-context LLM APIs?
Deepen Your Knowledge
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.
Reviewed and updated by the NHIMG editorial team on November 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org