What Is Prompt Injection and Why AI Apps Are Vulnerable
What is prompt injection and why ai apps are vulnerable is the security question of the AI era. Prompt injection is what happens when a language model cannot reliably tell the difference between instructions it should follow and content it is simply supposed to process.
In February 2026, a widely reported incident involving the open-source AI coding agent OpenClaw showed the risk in practice. An attacker used prompt injection to install software on users’ systems, not with malware, but with text the model treated as valid instructions.
This explainer covers what prompt injection is, why there is no complete fix, the difference between direct and indirect attacks, and the defences that actually reduce the risk for teams building AI apps.
Key Takeaways
Prompt injection works because a language model treats system prompts, user input and retrieved documents as one stream of text, with no hard boundary between instructions and data.
Direct injection hides malicious instructions in user input; indirect injection hides them in documents, web pages or tool outputs the model later reads.
OWASP ranks prompt injection as LLM01, the top risk in its guidance for LLM applications, because it cannot be fully fixed, only mitigated.
The February 2026 OpenClaw incident showed an agent installing software after reading injected instructions, and EchoLeak showed a zero-click attack on Microsoft 365 Copilot.
The defences that work are architectural: least privilege for tools, human approval for irreversible actions, and output validation in code.
What Is Prompt Injection?
Prompt injection is an attack where untrusted text is written to override or hijack the instructions a language model was given, so the model follows the attacker’s agenda instead of the developer’s. The attacker is not breaking the model; they are using language to redirect it.
Large language models treat everything as text in a single context window. System prompts, user inputs and retrieved documents all become tokens in one stream, and the model does not inherently know which parts are trusted rules and which parts are untrusted data.
If malicious content includes new instructions, the model may treat them as legitimate.
A simple example makes the idea clear. Suppose an app asks a model to summarise an article, and the article contains a hidden line saying to ignore the summary task and reveal the system prompt instead.
In a vulnerable system, the model may prioritise the injected line over the original instruction, because both arrived as text.
Direct vs Indirect Prompt Injection
Direct Prompt Injection
Direct prompt injection is the obvious case: the attacker types malicious instructions into the same interface the user controls, asking the model to ignore its system prompt, reveal secrets or take a forbidden action. A classic example is the phrase ignore all previous instructions followed by a new command.
Direct injection is the easiest to test for, and the easiest to defend against with input screening and clear system prompts. But it is also the least dangerous in production, because it requires the attacker to already have access to the chat interface.
Indirect Prompt Injection
Indirect prompt injection is more dangerous, because the payload never comes from the user. It is planted in a document, a web page, a ticket comment, a calendar invite or an email that the AI agent later retrieves and treats as content to reason over.
The agent reads the poisoned source as part of its normal work.
Defences that only sanitise the chat input leave the retrieval and tool layers wide open, which is exactly where production agents spend most of their time. Any agent that browses the web, reads documents or digests tickets can be steered by text it was never meant to treat as commands.
Why AI Apps Are Vulnerable: The Missing Boundary
The vulnerability is structural, not a bug. Unlike classic injection flaws that can be closed with parameterised queries or escaping, prompt injection exploits the model’s core behaviour: following natural-language instructions. There is no complete string-escaping library for English, and no way to mark text as data only.
OWASP ranks prompt injection as LLM01, the top risk in its LLM application guidance, precisely because it is a foundational vulnerability rather than a misconfiguration. Any application that concatenates untrusted text into a prompt inherits it, and the risk grows as the application gains tools and autonomy.
The stakes rise sharply with agents. A chatbot that gives a wrong answer is embarrassing; an agent with tool access can trigger tool calls, exfiltrate memory, approve a transaction or rewrite its own plan mid-run. The more an AI system can do, the more a successful injection can do through it.
The 2026 OpenClaw Incident and EchoLeak
In February 2026, a widely reported incident involving the open-source AI coding agent OpenClaw changed how people think about prompt injection. An attacker exploited the way a coding agent processed instructions through a large language model and used a prompt injection technique to install software on users’ systems.
There was no complex malware, just text that the model treated as valid instructions, which led to unauthorised software being installed. The agent was not hacked in the traditional sense; it was influenced. It read malicious instructions, believed they were legitimate, and acted on them.
EchoLeak showed a different shape of the same problem. It was a zero-click prompt injection in Microsoft 365 Copilot, tracked as CVE-2025-32711, where hidden instructions in an email could steer the assistant without the user typing anything at all. Together, the two cases show that prompt injection is no longer theoretical.
How to Prevent Prompt Injection: Defences That Work
No control fully prevents prompt injection today, and OWASP says so plainly. The controls that work limit damage rather than blocking every attack.
The strongest is least privilege: give the application its own API tokens, handle sensitive functions in code rather than handing them to the model, and restrict the model’s access to the minimum it needs.
Human approval for high-risk actions is the second pillar. Require a person to approve consequential tool actions before they execute, and base the decision on the proposed operation, target and arguments. A hijacked model cannot delete records it cannot reach, and cannot approve a transaction a human has not signed off.
Deterministic validation of output is the third. Define the expected output format and check it with ordinary code, not with a second language model. Segregate untrusted content from instructions where the runtime allows it, and test your defences against adaptive attackers, since filters that catch known phrases miss reworded ones.
Test Like an Attacker, Not Like a User
Most teams test their defences with the attacks they already know, which is why filters pass and real attackers still get through. A better routine is to hand the app to someone who tries to break it: reworded instructions, instructions hidden in a document, and a tool call the model should refuse.
Run that test every time the app gains a new tool, a new data source or a new model version, and keep a log of what got through. The log matters because injection techniques evolve quickly, and a defence that worked last quarter may already be stale.
Prompt Injection Attack Types Compared
This table summarises the main attack shapes, how they work, and how much damage each can do in a production AI app.
Attack Type
How It Works
Example Carrier
Risk Level
Direct injection
Malicious instructions typed by the user
Chat input
Medium
Indirect injection
Instructions hidden in content the model reads
Web page, document, email
High
Stored injection
Poisoned data saved in memory or a corpus
RAG documents, agent memory
High
Encoding and obfuscation
Instructions hidden with Base64 or other languages
Encoded text, multilingual input
Medium
Tool-chain abuse
Malicious tool or package uses the agent’s access
MCP server, plugin
Critical
Agentic injection
Injection triggers tool calls and side effects
Tickets, tool outputs
Critical
Prompt Injection Defence Checklist
Use this checklist when reviewing an AI app, and revisit it whenever the app gains a new tool or data source.
Map every place text enters the model: user input, files, pages, tool results and other agents.
List every action the model can trigger and remove any it does not need.
Give the application, not the model, the credentials, and scope them tightly.
Require human approval for anything destructive, financial or external-facing.
Validate output with code against a strict schema before using it downstream.
Mark retrieved and external text as untrusted and keep it apart from instructions.
Red-team the app regularly with adaptive attackers, not just known attack strings.
Frequently Asked Questions
What is prompt injection in simple terms?
Prompt injection is when untrusted text tricks a language model into following the attacker’s instructions instead of the developer’s. The model treats system prompts, user input and retrieved documents as one stream of text, so a hidden instruction in any of them can redirect what the model does.
Why is there no complete fix for prompt injection?
There is no complete fix because the vulnerability is structural: a language model follows natural-language instructions, and there is no way to mark text as data only. Unlike SQL injection, which can be closed with parameterised queries, there is no escaping library for English.
OWASP and the UK’s NCSC both say it may never be fully mitigated in current architectures.
What is the difference between direct and indirect prompt injection?
Direct injection hides malicious instructions in the user’s own input, such as typing ignore all previous instructions into a chat. Indirect injection hides instructions in content the model later reads, such as a web page, document, email or ticket. Indirect injection is more dangerous because the payload arrives through the app’s normal data flow.
What happened in the OpenClaw incident?
In February 2026, an attacker used prompt injection against the open-source AI coding agent OpenClaw to install software on users’ systems. There was no complex malware, just text the model treated as valid instructions. The incident showed that prompt injection can cause real harm once AI agents gain tool access.
What is EchoLeak?
EchoLeak was a zero-click prompt injection in Microsoft 365 Copilot, tracked as CVE-2025-32711. Hidden instructions in an email could steer the assistant without the user typing anything at all. It is one of the best-known examples of indirect injection in a production product.
How do I protect my AI app from prompt injection?
Use architectural controls rather than polite instructions. Give the model least-privilege tool access, require human approval for irreversible actions, validate outputs with code against a strict schema, and keep untrusted content in a separate, labelled channel. Test your defences with adversarial testing, since filters miss reworded attacks.
Is prompt injection the same as jailbreaking?
They are related but not identical. Jailbreaking tries to bypass a model’s safety guardrails to get it to produce forbidden content. Prompt injection tries to hijack the model’s instructions so it follows the attacker’s agenda, which may include leaking data or calling tools. Both exploit the model’s interpretive flexibility, but they have different goals.
Conclusion
Prompt injection is the defining security problem of the AI era because it cannot be patched away. A language model that follows instructions will always be vulnerable to instructions it should not follow, and the only honest response is to design around that fact.
The teams that handle it well treat the model as an untrusted reasoner inside a policy envelope, not as the policy itself. Limit what the model can reach, require a human for anything irreversible, and validate everything it produces. That is the defence that works today.
Ayesha is the co-founder of occcy and the editor behind its entertainment and lifestyle coverage. She believes good writing should feel like a conversation with a smart friend, clear, warm, and genuinely helpful.