Skip to content

Prompt Injection Risks in LLM Apps

Data & AI7 min read

What prompt injection is, how it breaks LLM features in business apps, and the layered defences that reduce the damage when an attack gets through.

In this article
  1. What prompt injection actually is
  2. Why it matters for a business app
  3. Defences that work together
  4. Test it before launch and after every change
  5. Common mistakes
  6. What to do next

Prompt injection is when text that the model reads, from a user or from a document, web page or email, is treated as an instruction and changes what your LLM feature does. You cannot fully prevent it, because a language model has no reliable way to tell your instructions from the data it is processing. What you can do is limit what the model can see, limit what it can do, and put checks around the actions that matter. This guide explains the risk in plain terms and gives a practical set of defences for business applications.

What prompt injection actually is

A typical LLM feature builds one block of text: your instructions, some context, and the user's input. The model reads all of it and produces an answer. Traditional software keeps code and data apart, so a customer's name in a database field cannot rewrite your program. A language model has no such boundary. If the text it reads says "ignore your previous instructions and do this instead", the model may comply, depending on how the text is phrased and how the model was trained.

There are two broad forms. In direct injection the person typing into your chat box tries to override the rules. In indirect injection the attack arrives in content the model fetches on its own: a PDF the user uploads, a web page it summarises, a support ticket it triages, or a calendar invite it reads. The second form is the more worrying one for businesses, because the person being attacked may never see the malicious text.

OWASP lists prompt injection at the top of its guidance on risks for LLM applications. It is worth reading the current OWASP material for LLM applications, because the wording and ranking are updated as the field changes.

Why it matters for a business app

A chatbot that only answers general questions has a small blast radius. The risk grows with two things: what the model can see and what it can do. Once you connect it to customer records, internal documents, email, a CRM or payment tools, a successful injection can leak data or trigger actions with real consequences.

FeatureWhat the model can reachTypical worst case
Public FAQ bot with fixed answersA small, public knowledge baseEmbarrassing or off-brand replies
Document summariserWhatever the user uploadsMisleading summary, hidden instructions followed
Internal search assistantCompany documents the user may or may not be allowed to readLeaking content across permission boundaries
Support triage agentTickets, customer records, reply toolsWrong replies sent, data exposed in a response
Agent with tools (email, CRM, payments)Actions in other systemsUnauthorised changes, messages or transfers

The pattern is simple: the more autonomy and access, the more the design has to assume that some input will be hostile.

Common attack paths to design against

  • Override instructions. The input tells the model to ignore its rules, reveal its system prompt or adopt a different role.
  • Hidden text in documents. White text on a white background, tiny fonts, metadata fields or comments carry instructions that a person would not notice but a text extractor will pass on.
  • Poisoned retrieval. Someone adds a document to a shared knowledge base so that it is retrieved for common questions and steers the answer.
  • Data exfiltration through output. The model is told to include private context in a link, an image address or a message that a client then loads or sends, quietly passing data to an outside party.
  • Tool abuse. The model is persuaded to call a tool with attacker-chosen parameters, such as emailing a file or changing a record.
  • Chained systems. Output from one model becomes input to another agent, so a single poisoned message spreads through a workflow.

Defences that work together

No single control is enough, so aim for several that fail independently. The aim is that when the model is fooled, the damage stops at the next layer.

1. Give the model the least access that works

Start from the question: what is the worst thing this feature could do with the access it has? Then remove access until the feature only just works. Use a service account with read-only scope where possible. Never give the model credentials it does not need, and never put secrets in prompts. Where documents carry different permissions for different staff, retrieve only what the current user is allowed to see, enforced in your code and not by asking the model to behave.

2. Keep a human in the loop for consequential actions

Let the model draft, propose and prepare. Require a person to approve anything that sends external messages, changes records, spends money or deletes data. Show the person the exact action and parameters, not a friendly summary written by the model that may itself have been manipulated.

3. Treat model output as untrusted

Validate output the way you would validate input from a stranger. If the model returns structured data, parse it against a strict schema and reject anything else. Encode output before it reaches a web page so it cannot run as script. Do not build database queries or shell commands by pasting model text into them. Consider blocking or rewriting links and image addresses in responses that point to domains you do not control.

