# LLM01 - Prompt Injection

> Adversaries manipulate model behavior by embedding malicious instructions in inputs.

- **Category**: Owasp Llm
- **Subcategory**: top10_2025
- **Canonical URL**: https://designpattern.fyi/owasp_llm/llm01_prompt_injection/

---

## Description
'**Intent**: Prevent adversaries from manipulating LLM behavior through crafted inputs that bypass safety constraints.

**Context**: LLMs process natural language inputs that can contain hidden instructions. Attackers embed malicious prompts to override system instructions, extract data, or trigger unauthorized actions.

**Solution**: Implement input validation and sanitization. Use prompt firewalls. Separate system prompts from user inputs. Apply output filtering. Monitor for anomalous prompt patterns. Use guardrail frameworks.'



## Use Cases
Use when building any LLM-powered application that processes user inputs or external data.





## Trade-offs


### Advantages

- Prevents unauthorized behavior changes

- Protects system prompt integrity

- Blocks data exfiltration attempts

- Maintains model safety constraints




### Considerations & Drawbacks

- No perfect defense exists yet

- May block legitimate edge-case inputs

- Requires continuous updating







---
**Reference**: [Original Source](https://genai.owasp.org)

