Generative AI / TECHNICAL PERSPECTIVE

Prompt Injection Defence for LLMs: When AI Reads the Wrong Instructions

Learn how prompt injection threatens enterprise AI assistants and how layered security, restricted permissions and independent checks can reduce business risk.

Prompt injection defence for LLMsGenerative AI securityIndirect prompt injectionRAG securityAI guardrailsAI agent securityLeast privilege
REFERENCE WORKFLOW03 stages
01Receive the authorised request and identify the trust level of retrieved information
02Let the LLM interpret information and propose a response or a permitted action
03Apply independent access, disclosure and action checks; release the result or escalate
EXECUTIVE SUMMARY

Key takeaways

  • An AI assistant must distinguish information it reads from instructions it is authorised to follow.

  • Prompt injection can enter through user messages, documents, emails, websites and connected services.

  • Better prompts and detection tools are useful, but they cannot guarantee immunity.

  • Keep access control, sensitive-data disclosure and business-action authorisation outside the language model.

  • Evaluate whether an attack causes an actual policy violation, not just whether the model produces a suspicious response.

  • Increase AI autonomy only when the safeguards are appropriate for the consequences of failure.

01 PRACTICAL GUIDANCE

What if the document your AI reads tells it what to do?

Imagine a procurement team introducing an AI assistant to review supplier proposals. Employees ask it to summarise commercial terms, identify contractual risks and compare competing offers. Everything works well during the pilot. Then a proposal arrives containing text intended to influence the assistant's assessment. Instead of evaluating the supplier against the organisation's criteria, the AI begins favouring that supplier.

The employee has not asked the AI to change its assessment criteria. The instruction came from the document itself. If the assistant is also connected to procurement systems, the consequences could extend beyond a misleading recommendation to an attempted change in a business record.

This is the central problem of prompt injection. Businesses want AI to read information from many sources, but they do not want those sources to acquire authority over the application.

Prompt injection defence for LLMs is therefore more than a chatbot security feature. It is an architectural and governance challenge that determines how safely an organisation can connect generative AI to its information and processes.

02 PRACTICAL GUIDANCE

The difference between reading information and following it

A large language model (LLM) generates responses from the context provided to it. That context may include application instructions, a user's question, retrieved documents and information returned by external tools. Prompt injection occurs when untrusted input influences the model to behave contrary to the intended instructions or application policy. NIST identifies the combination of untrusted input with higher-trust prompts as central to the problem.[1]

Direct prompt injection originates in the user's input. For example, someone interacting with a customer-service assistant may attempt to persuade it to disclose information outside the permitted scope.

Indirect prompt injection originates in material the AI processes on the user's behalf. An uploaded supplier proposal, a support ticket or a public web page can contain instructions that are unrelated to the legitimate task. The person using the AI may be unaware of them.

Unlike ordinary misinformation, prompt injection attempts to influence the behaviour of the system itself. An incorrect price in a document is a data-quality problem; document content attempting to control how the assistant evaluates that price presents an additional security concern.

Jailbreaking is related but generally focuses on defeating model behaviour restrictions. Enterprise prompt injection also concerns application-specific authority, such as access to confidential records or permission to initiate transactions.

03 PRACTICAL GUIDANCE

Why a stronger system prompt is not enough

An effective system prompt should define the assistant's role, expected behaviour and treatment of external content. This improves consistency, but it should not be mistaken for a technical access-control mechanism.

The UK's National Cyber Security Centre explains why prompt injection differs from conventional SQL injection: current LLMs do not provide a dependable internal security separation between instructions and data. Its guidance emphasises reducing consequences through system design rather than assuming malicious instructions can always be recognised.[2]

Consider an employee who asks a knowledge assistant to summarise a document. The model needs to interpret the document's language to complete the task. Simply asking it to ignore every imperative sentence would damage useful functionality, particularly when reading procedures, contracts and technical manuals.

Filters and specialised classifiers can help identify suspicious content. However, legitimate material can trigger alerts, and harmful content can be missed. Treat these controls as useful risk signals, not as proof that a request is safe.

