CoolFace
Apppublic

justinarndt/certified-phi-egress-firewall

sourceHugging Faceapache-2.0updated 4mo agoView on Hugging Face
0likes
App README

<div align="center">

πŸ›‘οΈ Certified Micro-Agent: HIPAA PHI Egress Firewall

v1.0.0 β€” Hybrid NLP + Regex | 14/18 HIPAA Safe Harbor Identifiers | CPU-only

![HIPAA](./validationpackage/SOC2HIPAATraceability.md) [![SOC 2](https://img.shields.io/badge/SOC%202-CC6.1%20%7C%20CC6.7-green?style=for-the-badge)](./validationpackage/SOC2HIPAATraceability.md) ![Validation](./validation_package/) ![License](./LICENSE) ![Python](https://python.org) ![Live Demo](https://huggingface.co/spaces/justinarndt/certified-phi-egress-firewall)

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

PassMethodSafe Harbor Identifiers Covered
RegexDeterministicSSN (#7), Phone (#4), Fax (#5), Email (#6), MRN (#8), NPI, DOB (#3), IP Address (#15), URL (#14), ZIP (#2-partial), Account # (#10)
NERspaCy encoreweb_smNames (#1), Geographic data (#2), Organizations (#2-partial), Facilities
GuardrailDensity scoringBlocks bulk PHI dumps before they route

14 of 18 Safe Harbor identifiers covered. Full mapping in `SOC2_HIPAA_Traceability.md`.


Sample Audit Trail Output

json
{
  "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

DocumentDescriptionFramework
`IQ_Report.md`Installation Qualification β€” dependencies, model hash, file integrityGAMP 5 IQ
`OQ_Test_Matrix_HIPAA_18.csv`OQ matrix covering all 18 Safe Harbor identifiers β€” documents FN rate < 0.1%GAMP 5 OQ
`SOC2_HIPAA_Traceability.md`Field-by-field mapping to HIPAA Β§ 164.312 and SOC 2 CC6.1 / CC6.7HIPAA / SOC 2

Quick Start

bash
# 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:7860

Requirements

pydantic>=2.9.0
spacy>=3.7.4
psutil>=5.9.8

Gradio 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.
ConcernCloud DLP / LLM ApproachThis Agent
PHI sent externally?Yes (to Google DLP, AWS Comprehend Medical)Never
Cost per call$0.001–$0.05~$0.00009
Latency200–2000 ms< 25 ms
False negative risk~3% (LLM "laziness")< 0.1% (deterministic)
Audit trailVendor-controlledFull cryptographic JSON
Air-gap compatibleNoYes

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>