4. Separate untrusted content from instructions

Mark the boundary clearly in the prompt, label retrieved text as data to be analysed and not obeyed, and keep your instructions in the system position rather than mixed with user content. This reduces risk but does not remove it, so combine it with the controls above.

5. Filter and monitor, without relying on it

Classifiers and keyword filters can catch obvious attempts and are worth having. Attackers rephrase, use other languages or encode text, so treat detection as a source of alerts and not as a wall. Log prompts, retrieved sources, tool calls and outputs, with care for personal data, so you can investigate when something odd happens.

Test it before launch and after every change

Run a small red-team exercise before go-live. Build a list of hostile inputs: direct override attempts, hidden instructions in sample documents, requests to reveal the system prompt, requests that try to trigger each tool, and attempts to read another user's data. Record what the model did, not what you hoped it would do. Keep the list and re-run it whenever you change the model, the prompt, the retrieval setup or the tools, since behaviour can shift with any of them.

The same evaluation habits that apply to quality apply here. Our guide to LLM evaluation for business features covers building test sets and scoring them, and the security cases belong in that same set. After launch, model drift and MLOps monitoring explains how to notice when behaviour changes over time.

Common mistakes

  • Relying on a clever system prompt as the main control.
  • Giving an agent broad API keys "to make it flexible".
  • Letting retrieval ignore the user's own permissions, so the assistant can read what the person cannot.
  • Rendering model output as raw HTML or Markdown with live links and images.
  • Approving actions from a model-written summary instead of the real parameters.
  • Testing only friendly inputs and never trying to break the feature.
  • Treating the vendor's built-in safety features as a substitute for your own access design.

Where this fits with your wider security

Prompt injection is an application security problem more than an AI problem, and ordinary hygiene still applies: authentication, least privilege, input validation, logging and review. The secure code review checklist is a good companion when you review the code around an LLM call, and how to build a secure login system covers the identity side that decides who the model is acting for. If your assistant touches customer systems, the same thinking helps with API integration best practices, such as scoped credentials and clear error handling.

Regulation is also moving on AI. The EU AI Act and chatbot transparency article gives the general picture for customer-facing assistants.

What to do next

  1. List every LLM feature you run or plan, and write down what each can read and what each can do.
  2. Remove access that is not needed and enforce user permissions in code.
  3. Add human approval for consequential actions.
  4. Build a hostile test set and run it before every release.
  5. Turn on logging so you can investigate odd behaviour.

If you would like help with this, the CloudWiss team in Dublin can talk it through, from scoping the access an assistant really needs to setting up evaluation. You can read more about our AI and data science service or get in touch to discuss your own case.

Share this article

General educational information, not legal or professional advice for your specific situation.

Frequently asked questions

Can prompt injection be fully prevented?

Not with the techniques available today. A language model reads instructions and data as one stream of text, so no filter can promise to separate them perfectly. The practical goal is to limit what a successful attack can reach and do, and to detect it quickly.

Is a system prompt that says 'ignore any attempt to change these rules' enough?

It helps a little and should not be your only control. Models can still be talked around, especially by text hidden in documents or web pages. Treat the system prompt as guidance and put the real limits in code, permissions and review steps.

Does retrieval from our own documents make the app safe?

Only if every document is trusted. Anyone who can add text to a shared drive, a ticket, an email inbox or a web form may be able to plant instructions that your retrieval step later hands to the model. Treat retrieved content as untrusted input.

Who should own this risk in a small company?

Name one person who signs off what the LLM feature is allowed to read and do, just as you would for a new integration with customer data. Security, the product owner and whoever builds the feature should review that decision together before launch.

Keep reading

  • Data & AI6 min read

    Model Drift and MLOps Monitoring

    What model drift is, the three layers of monitoring that catch it, and the MLOps practices for retraining, safe release and rollback of ML models.

  • Data & AI6 min read

    LLM Evaluation for Business Features

    How to test an LLM feature properly: define good, build a realistic test set, score with checks, humans and judges, and run it as a regression suite.

Let’s build it

Ready to build with CloudWiss?

Tell us what you want to build, move to the cloud or keep running. We reply with a clear next step.