Skip to main content
A prompt injection vulnerability occurs when user-controlled text is incorporated into a prompt processed by an LLM in a way that the model cannot reliably distinguish attacker instructions from legitimate system instructions. The result can be safety bypass, information leakage, or unintended actions.

Taxonomy

Direct prompt injection

The user directly inputs malicious instructions into the model’s input field.

Indirect (third-party) injection

Attacker instructions are embedded in external content (web pages, documents, emails) that an agent processes.

Prompt leaking

Tricks the model into revealing its system prompt or confidential instructions.

Jailbreak

Bypasses safety training to produce content the model would normally refuse.

Direct injection techniques

Authority assertion / rule override

Why it works: the model processes all text sequentially without a cryptographic trust boundary between the system prompt and user input.

Context switching / storytelling

The model may comply because it frames the output as fictional rather than real instructions.

Dual persona (DAN and variants)

The model role-plays an unrestricted persona, effectively bypassing safety training for that output.

Encoding and obfuscation

Payload splitting

Breaking a disallowed request across multiple messages:

Translation trick

The model in “helpful translator” mode may output the translated forbidden content.

Indirect prompt injection

When an LLM agent can browse the web, read files, or use plugins, attackers can place injected prompts in content the agent will process.

Web page injection

Common hiding techniques in HTML/CSS

GitHub Copilot injection (picture tag smuggling)

Trail of Bits demonstrated that Copilot’s coding agent processes GitHub Issue text verbatim. An attacker can hide a prompt inside a <picture> tag (which GitHub renders as empty) and inject instructions to backdoor the generated code:
The injected instructions can direct Copilot to:
  1. Add a legitimate-looking dependency
  2. Modify the lock file to point to an attacker-controlled package
  3. Include a backdoor that triggers on a specific HTTP header

Prompt leaking

Successful prompt leaking exposes:
  • Proprietary business logic in the system prompt
  • API keys or credentials embedded in instructions
  • Information about connected tools and capabilities

Agentic browsing attack chain

For LLMs with web browsing capabilities:
1

Seed injection in indexed content

Place attacker instructions in a user-generated area of a trusted domain (e.g., blog comments). When the agent summarises the article, it reads the comments and may execute the injection.
2

Link exfiltration via trusted redirectors

Some platforms (e.g., Bing) use trusted URL redirectors. Pre-index attacker pages, one per alphabet character, then exfiltrate secrets by having the agent render sequences of redirector links.
3

Memory persistence

Injected instructions tell the agent to update its long-term memory with a persistent backdoor behaviour. The memory update persists across sessions.

Defences

Ensure system prompts are truly privileged and cannot be overridden by user input. Use model providers that enforce system/user prompt separation at the API level.
Strip or neutralise known injection patterns from any external content before it is added to the model context. Treat all external data as untrusted.
Check model outputs for unexpected patterns: encoded data, exfiltration URLs, code that was not requested, or disclosure of internal state.
Use a dedicated safety classifier (e.g., Llama Prompt Guard 2) to screen user inputs before they reach the main model. These models are trained to detect injection attempts.
Scope tool permissions tightly. An agent that only needs to read documents should not have write or network access.
Alert if the model’s output contains unexpected phrases, exfiltration-style URLs, or content inconsistent with the user’s query.

Tools