prompt-firewall
Local, zero-dependency guardrail for LLM apps. Catch leaking API keys / secrets, PII (credit cards validated by Luhn, India Aadhaar validated by Verhoeff, SSN, email, phone, IP) and prompt-injection attempts — before the text is sent to an LLM, logged, or stored. Pure regex + checksum math: no network calls, sub-millisecond, nothing leaves the host.
npm i prompt-firewall # Node >= 12
pip install prompt-firewall # Python >= 3.8
Quickstart (JS)
const { guard, redact, scan } = require('prompt-firewall');
guard(userInput); // throws FirewallBlocked on a card / key / injection
const clean = redact(userInput); // or mask findings and continue
const report = scan(userInput); // or inspect: report.findings, report.blocked, report.safe
Quickstart (Python)
from prompt_firewall import guard, redact, scan, FirewallBlocked
try:
guard(user_input) # raises on high/critical findings
except FirewallBlocked as e:
for f in e.result.findings:
print(f.rule, f.severity, f.start, f.end)
clean = redact(user_input) # "[REDACTED:credit_card] ..."
Why it's real (not just regex)
- Credit cards are confirmed with the Luhn checksum, so a random 16-digit order number is not flagged — far fewer false positives than naive regex scanners.
- Aadhaar numbers are confirmed with the Verhoeff checksum (the real algorithm UIDAI uses).
- Secret patterns cover current formats:
sk-…,sk-ant-…,AKIA…/ASIA…,ghp_…,xox…,AIza…, PEM private-key blocks, JWTs. - Findings carry exact
start/endoffsets and a severity, so you can redact precisely.
Open-core
- Free (MIT): all detectors above,
scan/redact/guard, custom signatures. - Pro (threat-signatures pack): ship curated, versioned signature sets (new jailbreak
phrasings, cloud-vendor tokens, regional IDs) and load them with
scan(text, {extraSignatures}). Sell the maintained pack + updates; the loader is free.
Tests
cd npm && node test/test.js # 13 tests
cd pypi && python3 tests/test_firewall.py # 12 tests
Honest limits
Regex/heuristic detection is best-effort: it will miss novel obfuscations and can false-positive on odd text. Treat it as a fast first layer, not a complete security boundary. No ML, no guarantee of catching every injection — by design it is deterministic, auditable and offline.
License
MIT.
Metadata
Release files for pii-prompt-firewall 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pii_prompt_firewall-0.1.0.tar.gz | 7.2 kB | Without provenance | Details for pii_prompt_firewall-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pii_prompt_firewall-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pii_prompt_firewall-0.1.0-py3-none-any.whl |
Total release size: 13.6 kB
Release files / pii_prompt_firewall-0.1.0.tar.gz
| Download URL | pii_prompt_firewall-0.1.0.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c4e587a9e45e6f0fecf18a39f45affd6581193247db87d270ab3bfe09cb0e1e
|
|
BLAKE2b-256 checksum How to use checksums |
fd35c79e14347a76269151a30a59183953b12d3fc50bf44899bf495bee22a5ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / pii_prompt_firewall-0.1.0-py3-none-any.whl
| Download URL | pii_prompt_firewall-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c85507e396990b2152b63ce896953cbed1259535da734cc809d060ba038f11a1
|
|
BLAKE2b-256 checksum How to use checksums |
a02ffea8c01e70da64061a27a780d6a515e5e0611836f4f945636e675c4b9d70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Security for pii-prompt-firewall 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.