Building an LLM Firewall: Catching PII and Injection via Regex and Luhn

GiiTZzz · reddit · 2026-08-09

The author shares their custom LLM firewall solution, deploying a proxy layer that uses regex for SSN and email patterns, Luhn validation for credit cards, and a blocklist of injection phrases to intercept requests before they reach the model provider.

The post highlights the tradeoff between false positives and false negatives: strict rules block normal conversations, while loose rules risk actual leaks. The author released a live demo and seeks community input on production experiences regarding I/O scanning and choosing between regex versus classifiers.

Original post →

More from coding & agent

coding & agent channel →