justinarndt/certified-phi-egress-firewall
<div align="center">
π‘οΈ Certified Micro-Agent: HIPAA PHI Egress Firewall
v1.0.0 β Hybrid NLP + Regex | 14/18 HIPAA Safe Harbor Identifiers | CPU-only
 [](./validationpackage/SOC2HIPAATraceability.md)    
A CPU-bound, deterministic egress firewall that intercepts outbound LLM API calls, redacts Protected Health Information (PHI) in < 25 ms, and writes a cryptographic audit trail.
The #1 blocker to enterprise LLM adoption: "Staff will paste patient data into ChatGPT." This agent eliminates that risk entirely.
</div>
The Problem
Every hospital, payer, and health-tech startup faces the same CISO objection before adopting generative AI:
"We can't use ChatGPT/Claude/Gemini because our clinical staff will accidentally paste PHI into the prompt."
A single HIPAA violation involving AI-assisted tools costs $1.9M on average in OCR settlements. Traditional DLP tools are signature-based and miss free-text clinical notes entirely.
The Solution β Defense in Depth
Internal Staff Prompt (CONTAINS PHI)
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β engine.py (PHIFirewall) β
β β
β PASS 1 β Regex (structured identifiers) β
β SSN Β· Phone Β· Fax Β· Email Β· MRN Β· NPI Β· DOB β
β IP Address Β· URL Β· ZIP Code Β· Account Number β
β β
β PASS 2 β spaCy NER (en_core_web_sm, ~12 MB, CPU-only) β
β PERSON β [NAME_REDACTED] β
β GPE / LOC β [LOCATION_REDACTED] β
β ORG / FAC β [ORGANIZATION_REDACTED] β
β β
β PASS 3 β Density Guardrail β
β PHI chars / total chars > 35% β BLOCKED_HIGH_PHI_DENSITYβ
β Routes to InfoSec / Privacy Officer β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β Scrubbed Payload β β HIPAA Audit Trail (JSON) β
β β OpenAI / Anthropic β β β SIEM / Audit DB β
βββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββZero external API calls. Zero cloud NLP. Runs fully air-gapped.
HIPAA Safe Harbor Coverage
14 of 18 Safe Harbor identifiers covered. Full mapping in `SOC2_HIPAA_Traceability.md`.
Sample Audit Trail Output
{
"schema_version": "1.0",
"agent_name": "HIPAA-PHI-Egress-Firewall",
"execution_id": "f4a2c819-...",
"timestamp_utc": "2026-05-13T17:00:00+00:00",
"input_sha256": "a3f9c12e...",
"scrubbed_sha256": "b7d4e91f...",
"summary": {
"total_redactions": 6,
"entity_counts": {"SSN": 1, "PHONE": 1, "MRN": 1, "DOB": 1, "NAME": 1, "LOCATION": 1},
"phi_density_score": 0.12,
"action_taken": "CLEARED_FOR_EGRESS"
},
"redactions": [
{
"entity_category": "NAME",
"redaction_method": "NER_en_core_web_sm",
"start_char": 42,
"end_char": 54,
"replacement_token": "[NAME_REDACTED]"
}
],
"execution_metadata": {
"runtime_ms": 18.4,
"peak_ram_mb": 142.7,
"nlp_model": "spacy_en_core_web_sm"
}
}Validation Package
Quick Start
# 1. Clone
git clone https://github.com/j-arndt/certified-phi-egress-firewall
cd certified-phi-egress-firewall
# 2. Install
pip install -r requirements.txt
pip install "gradio>=5.0.0" # managed by sdk_version on HF Spaces
# 3. Download NLP model (auto-downloads on first engine.py run)
python -m spacy download en_core_web_sm
# 4. CLI smoke test
python engine.py
# 5. Launch UI
python app.py
# β http://localhost:7860Requirements
pydantic>=2.9.0
spacy>=3.7.4
psutil>=5.9.8Gradio managed via sdk_version: 5.29.0 on HuggingFace Spaces. Python >= 3.10 | No GPU required | Runs on any laptop or air-gapped server
Design Philosophy
We do not send PHI to a cloud NLP service to detect PHI. That defeats the purpose.
License
Apache 2.0 β see `LICENSE`
<div align="center"> Built by <strong>Justin Arndt</strong><br> 10 years Lancaster General Health / Penn Medicine Β· 18+ years GxP / CSV / QA<br> <a href="https://github.com/j-arndt">GitHub</a> </div>