The important design assumption is that the model may occasionally be misled. What matters next is whether the surrounding application permits that mistake to become a business incident.

04 PRACTICAL GUIDANCE

Four controls that change the consequences of an attack

First, establish clear trust boundaries. Keep application policy in controlled configuration and identify user requests, retrieved documents and tool responses according to their origin. Preserve these distinctions throughout the workflow, even when information is summarised or passed between components. Trust labels guide the model; they are not a substitute for independently enforced permissions.

Second, restrict what the AI can access. Apply the authenticated user's record-level permissions before retrieving information and give connected services narrowly scoped credentials. An assistant that summarises invoices should not automatically gain access to payroll, payment execution or the wider finance database.

Third, separate recommendations from execution. A model can propose an operation in a structured format, but the application must decide whether it is authorised. Check the user's identity, action type, affected record, destination and applicable business rules using ordinary application code. Validate both the structure and meaning of the request.

Fourth, control what leaves the system. Check responses for inappropriate disclosure and ensure external destinations are permitted. Avoid automatically executing model-generated content or fetching external resources from generated output. Require independent approval for consequential operations, such as sending confidential documents or modifying payment information.

OWASP's prompt injection guidance recommends multiple complementary mitigations, including limited privileges, validation and human oversight.[3] The practical objective is to reduce the likelihood of manipulation while independently limiting the harm that a manipulated model can cause.

05 PRACTICAL GUIDANCE

RAG can improve answers without making them secure

Retrieval-augmented generation (RAG) allows an AI assistant to search business information before answering a question. It is useful when employees need current company policies, product documentation or internal procedures. But the additional information also creates another route through which untrusted content can reach the model.

A document being stored in a corporate knowledge base does not automatically make every sentence in it authoritative. Internal repositories may contain customer correspondence, draft policies, supplier attachments and documents written by people with different permissions.

At ingestion, record document provenance, classification, ownership and approval status. At retrieval, enforce user-specific access restrictions and select sources appropriate to the task. A semantic search result indicates relevance, not authority.

For policy questions, distinguish approved policies from drafts, comments and externally supplied documents. If the retrieved sources conflict, the assistant should explain the uncertainty or refer the question to an appropriate owner rather than silently accepting a document's instruction.

Grounding and citations improve traceability, but a citation can point to a misleading source. Test whether the cited material actually supports the claim and whether it is authoritative for that decision. OWASP notes that RAG and fine-tuning do not fully address prompt injection vulnerabilities.[3]

06 PRACTICAL GUIDANCE

When AI can act, the permissions matter more than the prompt

An AI assistant that only summarises information has a different risk profile from an AI agent that can send messages, create tickets or modify business records. Read-only access limits some consequences, but it does not eliminate confidentiality or misleading-output risks.

Suppose a finance department uses AI to extract invoice information. The model can produce a proposed record containing supplier name, invoice number and amount. A separate service reconciles those fields with purchase orders and approved supplier records. Any payment instruction remains subject to the existing payment authorisation process.

The same principle applies to an AI assistant handling customer refunds. The model may identify the applicable refund policy, but an independent service checks the actual order, customer permissions, refund limits and transaction state. A model response asserting that a refund is approved does not create approval.

For operations requiring human consent, show the reviewer the real proposed action, affected records and destination using trusted application data. Bind the approval to those specific parameters so a materially changed request requires a new decision.

Research by Debenedetti and colleagues proposes CaMeL, an approach that constrains the influence of untrusted information on execution and governs permitted data flows.[4] This illustrates the importance of architectural separation. The research does not establish that every deployment or workflow is immune to manipulation.

07 PRACTICAL GUIDANCE

How to test whether the controls actually work

An AI security assessment should examine the whole application, including retrieval, integrations, permission checks, output handling and approval processes. Testing the language model alone cannot establish whether an unauthorised action would succeed.

