Safeguard
AI Security•

What types of prompt injection attacks exist?

Prompt injection spans direct and indirect attacks, encoding tricks, repeated and multi-turn attempts, markdown leaks, RAG poisoning and agent abuse.

Safeguard Security Team
4 min read

Prompt injection comes in two basic forms: direct, where a user's own input changes the model's behavior, and indirect, where instructions hidden in content the model reads do it. Variants add obfuscation, repeated attempts, multi-turn setups, hidden markdown, poisoned retrieval and manipulation of agent tools.

Definitions

OWASP defines a prompt injection vulnerability as user prompts altering the model's behavior or output in unintended ways. The input does not have to be readable by a person, as long as the model parses it.

Direct injection. The attacker is the user, or the user's input carries the instruction.

Indirect injection. The model ingests external content such as a web page, file, email or code comment that contains instructions.

Types in a table

TypeHow it worksWhere it shows up
DirectCrafted input overrides instructionsChat boxes, forms
IndirectInstructions inside retrieved contentBrowsing agents, document summaries, code review bots
Encoding and obfuscationBase64, hex, invisible Unicode, hidden textAnywhere a filter looks for plain phrases
TypoglycemiaScrambled words that humans and models can still readKeyword filters
Best-of-NMany prompt variations until one slips throughAny endpoint without rate limits
Role-play and hypotheticalsFraming that invites the model to ignore rulesChat assistants
Multi-turn and persistentInstructions built across turns or stored in memoryAssistants with memory
HTML and markdown injectionOutput with links or images that send data outChat UIs that render markdown
MultimodalInstructions inside images or documentsVision and file features
RAG poisoningMalicious text planted in the knowledge baseRetrieval apps
Agent attacksForged tool outputs or reasoning, tool manipulation, context poisoningTool-using agents
System prompt extractionCoaxing the model to reveal its instructionsAny app with a system prompt

Why simple filters fail

The NCSC explains that language models have no built-in boundary between instructions and data, unlike a database that separates query structure from values. It advises avoiding deny-lists of known attack phrases because rewording evades them. OWASP's cheat sheet treats filters as illustrative, not complete.

What helps instead

  1. Least privilege for tools and data, enforced outside the model.
  2. Human approval for high-impact actions, checked against the exact action.
  3. Treat model output as untrusted before it reaches a browser, shell or database.
  4. Separate and label untrusted content, knowing that labels alone do not enforce a boundary.
  5. Rate limit and watch for repeated attempts, which counters best-of-N.
  6. Log inputs, outputs and tool calls, without sensitive data. Repeated failed calls can show an attacker refining an approach.
  7. Test with your own channels. See how to test for prompt injection.

Quick check

Is prompt injection the same as jailbreaking?

They overlap but differ. Jailbreaking tries to make a model ignore its safety rules. Prompt injection tries to override an application's instructions, often through content the user did not write.

Can prompt injection be fully fixed?

The NCSC says it may never be fully eliminated and recommends reducing likelihood and impact. OWASP says no foolproof prevention is known.

Which type is most dangerous for agents?

Indirect injection, because the attacker never touches the app. The content the agent reads carries the instruction, and tools turn it into action.

Where Safeguard fits

Safeguard offers an MCP Guardrail and agent policies that limit what a tool-using agent can do, and a free scan at gold.safeguard.sh/scan for the dependencies in your app.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.