Skip to main content
USA-Based Digital Agency

AI security guide · Updated

What is prompt injection?

Prompt injection is an attack in which text reaches an AI model and changes what it does in ways its builder did not intend. It can come from the user directly or hide in a web page, email or file the model reads. It is first on OWASP’s list of LLM risks, and no one has a complete fix, so the goal is to limit what an injected model can do.

By George Shvaya, founder of Webvello · Published

Key takeaways

  • OWASP ranks prompt injection first (LLM01:2025) in its Top 10 for LLM Applications and says it is unclear whether fool-proof prevention exists.
  • Indirect prompt injection hides instructions in content the model reads, such as web pages, emails and files, so the person using the app never sees them.
  • NIST explains the root cause: generative AI models combine the data and instruction channels, so data can steer the system.
  • The UK NCSC warns that prompt injection may never be fully mitigated the way SQL injection can be.
  • The practical defense is limiting impact: least-privilege tools, human approval for consequential actions, and treating model output as untrusted.

How does prompt injection work?

A language model reads instructions and data as the same stream of text, so data can act like instructions.

OWASP defines it this way: “A Prompt Injection Vulnerability occurs when user prompts alter the LLM’s behavior or output in unintended ways” (OWASP LLM01:2025).

NIST’s taxonomy of adversarial machine learning gives the reason it is hard to stop: “Because GenAI models combine the data and instruction channels, attackers can leverage the data channel to affect system operations” (NIST AI 100-2 E2025, March 2025). A database separates a query from its parameters. A language model has no such separation.

What is the difference between direct and indirect prompt injection?

The difference is who supplies the text: the user, or content the model reads on the user’s behalf.
Direct and indirect prompt injection, with OWASP’s definitions (OWASP LLM01:2025)
TypeOWASP definitionWhere it comes fromMain risk
Direct“Direct prompt injections occur when a user’s prompt input directly alters the behavior of the model”The chat box or API inputBypassing the app’s rules, leaking its system prompt
Indirect“Indirect prompt injections occur when an LLM accepts input from external sources, such as websites or files.”Web pages, emails, documents, tool results, code repositoriesAn agent acting for the attacker with the user’s access

Why indirect injection matters more for agents

A chatbot that only talks can be tricked into saying the wrong thing. An agent that can send email, edit files, open pull requests or call APIs can be tricked into doing the wrong thing with the user’s permissions. The more tools an agent has, the more an injected instruction can reach.

Can prompt injection be fully prevented?

Not today, according to OWASP, the UK’s cyber agency and the model vendors themselves.
What security bodies and AI vendors say about preventing prompt injection (checked November 16, 2026)
SourceWhat they sayDate
OWASP“it is unclear if there are fool-proof methods of prevention for prompt injection”2025 list (Nov 2024)
UK NCSC“prompt injection attacks may never be totally mitigated in the way that SQL injection attacks can be”December 8, 2025
Anthropic“prompt injection is far from a solved problem”November 24, 2025
Microsoft MSRCUses “a defense-in-depth approach spanning both probabilistic and deterministic mitigations”July 29, 2025

The NCSC suggests treating the model as an “inherently confusable deputy”: assume it can be talked into misusing whatever access it has, and design so that misuse is contained.

Building an AI feature or agent?

Tell us what it reads and what it can do. We will tell you where an injected instruction could do damage.

How do you limit the damage from prompt injection?

Design for the case where injection succeeds: small permissions, checkpoints, and no blind trust in output.
  • Give each agent only the tools and data scopes its job needs, and separate read-only tools from tools that change things.
  • Require a person to approve consequential actions: sending messages, moving money, deleting data, publishing or merging code.
  • Treat model output as untrusted input: validate it before it reaches a database, shell, browser or another system (OWASP LLM05, Improper Output Handling).
  • Keep secrets out of prompts and context. A model cannot leak a key it never saw.
  • Mark and separate untrusted content (retrieved pages, emails, tool results) from instructions. Microsoft calls its approach Spotlighting.
  • Log tool calls and review them, so an injected action can be noticed and traced.
  • Test with injected content before launch, using the documents, pages and tools the app will really see.

Agents connected through the Model Context Protocol add their own risks, covered in MCP security risks. For the full list of LLM risks, see the OWASP Top 10 for LLM applications.

Pages that go deeper on the pieces this one touches.

Common questions

Straight answers to what owners ask us first.

Is prompt injection the same as jailbreaking?

They overlap. OWASP treats jailbreaking as a form of prompt injection in which the input makes the model ignore its safety rules entirely. Prompt injection is the broader term and includes instructions hidden in content the model reads.

Does a better system prompt stop prompt injection?

It helps a little and should not be relied on. The system prompt is text in the same channel the attacker writes into. Limits enforced outside the model, such as tool permissions and approval steps, hold up better.

Are AI coding agents affected?

Yes. A coding agent reads issues, pull requests, documentation and dependency files, any of which can carry injected instructions. Vendor docs for Claude Code, Codex and GitHub Copilot’s agent all describe prompt injection as a risk and limit network or command access by default.

Can you test our AI app for prompt injection?

Yes. Our AI application security review includes testing your app with injected content in the places it reads from, and reviewing what each tool can reach if an injection succeeds.

Find out what an injection could reach

We review AI apps and agents for prompt injection, tool permissions and data exposure.