Prompt injection prevention in 2026 is about limiting damage, not building a perfect filter: no known method reliably stops a large language model (LLM) from obeying instructions hidden in the text it reads. What works is layered design, with least privilege, rules enforced in ordinary code, human approval for risky actions, logging and adversarial testing.
That matters more for teams in India now. Once an LLM app or agent touches personal data, a successful injection can become a data protection problem under the Digital Personal Data Protection (DPDP) framework, not just a model quality bug.
What is prompt injection?
Prompt injection happens when input to an LLM changes its behaviour in a way the developer did not intend. The input can come from a user, a web page, an email, a retrieved document, a tool response, an image or the agent’s own memory.
The OWASP GenAI Security Project lists it as LLM01 in its 2026 Top 10 for LLM applications. The root cause it describes is simple: a model has no hard boundary between instructions and data. Both arrive as tokens.
Direct vs indirect prompt injection
| Type | Where the instruction comes from | Example |
|---|---|---|
| Direct | The user, or someone using the user’s access | A chat message telling a support bot to ignore its rules and look up another customer |
| Indirect | External content the model reads | Hidden text in a web page that tells a summariser to leak the conversation |
| Stored or persistent | Poisoned memory or a retrieval (RAG) corpus | A planted document that skews answers to later queries |
| Multimodal or hidden | Images, audio, video or invisible Unicode characters | Text a person cannot see but the model can process |
Indirect injection is usually the harder problem. The person using your assistant may never see the malicious text, and the source may look trustworthy, such as a support ticket, a code repository or an internal mailbox that outsiders can write to.
Why prompt injection cannot be patched like SQL injection
SQL injection has a dependable fix: parameterised queries keep commands and data apart. In December 2025, the UK’s National Cyber Security Centre (NCSC) warned that prompt injection is not SQL injection and may never be fully mitigated in the same way.
The NCSC frames the LLM as a “confusable deputy”: a component with legitimate powers that can be talked into using them for someone else. Its advice is to reduce both the likelihood and the impact, and to reconsider using an LLM where the remaining risk is unacceptable. OWASP reaches a similar conclusion.
So the useful design question changes. Instead of asking “Can we detect every attack?”, ask “What is the worst thing that can happen if the model is fully fooled?”
Prompt injection prevention: layered defences that help
1. Apply least privilege to every tool
Give the agent only the tools, records and scopes needed for the current task. Prefer read-only access. Keep API keys and database credentials in application code, never in the prompt or model context.
The NCSC offers a handy rule: when a model processes content from some party, its privileges should drop to that party’s level. An assistant reading an outsider’s email should not hold powerful tools at that moment.
2. Use the Rule of Two as a floor
Look for three properties in one agent session:
- It processes untrusted input.
- It can access sensitive data.
- It can change state or communicate externally.
OWASP’s guidance is that an agent combining all three needs human approval for each action. Where two are present, assess the residual risk and record your decision. Better still, split the work so one component never needs all three.
3. Enforce policy outside the model
A system prompt that says “never email customer data” is a request, not a control. Put the real check in deterministic code: an allow-list of recipients, limits on record counts, parameter validation and a policy engine in front of privileged calls.
Also require a strict output schema and validate it before anything downstream uses it. A valid structure can still carry a harmful value, so check meaning too.
4. Block common exfiltration paths
A model does not always need an email tool to leak data. A generated image link or URL can carry information to an attacker’s server when the interface loads it. Restrict outbound domains, disable automatic loading of remote images in model output, and review any link containing query data.
5. Separate and label untrusted content
Pass external content through a clearly marked channel with its source attached. Strip invisible Unicode characters at input and display points. These steps raise the cost of an attack, but a determined attacker can still get through. Treat keyword deny-lists with caution, because rephrasing defeats them.
6. Ask humans to approve irreversible actions
Before sending, deleting, paying or publishing, show the reviewer the exact action: recipient, content and affected records. A vague summary written by the same model is not enough.
7. Protect memory and tool supply chains
Treat writes to agent memory as privileged. Record what caused each write and flag memories that read like instructions. If you connect tools through Model Context Protocol (MCP) servers, pin and verify versions and read tool descriptions for hidden instructions.
8. Test with adaptive attacks and monitor
Red-team the system assuming the attacker knows your defences. A fixed list of old attack strings gives false comfort. Log inputs, outputs, tool calls and failures well enough to reconstruct an incident, while controlling who can read those logs and how long you keep them.
A quick checklist for AI agent security
| Question | Safer answer |
|---|---|
| Can the model reach more data than this user can? | No. Access follows the user’s own permissions. |
| Who decides whether a tool call is allowed? | Application code, not the model. |
| Can output send data outside without approval? | No. Domains and recipients are restricted. |
| Are risky actions reviewed? | Yes, with exact details shown. |
| Can you trace an incident? | Yes. Tool calls and data access are logged. |
Prompt injection and the DPDP Act
Here is where AI security meets Indian data protection law. The DPDP Act’s idea of a personal data breach is broad, covering unauthorised processing or accidental disclosure and similar events that compromise confidentiality, integrity or availability. My reading is that an injected instruction that exposes, alters or destroys personal data could fall within it. The facts of each incident will matter.
Security safeguards under Rule 6
Rule 6 of the DPDP Rules, 2025 sets minimum “reasonable security safeguards”. The table maps some of them to LLM applications. The mapping is my suggestion; the Rules do not mention prompt injection in these items.
| Rule 6 theme | Practical step for an LLM app |
|---|---|
| Encryption, masking, obfuscation or tokens | Mask personal data before it enters the model context |
| Access control | Scope tool and retrieval access to the user and task |
| Logs, monitoring and review | Trace which data and tools each session touched |
| Backups and continuity | Make agent changes reversible |
| One-year retention of logs and personal data for detection and investigation, unless another law requires otherwise | Plan secure storage and restricted access for AI traces |
| Safeguards in processor contracts | Cover model, hosting and tool vendors that process data for you |
Breach intimation and penalties
Under Rule 7, a Data Fiduciary must inform affected individuals and the Data Protection Board of a breach without delay, and give the Board fuller details within 72 hours of becoming aware of it, subject to any extension the Board allows. See my guide to the DPDP 72-hour breach notification rule.
The Act’s Schedule allows penalties of up to ₹250 crore for failing to take reasonable security safeguards, and up to ₹200 crore for failing to give breach notice. These are maximums, not automatic fines.
Timing: Rules 6 and 7 are scheduled to apply from May 2027, eighteen months after the November 2025 notification. A shorter timeline has been discussed, but I found no notified amendment to that effect in the sources checked (the latest dated 22 November 2026). Verify the current position before you plan around it. If you deploy agents, also read who is responsible for AI agents under the DPDP Act.
Disclaimer: This article is general information, not legal advice. Consult a qualified professional about your situation.
Frequently asked questions
Can prompt injection be completely prevented?
Not reliably with current LLM designs. You can reduce the chance of success and sharply limit what a successful attack can do.
Is prompt injection the same as jailbreaking?
No. Jailbreaking is a subset aimed at breaking a model’s safety rules. Prompt injection also covers hijacking an application through content the user never wrote.
Does RAG or fine-tuning stop prompt injection?
No. Neither creates a hard boundary between instructions and data, and a RAG corpus can itself be poisoned.
Is a stronger system prompt enough?
No. It helps set behaviour, but permissions and approvals must be enforced outside the model.
Is a prompt injection attack a DPDP data breach?
It can be, if it results in a compromise of personal data that fits the Act’s definition. An attempt that is blocked without affecting data is a different situation. Get legal advice on actual incidents.
Conclusion
Assume your model can be fooled and design so that this is survivable. Start by listing every tool and data source your agent can reach, remove what it does not need, and put approval and policy checks around the rest. That work improves security today and prepares you for DPDP safeguard duties.