What is prompt injection?

Prompt injection is a flaw where input text changes what a language model does. OWASP lists it as LLM01:2025 in its risks for large language model applications.

Updated

Direct and indirect injection

Direct prompt injection comes from the user's own input. Indirect prompt injection comes from outside content. OWASP says: "Indirect prompt injections occur when an LLM accepts input from external sources, such as websites or files."

An agent that reads a web page or a file reads that content as input. The page can hold text that the agent follows as instructions.

Why a sandbox is a second line

OWASP advises that you "Restrict the model's access privileges to the minimum necessary for its intended operations." Code that a coding agent writes after it reads injected text is untrusted code. A sandbox limits what that code can reach.

A sandbox limits the damage. It does not stop the injection. The model can still follow the injected text.

What to check

  • Whether the sandbox can reach the internet, and whether outbound access can be limited to a list of hosts. See egress allowlist.
  • Which secrets and files the sandbox can see.
  • Whether the sandbox is destroyed after one task, or reused for the next.

Related terms

All glossary terms

Related