
Email Phishing Detection Extention using On device LLM
Client-Side Phishing Detection in Gmail Using Local LLMs
The Problem: Trusting the Cloud for Email Security
Modern phishing detection often relies on cloud-based AI services. While powerful, these models raise critical privacy concerns when dealing with sensitive email content. Many users and enterprises hesitate to send their inbox data to third-party services, no matter how secure they claim to be.
Relying on cloud-based detection models meant every email was transmitted off-device, creating a serious privacy bottleneck for security-conscious users.
Additionally, even well-funded organizations were missing threats due to high false positive rates, delayed classification, and inconsistent integrations with email clients like Gmail.
The Solution: Grounded — A Local LLM Gmail Extension
Inspired by the idea of on-device inference, I designed and developed Grounded, a browser extension that brings phishing detection directly into the Gmail interface using a locally hosted language model.

At its core, Grounded uses Ollama to run a lightweight LLM (e.g., gemma-2b
) entirely on the user's machine. When an email is opened, the extension captures its contents and sends it to the localhost inference server—no data ever leaves the device.
Grounded makes use of the browser's content_scripts
and background.js
to extract email content and coordinate analysis with the local LLM.
Architecture Highlights
- Frontend (Content Script): Hooks into Gmail DOM to detect when an email opens and extract relevant content (subject, sender, body).
- Backend (Background Script): Handles caching verdicts in
localStorage
and querying the local LLM. - Inference (Ollama): Hosts a local HTTP server on
localhost:11434
where thegemma-2:2b
model classifies emails asLegit
,Neutral
, orPhishing
. - UI Overlay: Injects a result banner into Gmail using DOM manipulation, color-coded for clarity.
// contentScript.js - inject classification banner
const verdictBanner = document.createElement('div');
verdictBanner.innerText = "⚠️ Suspicious Email";
verdictBanner.style.backgroundColor = "#ffcccc";
emailElement.prepend(verdictBanner);
The Impact Though built as a proof-of-concept, Grounded opens a promising path for private, offline phishing detection that scales with local compute, not with cloud costs or privacy tradeoffs.
Bytes of Email Data Sent to Cloud
Average Local LLM Classification Time
On-Device Inference
Support Outlook Web and other email providers.
Add training and feedback loop for user-tuned phishing detection.
Integrate with endpoint threat intel tools for context-aware verdicts.
Want to try it out? 👉 View the repository
git clone https://github.com/iamahmedabdalla/grounded-extension