Blog / · 12 min read · By the Clawmont team

Prompt Injection Detection: How Pattern Matching, Classifiers, and LLM Judges Compare

Every prompt injection detector makes the same trade three ways: how much it catches, how often it cries wolf, and what each decision costs. Understanding that triangle is the difference between buying a control and buying a demo.

The short version

Prompt injection detection methods fall into three families. Deterministic checks match known attack structure: fast, predictable, cheap, and bounded by what they encode. Machine-learning classifiers generalize further but introduce false-positive risk that compounds at agent scale. LLM judges reason about intent with the most flexibility and the highest latency and cost.

For tool-using agents the detection question also moves: it is no longer only "is this text an attack?" but "is this action, caused by that text, safe?" That is why modern defenses run at multiple boundaries of the agent loop instead of only screening the user's message.

Citable answer

Prompt injection detection uses three method families: deterministic pattern checks (fast, predictable, bounded), ML classifiers (broader generalization, false-positive risk), and LLM judges (intent-level reasoning, latency and cost). No family detects everything, because paraphrase space is unbounded. Layered pipelines that escalate cheap checks to expensive ones, applied at input, tool-call, tool-result, and output boundaries, are the converged pattern for tool-using agents. Clawmont applies this layered model at four boundaries of the OpenClaw agent loop, with zero false positives on its published test set.

The three method families

Deterministic detection encodes known attack structure directly: instruction-override phrasings, encoded payloads, credential-shaped strings, suspicious URL constructions. Its virtues are speed, zero marginal cost, and explainability; when it fires, you can say exactly why. Its limit is equally clear: it recognizes what it encodes, and attackers can rephrase.

Classifier-based detection trains a model to score text as adversarial. Purpose-built classifiers generalize beyond literal patterns and score well on public benchmarks; Meta's PromptGuard 2, the best-known example, reports roughly 97.5 percent on its own injection benchmark. The operational cost is the false-positive rate: a small percentage sounds harmless until an agent runs thousands of checks a day and every false alarm interrupts a human. Alert fatigue is how detection layers get turned off.

LLM-judge detection asks a language model to reason about whether content or a proposed action is adversarial. Judges handle novelty and context best; they are also the slowest and most expensive per decision, and they inherit model failure modes of their own. In practice they work best as an escalation tier for the ambiguous minority of cases, not as the always-on first line.

Direct attacks are the easy case

OWASP ranks prompt injection first in its Top 10 for LLM applications, and its LLM01 taxonomy distinguishes direct injection, typed at the model by the attacker, from indirect injection, planted in content the system reads later. Direct attacks are what most demos test. Indirect attacks are what compromise agents: Unit 42 has documented web-based indirect prompt injection operating in the wild, and the AgentDojo benchmark, along with NIST's AgentDojo-Inspect variant, evaluates exactly this scenario for tool-using agents.

Indirect injection changes the engineering problem. The hostile text arrives mid-task inside a web page, a README, or an MCP tool result, after trust decisions were already made. Screening only user input misses it entirely, which is why detection has to run where content enters the loop and where actions leave it: input, tool call, tool result, and output. Our prompt injection detection guide covers the attack mechanics in more depth.

How to evaluate a detector

01

Define what a detection has to protect

A chat assistant leaking a system prompt and a coding agent about to run a destructive command are different problems. Decide whether you are protecting content, actions, or both; for tool-using agents, actions are what turn injections into incidents.

02

Test against indirect injection, not just pasted attacks

Most public demos test direct attacks typed by a user. Real agent compromises arrive indirectly: instructions hidden in web pages, READMEs, tickets, emails, and tool results. Your evaluation corpus needs both.

03

Measure false positives on your real traffic

A detector that flags three of every hundred benign requests will be disabled within a month by the people it interrupts. Run candidate detectors against a week of real agent traffic and count the interruptions before you trust any recall number.

04

Ask for novel-attack numbers, not just benchmark scores

Every vendor scores well on the corpus they tuned against. Paraphrase space is unbounded, so ask what happens on attacks the detector has never seen, and distrust anyone who will not give a lower second number.

05

Check latency at the boundary you care about

A detector in the tool-call path runs on every action. Deterministic checks cost microseconds; a model-based judge costs hundreds of milliseconds and real money. The right answer is often layered: cheap checks always on, expensive checks reserved for ambiguous cases.

06

Verify the audit trail

When a detection fires, you need what was flagged, at which boundary, why, and what happened next. If the answer to "show me last week's blocks" is a screenshot, the detector is a demo, not a control.

The honesty test

The fastest way to evaluate a detection vendor is to ask for two numbers: the rate on their test corpus, and the rate on attacks the detector has never seen. Everyone has the first number. Serious vendors have the second, it is always lower, and the gap between the two is the honest measure of how much the product depends on having seen the attack before.

The third number that matters is false positives, because it decides whether the detection survives contact with real users. A detector nobody has muted is worth more than a detector with two extra points of recall that drowned its owners in alerts by week two.

Where Clawmont fits

Clawmont applies this layered model to OpenClaw agents: deterministic checks run on every event at all four boundaries of the agent loop, and an optional cost-gated LLM judge escalates the ambiguous cases. We publish our measured detection rates, including the lower novel-attack numbers, on the security page, and hold the line at zero false positives on our published test set because a layer that interrupts honest work gets disabled.

You can watch the detection behavior yourself in the interactive playground preview before installing anything. Clawmont Security is $9.99/mo bundled with a persona or $19.99/mo standalone, with a 7-day free trial; see pricing.

Related reading

Source context

These sources anchor the three claims this post makes: the OWASP taxonomy separates direct from indirect injection, Unit 42 shows indirect injection is a live threat rather than a lab curiosity, and the AgentDojo line of benchmarks measures what actually matters for agents, harmful actions rather than bad answers.

FAQ

What is prompt injection detection?

Prompt injection detection is the practice of identifying instructions that try to override an AI system's intended behavior, whether typed directly by a user or hidden inside content the system reads. For tool-using agents it extends past text screening to the actions the injected instruction produces: the tool call, the destination, and the data being moved.

Which detection method is best?

None alone. Deterministic checks are fast and predictable but bounded by what they encode; classifiers generalize further but carry false-positive risk; LLM judges reason about intent but cost latency and money. Layered pipelines that escalate from cheap to expensive checks are the pattern the field has converged on.

Can prompt injection be detected with 100 percent accuracy?

No, and you should treat any such claim as a red flag. Natural language paraphrase space is unbounded, so every detector generalizes imperfectly to novel attacks. Honest vendors publish both a benchmark rate and a lower novel-attack rate, and design so that misses degrade safely.

Where does Clawmont fit?

Clawmont runs prompt injection detection at four boundaries of an OpenClaw agent: input, tool call, tool result, and output, combining deterministic checks with an optional cost-gated LLM judge for ambiguous cases. Measured detection rates, including the lower novel-attack numbers, are published on the Clawmont security page.