A man-in-the-prompt attack is a prompt injection attack that intercepts or alters the instructions an AI system receives, so the model follows attacker-controlled guidance instead of the user's intent. It can occur through retrieved content, tool output, hidden text or malicious context that changes the agent's behaviour and access decisions.
What a man-in-the-prompt attack does
A man-in-the-prompt attack sits inside the instruction path of an AI system. Instead of merely supplying malicious content, the attacker changes what the model treats as authoritative guidance, so the system may follow the injected instructions over the user’s original intent. That makes it an integrity problem for both prompting and downstream agent behaviour.
The core danger is that the model can appear to be responding normally while its priorities, constraints, or action choices have been silently rewritten. That can happen through retrieved documents, tool output, hidden text, or other context that the system ingests during runtime.
Where the attack enters the prompt chain
Man-in-the-prompt attacks usually exploit a trust boundary inside the AI application pipeline. The system may assume retrieved text, file contents, browser-rendered pages, or tool responses are safe enough to influence reasoning, even when those sources are not trustworthy.
This matters because the attack does not need to defeat the model directly. It only needs to place instructions where the model will read them, then rely on the model’s instruction-following behaviour to reinterpret the conversation or task.
For a broader defensive view of prompt injection patterns, Prompt Injection Guide covers direct, indirect, multimodal and tool-poisoning variants.
Why it is dangerous in AI agents
The attack becomes more serious when the AI system can take actions, call tools, or make access decisions. A poisoned prompt can redirect the agent toward unsafe tool use, disclosure, or policy bypass while still looking like a legitimate task completion path.
That is why the same pattern often overlaps with agent goal hijack: the attacker is not just changing the text the model sees, but steering the objective the system pursues. In practice, the model may preserve fluency while losing alignment with the user’s real request.
When an agent is in scope, the relevant defensive lens is often goal integrity and action gating, which is the focus of OWASP Agentic Top 10 ASI01 Guide.
Attackers can also abuse hidden or delayed instructions embedded in data that the system later reuses. That makes the issue especially hard to spot because the malicious influence may be separated in time from the eventual harmful action.
How organisations reduce exposure
Exposure checks start with identifying every place the system ingests untrusted text before it reasons or acts. That includes retrieval layers, browser content, uploaded files, tool outputs, and any feature that mixes user input with external context.
Defences should preserve a clear hierarchy between system instructions, user intent, and untrusted retrieved material. The practical aim is not to trust all context equally, but to make the model less willing to obey instructions that arrive from lower-trust sources.
For organisations that already use search, retrieval, or tool-augmented workflows, the key question is whether the AI application can distinguish content from instruction. That is where the Man-in-the-Middle Attacks Guide is useful as an analogy for interception and trust-boundary thinking, and the MITRE ATT&CK T1557 Adversary-in-the-Middle page is a useful detection reference for relay and poisoning patterns.
Detection and recovery after suspected prompt compromise
Detection is often indirect because the model may not crash or error. Instead, you look for unusual instruction adherence, tool calls that do not match the user request, data exfiltration behaviour, or responses that suddenly adopt language from untrusted content.
After suspected exploitation, review the prompt chain, retrieved sources, tool outputs, and agent actions around the event window. The goal is to determine whether the system merely consumed bad content or actually executed attacker-shaped instructions.
On the recovery side, organisations should assume that any compromised session or task context may need to be rebuilt from a clean state. For AI systems that call external services or handle sensitive material, the compromise review should extend to any credentials, tokens, sessions, or service permissions that may have been used while the prompt was poisoned.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK, OWASP Agentic AI Top 10 and MITRE ATLAS define the specific risk controls and attack patterns relevant to this term.
| Framework | Control / Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | T1027 — Obfuscated Files or Information | Prompt payloads may hide instructions in text or documents to evade review. |
| T1056 — Input Capture | The attack abuses text captured by the system as an input path for adversarial instructions. | |
| Recommendation — Inspect retrieved content for hidden or obfuscated instructions before the model consumes it. Treat every external prompt source as untrusted input and validate it before use. | ||
| OWASP Agentic AI Top 10 | ASI01 — Agent Goal Hijack | The attack redirects an agent's objective away from the user's intent. |
| ASI02 — Tool Misuse | Prompt injection can coerce unsafe tool calls or improper tool outputs. | |
| Recommendation — Lock agent goals and verify that runtime instructions cannot override task intent. Gate tool execution so injected instructions cannot trigger unauthorised actions. | ||
| MITRE ATLAS | AML.T0051 — Prompt Injection | This is the core adversarial AI pattern of injecting instructions into model context. |
| Recommendation — Model retrieval and tool pipelines to detect and block injected instructions in context. | ||
Related resources from NHI Mgmt Group
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 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org