Prompt injection review for teams shipping LLM features
Prompt injection is a system design problem, not a clever string problem. This article lays out how to map untrusted inputs, reduce model authority, secure tool use, and test indirect injection paths in real AI systems.
Practitioners keep reaching for large language models in places where trust matters. Support agents draft replies. Internal tools summarize incidents. Security teams ask a model to explain logs or write triage notes. The hard part is no longer calling a model. The hard part is keeping control of the model once untrusted text enters the prompt.
Simon Willison recently quoted Josh Dunsterville on prompt injection. The useful point is simple. Treat model instructions and untrusted content as mixed together unless you have built a strong boundary. That matters to any team building AI into a product or workflow.
If you ship LLM features, you need a practical review method. Look at where hostile text enters, what authority the model holds, what side effects exist, and how you test failure paths. The common mistake is to focus on the cleverness of the attack string. The deeper issue is system design.
Map every untrusted input path
Start with inventory. Most teams know the chat box is untrusted. They miss the rest.
Common input paths include:
- user chat messages
- uploaded PDFs and spreadsheets
- support tickets pulled from a helpdesk
- web pages fetched for summarization
- code repositories indexed for Q and A
- email bodies and attachments
- OCR text from images
- tool outputs from search, SQL, or external APIs
Every one of these paths is a prompt injection path if text from the source reaches the model. The attack does not need to look malicious to a human reader. A hidden HTML block, a white-on-white PDF section, or a line in a CSV cell is enough if your pipeline passes it through.
Your first control is labeling. Mark each source as trusted, internal but editable, or fully untrusted. Internal data often lands in the middle. Wikis, tickets, and CRM notes are inside your systems but still editable by many people. In practice, they behave like untrusted content.
Then trace propagation. Which prompts include raw source text. Which prompts include summaries of summaries. Which downstream steps reuse the model output. Many failures happen two hops later, when an earlier summary carries injected instructions into a later agent with more permissions.
A basic review table helps:
| Source | Who edits it | Reaches model raw | Reaches agent tools | Human review |
|---|---|---|---|---|
| support tickets | customers, staff | yes | yes | sometimes |
| internal wiki | staff | yes | no | no |
| fetched URLs | public web | yes | yes | rare |
| uploaded docs | users | yes | no | sometimes |
This mapping step sounds simple. Teams skip it because the feature works in happy-path testing. Then the first time an agent reads hostile text from a file, the failure looks surprising. It is not surprising if you mapped the data flow.
Reduce the model’s authority
Prompt injection becomes serious when the model has power. Reading bad text is one problem. Letting the model spend money, send messages, query sensitive systems, or change state is a different class of risk.
Ask four blunt questions for each LLM feature:
- What data does the model read?
- What tools does the model invoke?
- What state changes follow its output?
- What secrets are present in the same context?
A safe pattern is least authority. Give the model access only to the tools and data needed for one narrow task. Split broad agents into smaller steps with different permissions. A summarizer should not also hold the ability to email a customer or issue a refund.
Bad pattern:
- one agent reads user content
- same agent has access to CRM, email, billing, and admin APIs
- tool calls proceed from model intent with weak validation
Better pattern:
- one model classifies or extracts fields from untrusted content
- a separate deterministic layer validates those fields
- a separate service performs the state change with policy checks
- high-impact actions require explicit user confirmation or human review
You should also keep secrets out of the prompt where possible. If the model does not need an API key, customer PII, or internal rationale text, do not place it in context. Prompt injection often becomes data exfiltration because teams overpack context for convenience.
If you are red-teaming an agent, focus less on making the model say odd things and more on whether it gains authority from hostile content. The damage comes from actions and access.
Treat tool use as a security boundary
Many teams describe tool-using agents as if the model is deciding and the tools are helpers. Security review should invert that view. Tools are privileged operations. The model is an untrusted planner.
That leads to a different design style.
First, define strict schemas for tool inputs. Avoid free-form strings where a narrow enum or typed structure will do. If a model chooses an email recipient, a billing amount, or a database filter, validate it against an allowlist, policy, or independent lookup.
Second, separate reason generation from execution. Let the model propose an action. Then pass the proposal into code which enforces constraints.
For example:
Model output:
- action: refund
- order_id: 48291
- amount: 499.00
- reason: duplicate charge
The execution layer should still check:
- does order 48291 exist
- is the amount within policy
- did another system confirm a duplicate charge
- does this user role allow refunds
- does the action need a second approval
Third, make tools return minimal data. If a search tool returns ten pages of raw results, any hostile text in those results enters the next prompt. Return structured facts instead. The same rule applies to database queries and web fetchers.
Fourth, log every tool call with enough detail for review. You need the prompt version, source references, tool arguments, validation outcome, and user identity. Without this, incidents turn into guesswork.
For systems already in production, a targeted test harness helps. Pigfox’s Prompt-Injection & System-Prompt-Leak Tester fits this stage because it exercises an LLM system against common failure modes from the OWASP LLM Top 10.
Test for indirect injection, not only direct attacks
Direct attacks are the obvious ones. A user types, “ignore previous instructions” and asks for hidden data. Most teams test this. Indirect injection is where practitioners still get caught.
Examples:
- a web page includes hidden instructions aimed at summarizers
- a README in a repository tells an agent to expose secrets
- a support ticket contains instructions for the triage bot
- a PDF appendix includes off-screen text for OCR pipelines
- a calendar invite or email signature carries adversarial instructions
Indirect injection matters because the source looks like content, not a command channel. Your product often fetches it automatically. The user does not need direct prompt access to influence the model.
Your tests should mirror this reality.
Build a corpus of hostile fixtures across formats:
- HTML with hidden text and comments
- Markdown with instruction blocks
- PDFs with appended text layers
- CSV cells with long instruction strings
- images whose OCR output contains commands
- API responses with instruction-like content in fields
Then test each fixture across the full chain. Do not stop at the first model. See whether the content survives chunking, summarization, retrieval, and agent planning. Many attacks fail early. Some become stronger after preprocessing strips visual cues and leaves plain text.
Also score success carefully. A failed refusal message is not the only problem. Count these as failures too:
- the model leaks system prompt fragments
- the model requests tools it should not request
- the model changes priority or workflow based on injected text
- the model omits relevant source material because injected text hijacked attention
- the model produces output which causes another service to take action
This is where teams benefit from regression tests. Once you find a prompt injection path, keep the fixture and rerun it on every prompt or orchestration change.
Read retrieval and memory as attack surfaces
RAG systems and agent memory widen the problem. If you store model-readable text for later reuse, you have created a persistence layer for prompt injection.
In a retrieval system, inspect three things.
First, ingestion policy. Which documents enter the index. If your pipeline accepts public web content, user uploads, or broad internal notes, then hostile instructions enter the corpus unless you filter or segment them.
Second, chunking and metadata. Large chunks mix benign facts with adversarial instructions. Weak metadata makes it hard to apply policy later. Store source type, owner, trust level, and access scope alongside each chunk.
Third, retrieval formatting. The way you present chunks to the model matters. If every retrieved passage looks like equal-authority instruction text, the model has little basis to separate source content from system policy.
Good retrieval prompts state the role of retrieved text in plain terms. For example, label passages as untrusted source material and forbid them from altering system rules. This does not solve the problem by itself, but it improves your odds when combined with tool and authority limits.
Memory systems need the same discipline. If an agent writes user-provided content or model inferences into long-term memory, those entries influence future sessions. Review what gets persisted, who can write it, how it expires, and whether sensitive instructions or decisions end up there. A poisoned memory entry lasts longer than a single chat turn.
What to watch next
The next shift is from prompt engineering to policy engineering. More teams now accept that a single system prompt is not a security control. The stronger pattern is layered design, narrow permissions, typed tool interfaces, and repeatable adversarial testing.
If you build with LLMs, watch for two changes in your own stack. First, more hidden prompt paths as you connect files, search, and agents. Second, more pressure to let models take action. Those two trends together raise the stakes. Review the boundaries before the feature reaches production.