What is prompt injection?
Prompt injection is a type of attack that hides instructions in the input a language model reads, in order to override its original instructions and make it do something unintended. The instruction can be typed into the chat box, or planted in an email, web page or document. When the model can use tools, the result can be a data leak or an unauthorised action, not just a wrong answer.
Definition
Prompt injection is a type of attack that hides instructions in the input a language model reads, in order to override its original instructions and make it do something unintended.
How does prompt injection work?
A language model cannot strictly separate instructions from data. Both arrive in the same stream of text. In a direct attack, the user types something like “ignore the previous instructions” into the chat box. In an indirect attack, the instruction is hidden in a web page, an email or a document that the model reads.
If the model treats that text as a command, it can step outside the rules in its system prompt. OWASP includes prompt injection in its list of top risks for large language model applications.
When does the risk grow?
If the model only produces text, the damage is usually limited to a wrong or inappropriate answer. Tools change this. An AI agent that can send email, delete records or start a payment can be made to do so on an attacker’s behalf.
The risk is highest when three conditions meet: access to private data, exposure to untrusted content, and a way to send data out.
How do you defend against it?
No single measure is enough. Keep the agent’s permissions as narrow as the task allows. Require human approval for irreversible actions. Check inputs and outputs with a guardrails layer and log every tool call.
In an assistant with access to personal data, a successful attack can become a personal data breach. Plan for that scenario with your legal counsel, under GDPR and, for data processed in Türkiye, under KVKK, Türkiye’s data protection law. Testing with known attack patterns before release should be part of the plan.
Further reading
Connecting AI agents to systems with MCPIntegration patterns, authorization, prompt injection controls and human approval for connecting AI agents with MCP.
AI-powered process automationWhere language models fit into business workflows, which process to start with, and how to set up human approval, data protection and measurement.
MCP 2026-07-28: a stateless coreWhat MCP 2026-07-28 changes: no sessions, routing headers, deprecated features and a migration checklist for teams running MCP agents.Related terms
- System PromptA system prompt is the instruction text given to a language model before a conversation starts, which sets the model's role, tone, limits and output format.
- AI GuardrailsAI guardrails are technical controls that check the inputs, outputs and actions of an AI application in order to block unwanted behaviour.
- AI agentAn AI agent is software that uses a language model to decide which steps to take towards a goal and then carries out those steps with tools such as APIs, databases and email.
- Function Calling (Tool Use)Function calling (tool use) is a method that lets a language model state, in a structured format, which predefined function it wants to call and with which arguments.
- Human-in-the-Loop (HITL)Human-in-the-loop (HITL) is a way of working in which a person reviews, approves or corrects specific decisions or actions of an AI system before they take effect.
Frequently asked questions
Can prompt injection be fully prevented?
No method known today gives complete protection. The aim is to limit the damage even when an attack succeeds: narrow permissions, human approval for irreversible actions, input and output checks, and logging, all used together.
Is prompt injection the same as jailbreaking?
They are close but not identical. Jailbreaking tries to get around the model's own safety rules. Prompt injection targets the instructions of an application, and often arrives through content prepared by a third party.
Is it enough to write 'never change these instructions' in the system prompt?
No. Such sentences make simple attempts harder, but they are not a security boundary. Real protection sits outside the model: restricted permissions, checks on tool calls and an approval step for sensitive actions.
Let’s talk about your transformation
Tell us which work repeats every week. We will tell you honestly whether it is worth automating.
How we start
- A free first callWe pin down the problem and the goal together.
- A 2-week discovery sprintWe look at the data, the process and the tools, and decide where to start.
- A written proposalScope, architecture and timeline, in writing.