# Prompt Injection

Prompt injection is an attack in which untrusted input influences a model to disregard intended instructions, expose information, or misuse connected capabilities.

- Type: term
- Domain: Engineering & architecture
- Level: Intermediate
- Last reviewed: 2026-09-26
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/prompt-injection/>)

## What it means

Prompt injection exploits the fact that language-model applications process instructions and data in a shared representation without a dependable security boundary between them. A direct injection comes from a user; an indirect injection arrives through content the system reads, such as a webpage, email, document, image, or tool result. Jailbreaking is related but usually focuses on bypassing model restrictions rather than compromising an application's trusted workflow.

## Why it matters

When a model can retrieve private data or call tools, manipulated output can become data exposure, unauthorized action, or corrupted decisions. Prompt wording alone cannot eliminate the weakness, so product scope and deterministic controls must limit the possible impact.

## When to use it

Threat-model prompt injection for any system that combines untrusted content with privileged instructions, private context, retrieval, or tools. Risk rises with autonomy and permission. A read-only drafting aid needs different controls from an agent that sends messages or changes records.

## How it works

1. Map every source of untrusted content, privilege boundary, sensitive asset, tool, and downstream consumer.
2. Minimize accessible data and actions using user-scoped authorization and least-privilege tools.
3. Separate and label instructions and content while assuming the model may still confuse them.
4. Validate outputs and tool calls deterministically; require confirmation for consequential actions.
5. Test direct, indirect, encoded, multimodal, and multi-step attacks, then monitor and contain abnormal behavior.

## A practical example

An email assistant reads a message containing hidden instructions to forward confidential mail. The system prevents harm because the reading context has no send permission, recipients and attachments are server-validated, and any draft-to-send transition requires the user to review a clear action summary.

## Where it breaks

Filters and prompt delimiters can reduce some attacks but are bypassable and may block legitimate content. Detection evolves as models and attackers change. The safest design may be to withhold a capability when residual risk exceeds the value of automation.

## Common mistakes

- Treating prompt injection as solved by telling the model to ignore malicious instructions.
- Giving a model broad credentials and relying on a system prompt to enforce permissions.
- Testing only obvious direct phrases while ignoring indirect and multimodal content.
- Logging attacks without designing containment, revocation, and incident response.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/prompt-injection/#visualization-prompt-injection>)

## Sources

1. [LLM01:2025 Prompt Injection](<https://genai.owasp.org/llmrisk/llm01-prompt-injection/>) — OWASP GenAI Security Project · Security guidance
2. [Prompt injection is not SQL injection \(it may be worse\)](<https://www.ncsc.gov.uk/blog-post/prompt-injection-is-not-sql-injection>) — UK National Cyber Security Centre · Government security guidance

## Related topics

- [System Prompt](<https://wiki.soroush.uk/topic/system-prompt/>)
- [Tool Calling](<https://wiki.soroush.uk/topic/tool-calling/>)
- [Threat Modeling](<https://wiki.soroush.uk/topic/threat-modeling/>)
