All posts

Prompt injection is an architecture problem

OWASP’s 2025 Top 10 for LLM Applications ranks prompt injection first. I spent a semester working out why, and wrote it up as a survey: Hijacking the Prompt: A Survey of Prompt Injection Attacks, Detection, and Defense in Large Language Models (opens in a new tab), published through ODU Digital Commons under COVA CCI.

The short version fits in one line from the paper: “transformer-based LLMs treat all context window content as equally authoritative.”

Your system prompt, the user’s question, the PDF they uploaded, and the web page an agent just fetched all reach the model as the same thing. Tokens. Nothing in the architecture marks which of them is allowed to give orders. Everything else in the paper follows from that.

How the attacks get in

I drew on 18 primary sources from 2023 to 2025 and grouped the attacks into six vectors:

  • Direct injection, where the user types the attack.
  • Indirect injection, where the attack sits in content the model reads: an email, a document, a web page.
  • Multimodal attacks, where the instructions ride in an image or other non-text input.
  • Tool and agent exploitation, which targets what the model is allowed to do.
  • Hybrid chained techniques that combine several of the above.
  • Autonomous propagating threats, where injected content spreads from one system to the next.

The impacts sort into five categories: data exfiltration, unauthorized actions, content manipulation, system compromise, and supply chain propagation.

The last few vectors are where agents change the stakes. A chatbot that says something wrong is embarrassing. An agent with mailbox access that does something wrong is an incident.

Detection is a stack of partial answers

The paper compares five detection approaches: heuristic methods, machine learning classification, perplexity analysis, canary tokens, and LLM-as-judge architectures.

Each one covers a different gap, and each one has its own. Pattern matching catches known phrasing and misses a paraphrase. A judge model is still a model reading untrusted text. That is why the paper’s recommendation is layered, adaptive defense at the model, application, and system levels, not a single filter.

Then I built one

Reading about detection is different from writing it. I built a Python and Flask classifier that matches 13 prompt injection signatures against a six-category taxonomy, with 83 passing pytest tests. You can try it in the public playground (opens in a new tab).

It is a heuristic classifier, so it has the weaknesses described above. Writing the signatures is a fast way to find out exactly where pattern matching breaks.

The paper ends on open problems, not a fix. Until models can tell an instruction from a sentence, every document an agent reads is a possible set of orders.