Start with the legitimate task and define what must never happen: disclosure of another customer's information, unauthorised record changes or communication to an unapproved destination. Use synthetic records and isolated test integrations to examine these boundaries without exposing real customers or live business operations.

Include direct and indirect manipulation scenarios, multiple supported languages, long conversations and externally supplied documents. Test ordinary legitimate requests as well. An assistant that blocks every difficult question may appear secure in a narrow test but offer little operational value.

Measure the rate of policy violations across defined adversarial test cases. Distinguish model-level manipulation from end-to-end violations: a model may propose a prohibited action that the execution service correctly rejects. Record both, rather than reporting a single security score.

Track legitimate-task completion, incorrectly blocked requests, review volume, additional latency and the cost of operating security controls. Define the denominators and acceptance criteria before testing. Report results by workload and risk tier, since a good average can conceal a serious failure in a sensitive process.

Repeat the assessment after changes to models, prompts, retrieval sources, permissions and connected tools. An absence of observed violations on a test set is useful evidence, but it is not a guarantee against future attacks.

08 PRACTICAL GUIDANCE

A practical rollout for organisations already using generative AI

Begin with an inventory of AI applications and their connections. Identify what information enters each system, which identities can use it, what records it can access and what external effects it can produce. Pay particular attention to service accounts with access broader than the authenticated user's permissions.

Prioritise assistants that combine sensitive information with external content or the ability to execute transactions. Restrict high-impact tools until permission enforcement, approval processes and security testing have been demonstrated.

Assign clear ownership. The product owner defines the legitimate business task and unacceptable outcomes. Engineering implements the boundaries. Security evaluates their robustness, and relevant risk teams provide independent challenge according to the organisation's governance model.

Create an incident process that can suspend an affected integration, restrict credentials, isolate suspicious content and investigate potentially unauthorised actions. Record sufficient evidence, such as request identifiers, policy decisions, source identifiers and action outcomes, without unnecessarily storing sensitive prompts or documents. OWASP's implementation-oriented prevention guidance provides further detail on integrating security checks around LLM applications.[5]

For a small business that only needs employees to search an approved knowledge base, a restricted read-only assistant or conventional search system may be more appropriate than a fully autonomous agent. As requirements grow, introduce additional capabilities incrementally instead of granting broad permissions at the outset.

09 PRACTICAL GUIDANCE

The question leaders should ask before expanding AI autonomy

Can the organisation explain what happens when its AI assistant encounters information designed to influence it? More importantly, can it establish that important business restrictions still hold if the model behaves incorrectly?

The answer determines whether the organisation needs a better prompt, a redesigned integration, stronger access controls or a more limited AI use case. Investing in a security product without understanding those boundaries may leave the most important exposure unchanged.

If your organisation is introducing enterprise assistants, RAG or tool-enabled AI, a focused review of information flows, permissions and action boundaries can help identify where investment in security will be most useful.

In my view, the goal is not to build an AI system that must always make the right judgement to remain safe. It is to build an application whose most important security decisions remain dependable even when the AI makes a mistake.

10 PRACTICAL GUIDANCE

References and further reading

[1] National Institute of Standards and Technology (NIST). Prompt injection — CSRC Glossary, drawing on NIST AI 100-2e2025, Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations. Source: https://csrc.nist.gov/glossary/term/prompt_injection

[2] UK National Cyber Security Centre. Prompt injection is not SQL injection (it may be worse). Source: https://www.ncsc.gov.uk/blog-post/prompt-injection-is-not-sql-injection

[3] OWASP Gen AI Security Project. LLM01:2025 Prompt Injection. Source: https://genai.owasp.org/llmrisk/llm01-prompt-injection/

[4] Debenedetti, E., et al. (2025). Defeating Prompt Injections by Design. Research preprint. Source: https://arxiv.org/abs/2503.18813

[5] OWASP Cheat Sheet Series. LLM Prompt Injection Prevention. Source: https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html

WORKED EXAMPLE / SAMPLE DATA

Apply the approach

