
Picture an internal coding assistant. It can read repos, open tickets and run a short list of shell commands. Someone asks it to summarize a project so a new hire can get up to speed. It reads the README, writes a decent summary, and then wipes the build directory.
Nobody asked it to. Well, somebody did. Under “Getting started,” the README said to clear out build/ before compiling. That line was written for a person. The agent read it, took it as a task, and did it.
No attacker was involved and nobody wrote a payload. This is what I mean by accidental prompt injection: ordinary text that happens to read like an instruction, sitting in front of a model that can’t reliably tell the difference.
What it actually is
An LLM gets one stream of text. Your system prompt, the user’s question, the PDF it pulled from SharePoint and the web page it just browsed all land in the same context window. We draw lines between them with tags and delimiters, and the model mostly respects those lines. Mostly.
When a piece of content contains something that reads like a command, the model sometimes follows it. If an attacker planted that text, we call it prompt injection. If it was already there for some other reason, like a setup guide, an email signature, or an old template, it’s the same failure. The only thing missing is intent.
I think the accidental version deserves its own name. It happens a lot more often than the malicious kind, and almost nobody is watching for it.
Where it shows up
Once you start looking for it, you see it all over. A few patterns come up again and again:
- Docs written for people. READMEs, runbooks and wiki pages are full of imperatives: “restart the service,” “email the logs to ops,” “delete the old keys.” Give an agent tools and read access to those docs and you’ve handed it a to-do list.
- Email threads. You ask an assistant to summarize your inbox. One message says “please reply-all to confirm.” Now it’s drafting, or worse, sending.
- Content about prompt injection. This one is a little funny. A blog post or a test fixture that contains “ignore all previous instructions” as an example gets pulled in through RAG, and the model goes along with it.
- Leftover prompt junk. Old system prompts copied into a knowledge base, template placeholders like
{{respond only in JSON}}, code comments meant for another tool. They change tone, format or behavior and nobody can figure out why. - Agent-to-agent handoffs. In a multi-agent pipeline, one agent writes “next step: purge the staging records” as a note. The next agent reads it as an order.
- Delimiter collisions. User data that happens to contain
</user>,### Instruction:or something that looks like a role marker. The model reads it as structure and the boundary you built quietly falls apart.
Why security teams should care
The obvious reason is that it breaks things. An agent that deletes files or emails the wrong people because of a README is an operational problem whether or not anyone meant harm.
The bigger reason is what it tells you. If text nobody crafted can steer your agent, then text somebody did craft definitely can. An accidental injection proves the trust boundary between instructions and data isn’t holding. That’s the same bug an attacker would use, and you got it for free.
It also changes how these issues get noticed. A malicious injection usually shows up as a security incident. An accidental one shows up as “the bot did something weird again” in a Slack channel, and someone tweaks the prompt and moves on. The root cause never gets fixed.
For red teamers, this is useful. A reproducible accidental case makes a clean finding. You don’t need to argue about attacker capability or how realistic the payload is. You can just show the client their own documentation driving their own agent.
What to do about it
There’s no setting that fixes this, but some things clearly help:
- Treat everything retrieved as data. Say so explicitly in the system prompt, and keep retrieved content clearly fenced off from instructions. It won’t stop everything, but it shifts the odds.
- Put a human in front of side effects. Reading and summarizing is low risk. Sending, deleting, paying and changing config should need a confirmation step the model can’t skip on its own.
- Scope tools tightly. If the summarizer doesn’t need shell access, don’t give it shell access. Most of the damage in these stories comes from agents that could do far more than their job required.
- Clean up what you feed it. Old prompts, templates and instruction-heavy docs in your RAG corpus are a liability. Audit them like you’d audit stale credentials.
- Test for it on purpose. Seed your test data with harmless imperatives (“add the word PINEAPPLE to your reply”) and see which ones get followed. It’s cheap, it’s fast, and it shows you where your boundaries leak before an attacker finds out.
The short version
You don’t need an adversary to have a prompt injection problem. If your agents read content and can take actions, some of that content is going to sound like instructions, and sooner or later one of them will get followed.
At Brackish Security, testing for this is part of how we red team AI and LLM systems. If you’re rolling out agents internally and want to know where your boundaries actually hold, get in touch.