Building ScamShield: An Explainable, Security-First Phishing Detection System
How I built ScamShield from the ground up—from character-level TF-IDF and ML classification to SHAP explanations, evidence-aware risk fusion, threat intelligence, DNS/TLS intelligence, redirect analysis, SSRF and DNS-rebinding protection, QR scanning, and production deployment.
ScamShield started as a question: how can a phishing detector give a useful verdict without hiding the reasoning behind it?
I built it as a security-first full-stack system that analyzes URLs, messages, and QR codes while keeping the detection pipeline explainable and the network-facing components tightly bounded.
The Detection Pipeline
The core detector combines deterministic security rules with machine learning rather than depending on a single signal.
URL Analysis
The normalization and feature pipeline looks for structural indicators such as:
- Lookalike and suspicious domains
- Homoglyph and punycode usage
- IP-based hosts and URL obfuscation
- Suspicious keywords and excessive subdomains
- Credential-harvesting patterns
- HTTPS and other URL-level security signals
The ML baseline uses character-level TF-IDF features with Logistic Regression, allowing the model to learn suspicious URL structure without relying only on a fixed keyword list.
Explainability with SHAP
A detector should not simply return a number and call it intelligence.
ScamShield uses SHAP to expose model-level feature contributions so the explanation can show which learned signals influenced the prediction. SHAP remains explanatory rather than becoming an additional risk signal.
This keeps the distinction clear between:
- what the model predicted;
- what deterministic rules detected; and
- what the final risk fusion decided.
Evidence-Aware Risk Fusion
The final risk score is not built by blindly averaging every possible subsystem.
Signals participate according to their availability. Failed or unavailable external intelligence is excluded instead of being silently treated as clean evidence.
The result is a layered verdict:
- Safe
- Suspicious
- Dangerous
The system also preserves the underlying evidence so the user can understand why a result received its score.
Threat and Domain Intelligence
ScamShield includes interfaces for external reputation intelligence together with domain and infrastructure analysis.
The domain layer can inspect DNS, registration, and TLS characteristics. Redirect analysis follows bounded redirect chains without rendering pages or executing remote content.
These components are deliberately isolated from the core detector so an unavailable provider does not turn into a false “safe” signal.
SSRF and DNS-Rebinding Protection
Security tooling can accidentally become an attack surface itself.
Redirect and TLS analysis therefore validate resolved addresses and reject private, loopback, link-local, special, and other unsafe destinations. Connections are made only to validated public addresses while preserving the original hostname where required for SNI and certificate verification.
Redirect processing is also bounded by hop, timeout, URL, and chain limits.
Message and QR Scanning
A message can contain multiple URLs, so ScamShield extracts and evaluates each URL independently and preserves the highest-risk result for the overall scan.
QR codes are decoded locally. The decoded destination is analyzed without automatically opening or navigating to the link.
Production Deployment
The application is deployed as a real production system:
- Next.js frontend
- FastAPI backend
- Supabase PostgreSQL persistence
- Supabase authentication infrastructure
- Vercel deployment
- HTTPS on a custom subdomain
Live application: scamshield.shashankhu.dev
Source code: GitHub
What I Learned
The hardest part was not making the detector produce a score. It was designing the boundaries around that score.
A useful security product needs to answer three questions clearly:
- What did the system detect?
- Why did it reach this conclusion?
- What happens when one of its external signals is unavailable or untrusted?
That became the design principle behind ScamShield: layered detection, explicit evidence, explainability, and defensive network behavior rather than a black-box verdict.