Consider a hypothetical insurance claims assistant that reads customer-submitted documents, summarises claims and proposes next steps. A submission contains content intended to influence the assessment or trigger an unauthorised action. The following controls show how different parts of the system can reduce the resulting exposure. These are proposed design safeguards, not measured results from an actual deployment.

Document processingUntrusted input

Identify customer-submitted documents as evidence, not instructions. Retrieve only information permitted for the authenticated user and retain source provenance.

Claims recommendationIndependent checks

Compare the proposed assessment with approved policy and claim records. Refer ambiguous or inconsistent recommendations to a qualified reviewer.

Payment or record changeAuthorisation required

Keep the execution service separate from the LLM and enforce role-based permissions, transaction validation and any required approval before changing records or initiating payment.

IMPLEMENTATION CHECKLIST

Put the approach into practice

  1. 01Map the sources of untrusted content, sensitive information, tools and potential external effects for each AI application.
  2. 02Enforce user-scoped data access and restrict service credentials to the capabilities required for the legitimate task.
  3. 03Apply independent validation to model-generated outputs and proposed actions; add action-specific approval for consequential operations.
  4. 04Test with synthetic information and isolated integrations, measuring security violations alongside legitimate-task success.
  5. 05Monitor control decisions, maintain an incident-response process and reassess risk whenever models, data sources or integrations change.
COMMON QUESTIONS

Frequently asked questions

Can prompt injection be completely prevented?

There is no generally dependable way to eliminate prompt injection within current LLMs while retaining their full language-processing utility. Use layered safeguards and enforce important security rules outside the model. Residual risk must be assessed for each application.

Does a private or locally hosted LLM solve the problem?

No. Private hosting may improve control over data processing and infrastructure, but a locally hosted model can still be influenced by untrusted input. The application must separately enforce permissions, information disclosure and action restrictions.

Can an AI guardrail replace ordinary application security?

No. Guardrails can detect or reduce unwanted behaviour, but their predictions can be wrong. Authentication, authorisation, input and output validation, network restrictions and transaction controls remain necessary.

Should confidential information ever be included in a prompt?

Only include information necessary for an authorised task, in an approved processing environment, subject to applicable data handling policies. Do not place reusable credentials or secrets in prompts. Limit what the application retrieves and what the response is permitted to disclose.

How much does prompt injection defence cost?

Cost depends on the application's data sensitivity, integration complexity, monitoring requirements, testing effort and human-review volume. Start with an assessment of the potential impact and existing controls before selecting additional security tools.

CONTINUE EXPLORING

Related articles

Continue through the same expertise domain or explore another perspective.

Generative AI
Puneett Bhatnagr · 14 min read

Advanced RAG Architecture Patterns: Beyond the Basic AI Chatbot

Discover how advanced RAG architecture patterns help enterprise AI find better evidence, handle complex questions, respect permissions and deliver more dependable answers without unnecessary complexity.

Advanced RAG architecture patternsHybrid retrievalContext engineeringHierarchical retrievalGraphRAGAgentic RAGRAG evaluation
Read article
Generative AI
Puneett Bhatnagr · 13 min read

Beyond OCR: How Multimodal AI Can Understand Enterprise Documents

Explore how multimodal AI for enterprise documents interprets text, tables and images, supports reliable extraction, and reduces manual work with human oversight.

Multimodal AI for enterprise documentsDocument intelligenceVision-language modelsOptical character recognitionMultimodal RAGHuman-in-the-loop validation
Read article
Generative AI
Puneett Bhatnagr · 12 min read

Embedding Model Selection: Why Your AI Must Find the Right Evidence

Choosing an embedding model shapes the quality, cost and reliability of enterprise AI search. Learn how to evaluate models, benchmark retrieval and build a dependable RAG system.

Embedding model selectionRetrieval-augmented generationSemantic searchVector embeddingsHybrid retrievalRetrieval evaluationGenerative AI
Read article
Generative AI
Puneett Bhatnagr · 12 min read

