Inspiration
Fresh phishing pages copy real brands pixel for pixel and stay online for hours. Blocklists only know a page once someone has reported it, so the first visitors are on their own. Malicious files hide behind names like invoice.pdf.exe, wrong content types and silent iframe downloads. Most people can't tell a spoofed login from the real one, and they never open the Network tab.
We also noticed a privacy problem hiding inside the fix. A tool that watches every request sees your whole browsing history. Sending that to a server to be analysed is a big ask. On-device models change the equation: fast, private and free to run. But they aren't on every device, which is exactly the gap hybrid inference fills.
What it does
Gatekeeper is a Chrome extension that warns you before you hand credentials to a spoofed site and stops risky downloads.
- Warns before you type. Password, OTP and card fields lock on unfamiliar sites until a verdict arrives. A confident spoof replaces the page with a plain-language warning that shows the brand being copied next to the real domain. "Go back" is the default, and proceeding needs a second confirmation.
- Watches every request. Fast rules run on each request: look-alike and punycode domains, credentials sent to a different website, long redirect chains, hidden iframe downloads, and executables served as documents.
- Pauses risky downloads. Every download is paused on start. Disguised extensions and files whose first bytes don't match their name are held for a Keep or Delete decision with a plain explanation. Gatekeeper judges context only; it is not antivirus.
- Blocks known-bad domains. A domain judged malicious gets a dynamic request-blocking rule, so later requests to it are stopped.
- Shows everything in one place. The dashboard lists everything blocked or flagged with its reason, severity and whether it was judged on-device or in the cloud. It also has per-day statistics, a request log with filters and export, allow and report actions, and a performance panel. The toolbar popup shows the current site's status and a one-click "Why?" explanation.
- Rules in your own words. Type "Block all requests to .xyz websites" and the model returns a validated rule. You preview it, confirm it, and it is enforced deterministically on every site, trusted ones included.
How we built it
Stack: Chrome Manifest V3, TypeScript and Vite, with the Firebase SDK bundled (no remotely hosted code).
Four layers:
- A content script in the tab extracts page signals and locks credential fields.
- A service worker runs the rule engine on every request, routes verdicts, applies dynamic blocking and gatekeeps downloads.
- An offscreen document hosts the Firebase AI Logic SDK, because Gemini Nano needs a window context.
- Extension pages: popup, dashboard, warning screen, download prompt and onboarding.
How we use Firebase AI Logic (all AI goes through src/offscreen/ai.ts):
- Hybrid inference.
InferenceMode.PREFER_ON_DEVICEruns Gemini Nano in Chrome first. A cloud-only route handles low-confidence cases and machines without Nano. - Confidence routing. An on-device result at or above the threshold (0.75 by default) is final. Below it, or without Nano, the page goes to cloud Gemini with a little more context. If both fail, the rule engine decides alone and credential fields stay locked.
- Structured output. Verdicts, explanations and rule translation use JSON schemas on both paths. A parse failure defaults to "suspicious", never "safe". The on-device or cloud badge comes from the SDK's
inferenceSource, not from the model. - Remote Config tunes thresholds, the protected-brand list, an emergency blocklist, risky extensions and the cloud model name without republishing.
- App Check guards the AI calls with limited-use tokens (a debug token in this build, documented in the README).
- Anonymous Auth and Firestore store community reports (domain, verdict and reason only), under write-only security rules.
Security by design. Page text is treated as untrusted data in every prompt. Outputs are schema-validated. A strong rule hit keeps fields locked even if the model answers "safe". Custom rules can add protection but never switch off built-ins. The full threat model and a comparison with blocklists, cloud ML scanning and password managers is in the repo.
Why hybrid is essential, not bolted on. Analysing on-device is the privacy feature. The cloud only ever receives extracted signals for one page, and only when the local model is missing or unsure: never cookies, form values, full URLs or browsing history. The cloud path also keeps Gatekeeper working on machines without Gemini Nano.
Challenges we ran into
- MV3 can't hold a request for an async AI verdict. So instead of delaying every page, Gatekeeper gates the risky moment: typing secrets and starting downloads.
- Cold-start latency. The first on-device call took several seconds while the model loaded. We keep Nano warm while the user is browsing, and send trimmed prompts with only the relevant brands.
- Small models hedge. Nano often answered "suspicious" while flagging a spoof, so a confident spoof with a named brand is now treated as malicious.
- Cloud latency and model quirks. One cloud model never answered for our project. We built a diagnostic, found a model that did, and lowered its thinking level so answers aren't cut off by hidden reasoning tokens.
- Making the warning actually safe to leave. Our first "Go back" bounced users straight back into the warning. We fixed it so it skips past the fake page.
- A single tricky constraint: a page's own script runs in the same world as our field lock. That is a stated limit in our security notes.
Accomplishments that we're proud of
- A complete product, not a single demo button. A popup, credential field guard, warning screen, download prompt, dashboard with statistics and a request log, onboarding, and rules in plain language.
- Both halves of the hybrid story working. We saw verdicts returned from Gemini Nano on-device (including with Wi-Fi off) and from cloud Gemini through the same SDK call.
- Privacy that is real. Request logs, page text and verdicts stay on the device. We documented exactly what can leave it, and when.
- Honest security notes. A threat model, a comparison with Safe Browsing, SmartScreen, Chrome Enhanced Protection and password managers, and a clear list of limits.
- Everything Firebase wired for real. AI Logic, App Check, Remote Config, Authentication and Firestore with deployed rules, and unit tests for the rule engine, parsing and rule validation.
- A safe way to test. Twenty harmless self-hosted spoof pages, harmless renamed download files, and a list of real sites for false-positive checks.
What we learned
Hybrid inference changes what you can afford to analyse. On-device inference makes page-level privacy practical, and a confidence threshold keeps the cloud for the cases that need it. We also learned that AI should sit on top of deterministic rules, not replace them: rules work without any model, and a strong rule hit keeps protection on even if the model is fooled. Finally, latency is a product feature. Model cold starts, token fetches and hidden reasoning budgets all show up as seconds a user waits.
What's next for GateKeeper
- Stronger tamper resistance for the field lock, and protection for sign-in forms inside iframes.
- Measured detection and false-positive rates over a larger, fixed test set.
- Request-log export, a weekly safety summary, and community-flag aggregation with Cloud Functions.
- An Android companion using Gemini Nano through the same Firebase AI Logic SDK.
- A Chrome Web Store release with a real App Check attestation provider.
Built With
- chrome
- claude
- cloud-firestore
- css3
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-authentication
- firebase-remote-config
- gemini
- gemini-nano
- html5
- javascript
- manifest-v3
- typescript
- vite