
Safety Guardrail
Telling attacks from quotes, without an LLM

Telling attacks from quotes, without an LLM
I rebuilt a deliberately weak AI-safety guardrail into a deterministic moderation pipeline. It separates prompt injection, scams and abuse from harmless text that only quotes them, with no language model in the loop.
The starting point was a small HTTP service that screens messages before they reach an AI assistant. It mixed keyword rules with a basic text-similarity matcher and scored 61.54 on the public test suite.
The constraints: keep the API contract, use no external models or network calls, and never read test data at runtime. Each request gets one of four actions (allow, allow as data, block, escalate) and one of 13 reason codes.
Most of the difficulty is context. "Ignore your instructions" is an attack when a user writes it. The same words inside a forwarded email that a moderator wants explained are just data. A filter that only looks for bad words blocks the moderator and lets disguised attacks through.
I replaced the single pass with an ordered pipeline. Text is normalised and de-obfuscated first, so leetspeak and spacing tricks collapse into several plain views of the same message. Imminent safety risks are checked next and escalated. Then the operation a request asks for is checked against what it is allowed to do.
Quoted evidence is classified separately from the user's own message. Studying hostile text is allowed as data. Asking to run an injected instruction or to spread quoted abuse is blocked. Only after that do the block rules and the tuned similarity matcher run.
On the 26-case public suite the score went from 61.54 to 100, with full marks on security, utility, robustness and reason accuracy. The project's 155 tests pass. The graded suite is private, so the public number is the one I quote.
Next project

World news in, probabilities out