Enterprise Context Engineering: Why Better AI Needs Better Context

Discover how enterprise context engineering helps AI use relevant, authorised business information to improve answer reliability and reduce avoidable rework.

Enterprise context engineeringGenerative AIRetrieval-augmented generationContext managementEnterprise knowledge assistantsAI evaluationAI security
Read article
Generative AI
Puneett Bhatnagr · 13 min read

Hybrid Search for Generative AI: Better Answers Start with Better Search

Why do AI assistants miss information your business already holds? Discover how keyword and vector search work together to improve enterprise RAG, retrieve relevant evidence and make AI answers more dependable.

Hybrid searchGenerative AIRetrieval-augmented generationBM25Vector searchSemantic rerankingEnterprise knowledge management
Read article
Generative AI
Puneett Bhatnagr · 13 min read

LLM Fine-Tuning vs RAG: Which Approach Does Your Business Need?

Should your AI learn new behaviour or retrieve better information? Explore LLM fine-tuning vs RAG through business examples, architecture choices, cost trade-offs and practical evaluation criteria.

LLM fine-tuningRetrieval-augmented generationEnterprise generative AIModel adaptationKnowledge groundingLLM evaluationLoRAAI architecture
Read article
Generative AI
Puneett Bhatnagr · 14 min read

RAG Chunking Strategies: Why Your AI Misses the Right Answer

Learn how RAG chunking strategies preserve meaning, improve document retrieval and help AI assistants deliver reliable, evidence-based answers at a manageable cost.

RAG chunking strategiesRetrieval-augmented generationSemantic chunkingDocument retrievalContext engineeringRAG evaluation
Read article
Generative AI
Puneett Bhatnagr · 13 min read

RAG Reranking Techniques: Why Finding the Right Evidence Matters

Explore how RAG reranking techniques improve the relevance of evidence behind AI answers, compare retrieval strategies and learn when a reranker is worth the investment.

RAG reranking techniquesRetrieval-augmented generationCross-encoder rerankingHybrid searchSemantic searchRetrieval evaluationContext engineering
Read article
Generative AI
Puneett Bhatnagr · 12 min read

Structured Outputs in LLM Applications: Beyond Better Answers

Turn AI-generated language into dependable application data. Learn how JSON Schema, independent validation and safe workflow integration make structured outputs useful for business.

Structured outputsGenerative AIJSON SchemaConstrained decodingLLM applicationsOutput validationDocument intelligenceFunction calling
Read article
Generative AI
Puneett Bhatnagr · 12 min read

Synthetic Data for Generative AI: When Real Data Is Not Enough

Learn how synthetic data can strengthen generative AI training and testing, expand coverage of rare scenarios and reduce dependence on sensitive records while preserving reliability.

Synthetic dataGenerative AIInstruction tuningAI evaluationData augmentationData privacyModel collapse
Read article
Generative AI
Puneett Bhatnagr · 12 min read

When AI Sounds Certain but Is Wrong: LLM Hallucination Detection

Can your business trust its AI-generated answers? Explore how LLM hallucination detection combines evidence checks, uncertainty signals and human oversight to catch unreliable claims before they influence decisions.

LLM hallucination detectionGenerative AIAI factualityRetrieval-augmented generationSemantic entropyLLM evaluationAI reliabilityHuman oversight
Read article
LET'S CONNECT

Let’s build something with AI.

I welcome conversations about enterprise AI, strategic advisory, executive leadership and research collaboration.

Use the inquiry form below
  • AI engineering and enterprise architecture
  • Responsible AI and model risk
  • Executive opportunities and consulting
  • Research and technical collaboration
AI collaborationA message connects enterprise AI strategy, AI engineering and responsible governance.AI COLLABORATIONConnectStrategyEngineeringGovernance

Send me an inquiry

Tell me about your AI challenge, leadership opportunity or research idea.

Please do not include confidential business data.

Enter the answer to confirm you are human.
Let’s connect

Explore the portfolio

Search the eight expertise pages, selected case studies and research records.