DEV Community

Sattyam Jain
Sattyam Jain

Posted on

I Built a Chrome Extension That Scans Websites for Threats Using AI — Entirely On-Device

What If Your Browser Could Think?

Here's a question: what if your browser could look at a website and tell you -- in plain English -- whether it's trying to steal your credentials, run malicious scripts, or track you across the internet?

Now here's the harder question: what if it could do all of that without sending any of your browsing data to a server?

No cloud APIs. No telemetry. No "we anonymize your data" promises. Just an AI model running entirely inside your browser, analyzing pages in real time, and keeping everything local.

That's what I built. It's called ZeroTrust, and it's a Chrome extension that scores website security using on-device AI powered by WebLLM and WebGPU.

Never trust. Always verify. And do it without trusting anyone else with your data.


The Privacy Problem Nobody Talks About

Let's talk about the irony of cloud-based security tools.

You install a browser extension to protect you from phishing. Great. But that extension works by sending every URL you visit -- and sometimes the page content -- to a remote server for analysis. You're now trusting a third-party company with your complete browsing history, including the banking sites, medical portals, and private dashboards you visit.

You traded one privacy problem for another.

Here's what popular security extensions typically do:

  • Send URLs to cloud APIs for reputation checks
  • Upload page content for phishing analysis
  • Track browsing patterns for "threat intelligence"
  • Require user accounts and store browsing profiles
  • Phone home with telemetry data

Even the well-intentioned ones are sending your data somewhere. And once it leaves your machine, you have zero control over what happens to it.

I wanted something different. I wanted security analysis that never leaves the browser. Not because cloud services are evil, but because the most secure data is data that never gets transmitted in the first place.


How ZeroTrust Works

ZeroTrust is a Manifest V3 Chrome extension that runs an LLM directly in your browser using WebLLM and WebGPU acceleration. When you visit a website, it performs a comprehensive security analysis and gives you a trust score from 0 to 100, all without making a single network request for analysis.

The Architecture

┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Popup     │────>│  Background │────>│  Offscreen  │
│   (React)   │     │  (Router)   │     │  (WebLLM)   │
└─────────────┘     └─────────────┘     └─────────────┘
                           │
                           v
                    ┌─────────────┐
                    │   Content   │
                    │  (Scanner)  │
                    └─────────────┘
Enter fullscreen mode Exit fullscreen mode

Four components, each with a specific job:

Popup (src/popup/) -- The React-based UI you interact with. Shows the trust score, security breakdown, and AI chat interface. Built with React 19 and Tailwind CSS 4.

Background (src/background/) -- The message router. Coordinates communication between the popup, content script, and offscreen document. Manages the lifecycle of the offscreen page that hosts the AI model.

Offscreen (src/offscreen/) -- This is where the magic happens. An offscreen document loads and runs the WebLLM engine. All AI inference happens here, using your GPU via WebGPU. The model stays loaded in memory so subsequent analyses are fast.

Content (src/content/) -- The scanner. Injected into every page you visit, this script analyzes the page's HTML, scripts, forms, cookies, and network behavior. It feeds structured data to the AI model for deeper analysis.

The Key Insight: Offscreen Documents

Chrome extensions can't run WebGPU directly in background service workers. The solution is Manifest V3's offscreen document API. ZeroTrust creates an offscreen HTML page that loads WebLLM, which in turn downloads and runs an LLM using WebGPU compute shaders. The background script routes messages between the popup/content scripts and this offscreen AI engine.

This means the model runs in a dedicated context with full GPU access, but it's invisible to the user. No extra tabs. No popups. Just background AI.


The Trust Scoring Algorithm

Every website gets a score from 0 to 100, calculated from seven security factors. Each factor contributes a maximum number of points based on its importance to overall security.

Factor Max Points What It Checks
HTTPS Connection 15 Is the connection encrypted?
Valid Certificate 10 Is the SSL certificate valid and current?
Domain Age 10 How old is the domain? (Newer = riskier)
Phishing Signals 25 Suspicious URLs, fake login forms, brand impersonation
Malicious Scripts 20 Obfuscated code, cryptominers, keyloggers
Cookie Compliance 10 Excessive tracking, third-party cookies, missing consent
Form Security 10 Insecure form actions, password fields on HTTP

The scoring is weighted based on real-world threat data. Phishing signals get the most weight (25 points) because phishing is the most common attack vector. Malicious scripts get 20 points because they represent active threats. Connection security gets 15 points because it's foundational.

Grade Scale

The raw score maps to a letter grade that's immediately understandable:

  • A (90-100): Excellent security. This site follows best practices.
  • B (80-89): Good security. Minor concerns but generally safe.
  • C (70-79): Moderate concerns. Proceed with caution.
  • D (60-69): Poor security. Significant risks detected.
  • F (0-59): Critical issues. This site may be actively dangerous.

