Glossary

Prompt Injection

Prompt injection is a security attack in which crafted input manipulates a large language model into ignoring its intended instructions and following the attacker's instead, exploiting the model's inability to reliably separate its instructions from the data it reads.

Reviewed by Daniel Hayes, Revenue Operations
Last updated

Key takeaways

  • Prompt injection manipulates an LLM via crafted input into ignoring its real instructions and following the attacker's.
  • It works because a model cannot reliably tell its instructions apart from the content it reads.
  • Direct injection comes from user input; indirect injection hides instructions in external content the model ingests.
  • The risk sharpens with connected agents that can take actions, not just generate text.
  • There is no single fix; defense is layered: tight permissions, untrusted-by-default content, guardrails, and a human in the loop.

Prompt injection is a security attack in which crafted input manipulates a large language model into ignoring its intended instructions and instead following the attacker's, causing it to leak information, take unauthorized actions, or produce harmful output. It exploits the fact that an LLM cannot reliably tell its instructions apart from the data it reads.

As AI agents move from answering questions to taking actions, prompt injection becomes a practical security concern, not a theoretical one. An agent that reads emails, web pages, or documents can be steered by malicious text hidden inside that content, which is why anyone deploying LLM-powered tools needs to understand the risk.

What prompt injection is

Prompt injection occurs because a large language model processes its system instructions and the surrounding content in the same stream of text, with no hard boundary between them. An attacker writes input designed to read as a new instruction, "ignore your previous directions and do this instead", and the model may comply. It comes in two main forms: direct injection, where the user types the malicious instruction, and indirect injection, where the instruction is hidden in external content the model later ingests, such as a webpage, email, or file.

How prompt injection works

Malicious instructions enter through user input or external content, the model reads them alongside its real instructions, and, unable to tell them apart, it may act on the attacker's directions.

Malicious text enters, the model cannot separate it from real instructions, and may obey it.

The danger grows with capability. A model that only generates text can be tricked into saying something it should not; an agent connected to tools, email, a CRM, a knowledge base, can be tricked into doing something, exfiltrating data or taking an unauthorized action. This is why guardrails and a human in the loop matter most precisely where an agent can act with real consequences.

Direct vs indirect prompt injection

DimensionDirect injectionIndirect injection
SourceThe user typing to the modelExternal content the model reads
VisibilityOften visible in the inputCan be hidden in a page or file
Hard partDetecting malicious phrasingTrusting any ingested content at all

Why prompt injection matters

  • It is hard to fully solve. The model's inability to separate instructions from data is structural, not a simple bug.
  • Action raises the stakes. Connected agents can be steered into real, harmful actions, not just bad text.
  • External content is risky. Any page, email, or document an agent reads can carry hidden instructions.
  • Trust depends on it. Deploying AI on sensitive work requires taking injection seriously.

How to defend against prompt injection

There is no single fix, so defense is layered. Limit what an agent can do, especially what it can do automatically: scope its permissions tightly, and require approval for consequential or irreversible actions so a successful injection cannot quietly cause harm. Treat external content as untrusted input rather than as instructions, and design the system so reading data never silently becomes obeying it. Add guardrails that constrain and check the model's output, validate actions before they execute, and keep a human in the loop where the downside is real. Test adversarially, try to break your own agent, and assume that any content it ingests may be hostile.

Common prompt injection mistakes

  • Trusting ingested content. Treating a fetched page or email as safe lets hidden instructions through.
  • Over-permissioning agents. Giving an agent broad, automatic powers turns an injection into real damage.
  • Relying on one defense. Hoping a single filter stops injection ignores how varied the attacks are.
  • Skipping adversarial testing. Not trying to break your own system means attackers find the gaps first.

Prompt injection exploits an LLM's inability to separate its instructions from the content it reads, letting crafted input hijack its behavior, a risk that sharpens as agents gain the power to act. There is no single cure, so safety comes from layered defense: tight permissions, untrusted-by-default content, guardrails, and a human in the loop wherever an agent can do something that matters.

Frequently asked questions

What is prompt injection?

Prompt injection is a security attack in which crafted input manipulates a large language model into ignoring its intended instructions and instead following the attacker's, causing it to leak information, take unauthorized actions, or produce harmful output. It exploits the fact that an LLM processes its system instructions and the surrounding content in the same stream of text, with no hard boundary, so input written to read as a new instruction may be obeyed.

What is the difference between direct and indirect prompt injection?

Direct injection is when the user types the malicious instruction straight to the model, so it often appears in the visible input. Indirect injection hides the instruction in external content the model later ingests, such as a webpage, email, or file, where it can be concealed. Indirect injection is especially tricky because it means any content an agent reads, not just what a user types, can carry hostile instructions.

Why is prompt injection dangerous for AI agents?

A model that only generates text can be tricked into saying something it should not, but an agent connected to tools, email, a CRM, or a knowledge base can be tricked into doing something, such as exfiltrating data or taking an unauthorized action. As agents move from answering questions to acting with real consequences, prompt injection becomes a practical security concern rather than a theoretical one, which is why permissions and oversight matter most where an agent can act.

How do you defend against prompt injection?

There is no single fix, so defense is layered. Scope an agent's permissions tightly and require approval for consequential or irreversible actions, treat external content as untrusted input rather than as instructions, and design the system so reading data never silently becomes obeying it. Add guardrails that constrain and check output, validate actions before they execute, keep a human in the loop where the downside is real, and test adversarially by trying to break your own agent.

What are common prompt injection mistakes?

Common mistakes include trusting ingested content by treating a fetched page or email as safe, which lets hidden instructions through; over-permissioning agents so an injection turns into real damage; relying on a single filter as if one defense could stop varied attacks; and skipping adversarial testing, which means attackers find the gaps before you do. Assuming any content an agent reads may be hostile is a safer default.

AI Agent Handoff

An AI agent handoff is the moment an AI agent transfers a conversation or task to a human (or another agent), passing along full context so the next party can pick up seamlessly, the escape hatch that keeps automation helpful rather than a trap.

AI Agent SOP

An AI agent SOP (standard operating procedure) is the documented set of rules, steps, and boundaries that govern how an AI agent should handle a given situation, the playbook defining what it does, in what order, and when to escalate, translating human SOPs into instructions an agent executes consistently.

AI Chat Agent

An AI chat agent is an AI system that converses with people through text chat, on a website, in an app, or in messaging, understanding what they type and responding helpfully, and increasingly taking actions, rather than following a rigid scripted menu.

AI Concierge

An AI concierge is an AI assistant that provides personalized, white-glove help to customers or prospects, guiding them, answering questions, and handling requests in a high-touch, attentive way, available instantly and at scale.

AI Copilot

An AI copilot is an AI assistant that works alongside a human, suggesting, drafting, and surfacing information in real time while the person stays in control and makes the final call. The human is the pilot; the AI assists, never acting alone.

AI Gateway

An AI gateway is a management layer that sits between an application and the AI models it uses, routing requests, enforcing policy, controlling cost, and adding security and observability, much as an API gateway does for APIs.