PrivacyFirewall (Local AI Privacy Shield / Local LLM DLP)
β 100+ stars in 24 hours | π΄ 7 forks | π₯ Trending
"Solves a major security concern" β Security Professional "Very elegant and impressive solution" β LinkedIn User
π If you're trying PrivacyFirewall, please star the repo!
It helps others discover the project and motivates development. Takes 2 seconds β β (top right)
PrivacyFirewall is a local-first PII and secrets firewall for AI tools like ChatGPT, Claude, and Gemini.It blocks risky paste events, warns as you type, and (optionally) uses a lightweight on-device Transformer model for deeper PII detection.
π **No data ever leaves your machine.**Everything runs locally in your browser or through an optional local API.You can verify this by inspecting the network panel and reading the open-source code.
π¨ Why This Project Exists
Modern AI tools make it extremely easy to leak sensitive information:
-
Emails & phone numbers
-
API keys & credentials
-
Customer or employee data
-
IP & MAC address
-
Internal logs & stack traces
-
Regulated personal information (PII/PHI)
Traditional enterprise DLP tools donβt cover AI chat prompts.
PrivacyFirewall adds a zero-trust privacy shield BEFORE your text ever reaches a third-party AI system.
What PrivacyFirewall gives you:
-
β Human-in-the-loop protection for accidental leaks
-
π 100% local processing (browser + localhost only)
-
β‘ Practical protection (regex + optional transformer NER)
-
π§© Friendly UX (warnings, paste-block modals, override options)
-
π OSS and auditable (MV3 + FastAPI + Hugging Face stack)
π§ How It Works
Two Layers of Protection
-
**Lite Mode (regex-only)**Runs instantly in the extension β no setup needed.
-
**AI Mode (optional, local LLM)**Uses a local FastAPI agent + transformer model for deeper detection(People, organizations, locations, contextual entities).
High-level architecture
graph TD
A[User Pastes/Types Text]:::blueNode -->|Intercept| B(Chrome Extension):::blueNode
B -->|Regex Check| C{Contains Secrets/PII?}
C -->|Yes & Paste| D[BLOCK & WARN]:::redNode
C -->|Yes & Typing| E[SHOW WARNING BANNER]:::redNode
C -->|No| F{Local Engine Online?}
F -->|No| G[Allow]:::blueNode
F -->|Yes| H[Python Local Engine]:::blueNode
H -->|BERT Model| I{AI Detected PII?}
I -->|Yes & Paste| D
I -->|Yes & Typing| E
I -->|No| G
classDef blueNode fill:#2563eb,stroke:#1e40af,color:#fff
classDef redNode fill:#dc2626,stroke:#b91c1c,color:#fff
-
Regex Mode covers secrets quickly
-
AI Mode enhances detection when the local engine is running
-
If the agent goes offline β extension falls back automatically
π Quickstart (Local Development)
Prerequisites
-
Python 3.10+
-
Chrome/Chromium/Edge
-
Git
1) Clone
$ git clone https://github.com/privacyshield-ai/privacy-firewall.git
$ cd privacy-firewall
2) Run the Local Engine (optional for AI Mode)
$ cd src/engine python -m venv .venv
$ source .venv/bin/activate # Windows: .venv\Scripts\activate
$ pip install --upgrade
$ pip install -r requirements.txt
$ uvicorn main:app --host 127.0.0.1 --port 8765
-
First run downloads dslim/bert-base-NER (~400MB) to ~/.cache/huggingface.
-
http://127.0.0.1:8765/health β {"status":"ok"}
3) Install the Chrome Extension
-
Visit: chrome://extensions
-
Enable Developer mode
-
Click Load unpacked
-
Select: src/extension/
You now have Lite Mode running with regex-based detection.
4) Try It Out
Go to:
Paste:
My email is john.doe@example.com `
β Paste is intercepted, modal appears.
Paste:
β Detected as AWS key β blocked.
Enable AI Mode (when popup UI is ready), type:
Meeting notes from Sarah Thompson at HR...
β Local transformer flags PERSON β warns you.
π Detection Coverage
Regex Mode (Fast, Offline, Default)
-
Email address
-
Phone number
-
Credit card candidate
-
MAC address
-
IPv4 address
-
AWS access keys
-
JWT tokens
-
Private key blocks
-
Generic API key / hash patterns
-
US SSN (basic pattern)
AI Mode (Local Transformer)
Powered by dslim/bert-base-NER:
-
PERSON
-
ORGANIZATION
-
LOCATION
-
Additional named entities
-
Helpful for ambiguous or context-based leakage
π Project Layout
π§ͺ Development
Run Detection Tests
src/extension/ Chrome MV3 extension (content script, background worker, UI assets)
src/engine/ FastAPI service + transformer model wrapper
src/engine/models/ Model utilities (Hugging Face pipeline)
src/engine/tests/ Basic test harness for detection
Model & Cache Notes
-
HuggingFace models live in ~/.cache/huggingface/
-
Delete this directory to force a fresh download
π οΈ Future Improvements
-
Extension settings UI (enable/disable regex/AI modes)
-
Add per-site allow/deny lists
-
Add secret-type redaction instead of full block
-
Package engine as a binary or desktop app
-
Explore transformer.js for in-browser inference.
-
Automated CI + browser testing
β Troubleshooting
βEngine Offlineβ Banner
-
Ensure the Python engine is running
-
Confirm nothing else uses port 8765
-
Lite mode will still block regex-based secrets
βIt didnβt flag a name I typedβ
-
Ensure AI Mode is enabled + engine is online
-
NER models are probabilistic; long names work best
-
Confidence threshold is tunable in transformer_detector.py
π€ Contributing
PRs and issues are welcome!Please include:
-
OS & browser version
-
Reproduction steps
-
Model version (if reporting AI false positives/negatives)
π Security & Privacy Notes
-
No prompts or text ever leave your machine
-
Extension communicates only with:
-
Browser local context
-
Optional localhost API at 127.0.0.1:8765
-
-
No analytics, telemetry, or external logging
-
Review src/extension/content-script.js and DevTools β Network tabto verify behavior
π License
MIT License.See LICENSE for full text.