Beyond the Score: AI Analysis

The trust score gives you the quick answer. But ZeroTrust also includes an AI chatbot that lets you ask deeper questions about any website:

  • "Is this login form safe?"
  • "What tracking scripts are running on this page?"
  • "Does this site have any known vulnerabilities?"
  • "Explain the security risks of this page in simple terms."

The LLM analyzes the page content and gives you a natural language explanation. All processing happens locally. Your questions and the page content never leave your machine.


The AI Models

Running an LLM in the browser means working within hardware constraints. ZeroTrust gives you three model options based on your device capabilities:

Model Download Size VRAM Required Best For
Gemma 2 2B ~1.5 GB 2 GB Quick scans, lower-end hardware
Phi-3 Mini ~2 GB 3 GB Recommended balance of speed and quality
Llama 3.1 8B ~4.5 GB 6 GB Most thorough analysis, needs decent GPU

The model downloads once and is cached by the browser. Subsequent loads are fast -- the model initializes from the local cache and is ready in seconds.

Phi-3 Mini is the sweet spot. It's small enough to run on most modern laptops but capable enough to provide meaningful security analysis. If you have a dedicated GPU with 6+ GB of VRAM, Llama 3.1 8B will give you the most detailed results.

WebGPU: Why This Works Now

This extension wouldn't have been possible two years ago. WebGPU is the successor to WebGL, and it gives JavaScript access to modern GPU compute capabilities -- the same kind of parallel processing that powers CUDA on NVIDIA GPUs.

WebLLM leverages WebGPU to run transformer models at near-native speeds in the browser. No WASM hacks. No CPU-only inference that takes 30 seconds per response. Actual GPU-accelerated inference, running quantized models that fit in browser memory.

Chrome 113+ supports WebGPU, and most modern GPUs (even integrated ones from the last few years) can handle it.


Technical Deep Dive: The Stack

For those who want to know exactly what's under the hood:

  • React 19 -- UI framework for the popup interface
  • TypeScript -- Type safety across the entire codebase
  • Vite -- Fast builds and hot module replacement during development
  • Tailwind CSS 4 -- Utility-first styling
  • WebLLM -- On-device LLM inference library by the MLC team
  • WebGPU -- GPU compute API for browser-based AI

Development Setup

# Clone the repo
git clone https://github.com/sattyamjjain/zerotrust.git
cd zerotrust

# Install dependencies
npm install

# Development mode with hot reload
npm run dev

# Production build
npm run build

# Lint
npm run lint
Enter fullscreen mode Exit fullscreen mode

Loading the Extension

  1. Open chrome://extensions/
  2. Enable "Developer mode" (toggle in the top right)
  3. Click "Load unpacked"
  4. Select the dist folder from the built project

That's it. Navigate to any website and click the ZeroTrust icon to see its security analysis.

System Requirements

  • Chrome 113 or later (for WebGPU support)
  • 4 GB RAM minimum (8 GB recommended)
  • GPU with WebGPU support (most GPUs from 2020+)

Why "Zero Trust"?

The name comes from the zero trust security model: never trust, always verify. But I'm applying it in two directions.

Don't trust websites. Every site you visit gets scanned and scored. No whitelists, no assumptions. Even sites you visit daily can be compromised.

Don't trust security tools. Most security tools ask you to trust them with your data. ZeroTrust doesn't ask for that trust because it doesn't need it. Everything runs locally. There's no server to trust, no data to leak, no company to get breached.

Zero trust, applied all the way down.


What's Next

ZeroTrust is functional and usable today, but there's more I want to build:

  • Real-time monitoring: Continuous scanning as pages dynamically load content
  • Extension analysis: Scanning other installed extensions for suspicious behavior
  • Exportable reports: PDF security reports for compliance teams
  • Custom rules: User-defined security policies and allowlists
  • Firefox support: Porting to Firefox when WebGPU lands in stable

Try It Out

ZeroTrust is open source, MIT licensed, and ready to use.

  • Star the repo: github.com/sattyamjjain/zerotrust
  • Clone and build: Takes about two minutes with the instructions above
  • Report issues: Found a bug or have a feature request? Open an issue.
  • Contribute: PRs are welcome, especially for new security checks and model integrations.

If you care about security and privacy, this is the kind of tool that should exist. No accounts. No telemetry. No cloud dependencies. Just your browser, your GPU, and an AI that works for you -- not for an ad network.


What security checks would you add to a tool like this? Have you experimented with running LLMs in the browser? I'd love to hear about your experience in the comments.

Top comments (0)