-
-
Masked prompt sent to Gemini: real names, company, city, and pay stay local while only [TOKENS] reach the cloud.
-
Multi-turn chat protection with live Side Panel metrics tracking protected prompts, masked secrets, and scan activity.
-
Live 0ms detection pill flags secrets in Gemini as you type, paired with the ZeroLeak Privacy report side panel.
-
Step 2: Opt-in Cloud Mosaic Audit checks only masked tokens via Firebase AI Logic for indirect re-identification risk.
-
Step 1: On-device Gemini Nano intercepts Send and masks sensitive entities locally into reversible placeholders.
Inspiration
Every day, engineers, doctors, HR managers, and founders paste production credentials, patient notes, salary figures, and client contracts straight into ChatGPT, Gemini, and Claude just to summarize a paragraph or fix a bug. Once that prompt leaves the browser, sensitive data is out of your control—yet turning off AI altogether isn't realistic. We built ZeroLeak to give people a seamless privacy firewall right inside Chrome: sanitize locally before anything leaves the browser, consult the cloud only with consent and masked tokens, and restore the real words automatically when the reply comes back.
What it does
ZeroLeak is a Manifest V3 Chrome Extension (plus a live Firebase Hosting test sandbox) that protects AI chatboxes in three automatic steps:
- Step 1 — Flag & Mask Locally (
PREFER_ON_DEVICE): Combines a 0ms local structural & watchlist guard (API keys, DB URIs, private IPs, PAN, Aadhaar, SSN, IFSC, UPI handles, emails, phone numbers, currencies, clinical dosages/PHI) with on-device Gemini Nano semantic extraction via Firebase AI Logic. Detected secrets are replaced locally with reversible tokens ([PERSON_1],[ORG_1],[AMOUNT_1],[SECRET_1]), supporting both context-rich masking (e.g.,[AMOUNT_1 (~few thousand INR)]so the external LLM still gives high-relevance answers) and exact tokens. Your secret vault never leaves your browser. - Step 2 — Explicit Consent Gate & Cloud Mosaic Audit (
ONLY_IN_CLOUD): InterceptsEnter, Send button clicks, and form submits across AI chat sites so you can review every flagged item first. Optionally clicking Check masked draft in cloud sends only the already-masked placeholders (never raw words) to Gemini (gemini-3.5-flash-lite) to catch indirect re-identification risks ("mosaic risk") and refine the draft while preserving every[TOKEN]. - Step 3 — Local Auto-Restoration:
Watches streamed assistant replies in the DOM and swaps placeholders back into the original text right on your screen, showing a confirmation toast (
Restored N secret(s) locally).
Alongside interception, the ZeroLeak Side Panel provides a live Privacy report with per-scan latency, engine transparency (On device, Cloud fallback, Cloud check, Local rules), a Download Gemini Nano warm-up control, and a Watchlist for custom confidential terms.
How we built it
- Hybrid AI Engine (
src/ai/): Uses Firebase AI Logic (firebase/ai) withInferenceMode.PREFER_ON_DEVICE(backed by Chrome's Prompt API / Gemini Nano) for local semantic entity extraction andInferenceMode.ONLY_IN_CLOUD(gemini-3.5-flash-lite) for opt-in Mosaic Auditing, paired with our 0ms deterministic guard and fuzzy substring matcher (src/shared/masking.ts). - Manifest V3 Extension Architecture (
src/background/,src/offscreen/,src/content/): Runs Firebase AI Logic safely inside an MV3 Offscreen Document (offscreen.html) so strict website Content Security Policies never block AI calls; scopes content script injection strictly to AI chat platforms (ChatGPT, Gemini, AI Studio, NotebookLM, Claude, Perplexity, Copilot, DeepSeek, Grok, Poe, Mistral Le Chat, HuggingChat) and the ZeroLeak sandbox. - Firebase Ecosystem (
src/firebase/):- App Check (
ReCaptchaV3Provider) & Anonymous Auth to secure backend calls and user-scoped preferences. - Cloud Firestore with strict security rules (
users/{uid}) storing only user-defined custom Watchlist keywords and anonymized integer counters—raw prompts and token maps are never uploaded. - Remote Config for live sensitivity (
standard/strict), model routing, and Mosaic Audit feature flags. - Firebase Hosting serving the interactive web sandbox (
https://zeroleak-hybrid-26.web.app).
- App Check (
- UI (
src/sidepanel/,public/review.css): Built with React 19, TypeScript, Vite 6, Tailwind CSS v4, and Lucide Icons.
Challenges we ran into
- On-device Nano concurrency & grammar stalls: Firing background typing scans every few hundred milliseconds queued multiple local Gemini Nano sessions, driving latency up to 15–20 seconds, and Chrome's constrained JSON grammar occasionally rejected complex schemas without triggering cloud fallback automatically. We solved this with a non-congesting queue gate, a lean multi-domain prompt, and a 3-tier resilient cascade (structured Nano → unconstrained Nano → explicit Cloud Fallback) that never auto-sends unmasked text on timeout or error.
- Dynamic SPA editors & streamed DOM restoration: ChatGPT, Gemini, and Claude render prompts in React/ProseMirror/Quill editors, assign new conversation URLs after the first message, and stream responses across split
<span>/<code>nodes. We built route-aware vault carry-over (syncConversation) and a multi-pass DOM stitcher so placeholders inside code blocks and prose still restore cleanly. - Precision without false positives: Avoiding misclassifications (like flagging salary figures or API key digits as phone numbers, or intercepting non-AI web forms) required priority-ranked entity merging, structural context rules, and strict AI-host allowlisting.
Accomplishments that we're proud of
- True hybrid AI privacy in production: local-first protection powered by Gemini Nano and Firebase AI Logic that still preserves prompt usefulness via context-rich tokens and seamless round-trip restoration.
- End-to-end zero-knowledge Firestore architecture backed by strict
firestore.ruleswhere no raw prompt or secret mapping ever touches cloud storage. - Works seamlessly across major AI chat interfaces (ChatGPT, Gemini, Claude, Perplexity, and more) in English, Hinglish, code/DevOps logs, healthcare notes, and financial drafts.
What we learned
- Hybrid AI UX is as much about queue scheduling, timeout safety, and fallback ergonomics as prompt engineering—small on-device models excel when given tight, high-signal schemas without contention.
- Protecting users in real workflows requires meeting them directly inside the text boxes they already use every day without breaking rich editors or non-AI forms.
What's next for ZeroLeak — Hybrid AI Privacy Firewall
- Support for document & attachment scanning (PDF/CSV/image OCR before upload) using multimodal on-device/hybrid checks.
- Enterprise policy packs managed via Firebase Remote Config for team-wide compliance presets (HIPAA/PHI, SOC2 credentials, financial/legal).
- One-click Chrome Web Store release and customizable per-category masking policies.
Built With
- chrome
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-auth
- firebase-hosting
- firebase-remote-config
- firestore
- gemini
- gemini-nano
- google-cloud
- react
- tailwindcss
- typescript
- vite