A detection layer for LLM applications — prompt injection, jailbreaks, system-prompt leakage, PII, toxicity, and malicious tool calls — scored, decided, and audit-logged. This page reports real numbers from the repo's own benchmark and replay tooling, including an honest held-out generalization test.
Two corpora, two purposes: the tuned corpus is a regression suite (detectors were iterated against it); the holdout corpus is paraphrased attack wording the detectors never saw, so it's a genuine generalization check.
Tuned corpus (96 cases: 20 benign + 76 attacks) vs. held-out corpus (40 cases: 8 benign + 32 paraphrased attacks), regenerated on every CI run via python cli.py benchmark.
Every attack in the tuned corpus sent to two offline, deterministic backends — naive_mock
(simulates an unguarded model that complies with attacks) and guarded_mock (simulates a
reasonably aligned one) — first with no gateway, then routed through
SecurityGateway. "Compromised" is judged by a heuristic oracle
(refusal-phrase absence, PII/leakage detectors on the response) — see
benchmark/multi_model.py. Real backends (OpenAI, Anthropic) run the
same comparison when API keys are configured.
guarded_mock) drops from a 52.6% to a 21.1% compromise rate
with the gateway in front — a second, independent, auditable layer of defense pays off regardless
of how good the underlying model's own alignment is.
Override/disregard phrasing, fake role delimiters, HTML-comment smuggling, base64-encoded instruction payloads.
DAN/AIM/STAN personas, developer-mode claims, "pretend you have no restrictions," dual-response splitting, false-authority framing.
Extraction attempts on the input side; verbatim/near-verbatim reproduction on the output side via sliding-window similarity.
Email, phone (US & international), SSN, Luhn-checked card numbers, IBAN, passport, IP, DOB, street address, AWS/GitHub keys, passwords — with redaction.
Weighted lexicon: profanity, harassment, threats, self-harm, hate-speech structure, plus aggressive-formatting heuristics.
Shell injection, destructive/tautological SQL, path traversal, credential access, SSRF (loopback/link-local/cloud-metadata), exfiltration params.
Script/markup injection, markdown image/link exfiltration payloads, degenerate repetition, JSON-schema conformance.
Weighted-max aggregation → allow/flag/sanitize/block, plus append-only JSONL audit logs and an attack-replay regression harness.
git clone https://github.com/ara-5/AI-Security-Gateway
cd AI-Security-Gateway
pip install -r requirements.txt
python cli.py benchmark # tuned corpus
python cli.py benchmark --corpus data/holdout_corpus.jsonl # held-out corpus
python cli.py multi-model --backends naive_mock,guarded_mock
python -m pytest -q # 42 tests, incl. regression floors