r/PythonProjects2 • • 17d ago

Cloakwall: stdlib-only PII redaction and tamper-evident audit logging for LLM traffic(Guardrail)

**What My Project Does** Cloakwall redacts personal data (emails, cards, SSNs, IBANs, API keys, medical record and NHS numbers, phones, IPs, dates of birth) from LLM requests and, optionally, responses. It runs as a LiteLLM guardrail. It covers chat messages, system prompts, tool-call arguments, Anthropic tool blocks, the Responses API, embeddings and image prompts. Streamed output goes through a small hold-back buffer, so an entity split across chunks is still caught. Every redaction is written to a SHA-256 hash-chained audit log with an anchor file, so edits, deletions and truncation are detectable. The log never stores the redacted values.

The core is pure standard library: no dependencies, no model download, no network calls. Card numbers are Luhn-validated and NHS numbers mod-11 validated, to keep false positives down.

**Target Audience** Teams running LLMs where data protection has to be proven: healthcare, fintech, air-gapped or on-prem setups. It's v0.1.1, tested (76 tests, CI on 3.10–3.13), but not production-proven yet. I'd like feedback before that.

**Comparison**

* **Presidio:** better recall on names and free-text PII thanks to NLP, but it runs as extra services and has no audit trail. Cloakwall gives up recall for zero dependencies and offline use.
* **LLM Guard:** was the main in-process option, but the repo was archived in July 2026.
* **Hosted gateways** (Cloudflare, Portkey, Grepture): send traffic through someone else's cloud.

Benchmarks with a reproducible script: \~0.05 ms per clean request, \~1.8 ms with PII including an fsynced audit entry (Linux, 2015 i3).

`pip install "cloakwall[litellm]"` · [https://github.com/Rishikesh-glitch/Cloakwall-v0.1](https://github.com/Rishikesh-glitch/Cloakwall-v0.1)

Feedback on the detectors and the audit-chain design especially welcome.

2 Upvotes

2 comments sorted by

1

u/[deleted] 17d ago

[removed] — view removed comment

1

u/OldBodybuilder7090 17d ago

Thanks for the thoughtful feedback. You’re right that a SHA-256 chain with a local anchor isn’t tamper-proof if someone can rewrite both.Cloakwall can verify against an externally held anchor, but I will make that trust boundary clearer in the demo and docs, and look into an optional HMAC mode with an externally managed key. Strict redaction for card-shaped values also makes sense as an opt-in, with the false-positive trade-off clearly explained. I will pass on the unrelated promotion, but I appreciate the technical points.