Dev.to Security 🔐 Cybersecurity 👁 0 📖 5 min read

Building ScamShield AI: An Evidence-Grounded, Multimodal Threat Intelligence System for Indian Mobile Scams

🚨 The Problem: The Epidemic of Mobile Smishing in India If you live in India or follow digital fraud trends, you already know the story: "Dear SBI user, your YONO account is blocked. Update KYC immediately at [bit.ly

🚨 The Problem: The Epidemic of Mobile Smishing in India

If you live in India or follow digital fraud trends, you already know the story:

  • "Dear SBI user, your YONO account is blocked. Update KYC immediately at [bit.ly/fake-link]."
  • "Electricity bill unpaid. Power will be disconnected tonight at 9:30 PM. Call officer at 98xxxxxx."
  • Unsolicited courier APKs, fake part-time job offers on WhatsApp, and malicious UPI "refund" links.

These attacks target millions every single day. But from a cybersecurity and machine learning perspective, detecting them accurately is deceptively hard:

  1. Linguistic Code-Mixing: Messages are frequently written in Hinglish (Romanized Hindi), Devanagari Hindi, English, or a chaotic mix of both. Generic spam filters trained on Western datasets fall flat.
  2. Multimodal Delivery: Half the time, users receive messages as notification screenshots or forward compressed images over WhatsApp. A single OCR character error on a suspicious domain name completely breaks security analysis.
  3. The Active Threat Problem: You cannot just "curl" or inspect a hostile link from a local server without exposing internal networks to exploitation (SSRF, malvertising, browser-fingerprinting exploits).
  4. The Hallucination Trap: Slapping a generic generative LLM onto fraud detection often leads to hallucinated reasons and inconsistent risk scores. Security demands ground-truth evidence.

To solve this, I am building ScamShield AI — a portfolio-grade, evidence-grounded scam intelligence platform designed to analyze suspicious text messages and mobile screenshots.

🏗️ High-Level System Architecture

ScamShield is designed around a single core tenet: Evidence over intuition. The system does not guess; it analyzes structured signals across parallel intelligence tracks before computing a calibrated risk score.

🔍 How the 4 Intelligence Tracks Work

When a message contains an external URL, the backend fans out independent operations asynchronously:

  • Track A — URL Intelligence: Parses the URL, calculates Levenshtein distances for typosquatting against known Indian banking and utility targets (SBI, HDFC, ICICI, India Post, Paytm, etc.), inspects Unicode homoglyphs, and checks historical VirusTotal reputation.
  • Track B — Domain Intelligence: Evaluates registration age and domain metadata via WhoisXML without letting the host establish direct active connections to hostile infrastructure.
  • Track C — Isolated Remote Sandbox (AWS ECS/Fargate + Playwright): Dangerous URLs are routed into an ephemeral, headless Playwright browser inside a disposable cloud container. The worker collects redirect chains, final destinations, DOM elements (fake OTP forms, credential harvesting fields, payment inputs), and full-page screenshots.
  • Track D — Multilingual Scam Transformer: A shared multilingual transformer head predicting:
    • Scam Intent (Multi-class: Fake KYC, Electricity Fraud, UPI/Payment Trap, Job Scam, Benign, etc.)
    • Social Engineering Tactics (Multi-label: Urgency, Fear, Authority Impersonation, Reward Bait, Financial Pressure)

📊 Project Status: How Much is Completed?

I believe in radical transparency in engineering. Here is the exact breakdown of what is running, what is in flight, and what is up next:

Component / Layer Status Implementation Details
API & Routing 🟢 100% Done FastAPI backend with structured /scan/text and /scan/image endpoints, validation, and scan context tracing.
Persistence & Caching 🟢 100% Done Primary PostgreSQL persistence with SQLite fallback; SHA-256 fingerprinting for near-instant (<50ms) cache retrieval.
Entity Extraction 🟢 100% Done Regex and heuristic engine extracting UPI handles, phone numbers, OTP patterns, rupee amounts, and URLs.
Explainability Engine 🟢 100% Done Deterministic English & Hindi explanation generator. (Zero hallucination: only reports evidence actually returned by tracks).
Track C Security Harness 🟢 100% Done Strict preflight gatekeeper preventing SSRF, IPv4-mapped IPv6 bypasses, and AWS metadata leaks, paired with browser proxy integration testing.
Frontend Portal 🟢 90% Done Modern React (Vite) interface with risk score gauges, evidence cards, and bilingual report viewing.
Multilingual OCR 🟡 75% In Progress Dual-pass PaddleOCR + OpenCV pipeline for English and Hindi/Devanagari screenshots. Building the benchmark harness to measure CER/WER and entity preservation.
External Threat Adapters 🟡 70% In Progress Track A (VirusTotal) and Track B (WhoisXML) connectors with graceful fallback and quota management.
Track C Cloud Sandbox 🟡 65% In Progress Local mock/proxy integration tested; AWS Fargate task dispatcher integration underway.
Track D (ML Transformer) 🔵 Architecture Ready Multi-task architecture finalized; dataset curation, deduplication, and training pipeline targeting our dedicated local GPU (RTX 5050).

🛡️ Key Architectural Decision: Zero-Trust Security for the Scanner

A major lesson in building cybersecurity tooling: Your scanner is a target.

If an attacker sends a message containing http://169.254.169.254/latest/meta-data/ or a local loopback link disguised inside an IPv4-mapped IPv6 address, a naive crawler will execute an SSRF (Server-Side Request Forgery) exploit against your cloud infrastructure.

To lock this down for Track C, I built a strict URL Preflight & Proxy Gatekeeper:

  1. Address Validation: Unwraps IPv4-mapped IPv6 addresses (e.g., ::ffff:10.0.0.1) and enforces strict CIDR blocking on CGNAT, private RFC1918 ranges, test nets, and cloud instance metadata endpoints.
  2. DNS Pinning & MITM Proxy Integration: Mitigates DNS rebinding attacks by ensuring the IP resolved at preflight time matches the connection accepted by our downstream sandbox proxy.

🧠 My Weekly Learnings & Technical Takeaways

  • SSRF and Address Space Normalization: Learned that standard string-based URL checks are useless against bypasses like decimal IPs, octal representations, and IPv4-mapped IPv6 strings. Python's ipaddress module with explicit socket resolution is mandatory.
  • Why DNS Time-of-Check != Time-of-Use: A domain can return a clean public IP during validation, then resolve to 127.0.0.1 10 milliseconds later when Playwright navigates (DNS Rebinding). Protecting against this requires tying DNS resolution to the browser's HTTP proxy layer.
  • Entity Preservation over Pure OCR Accuracy: In typical document OCR, 96% accuracy sounds great. But in scam detection, if an OCR engine misrecognizes sbi.co.in.pay-alert.top as sbi.co.in pay-alert top, the entire URL track fails to trigger. We must score OCR based on entity extraction recall.

🏆 Major Accomplishments This Week

  • ✅ SSRF Preflight Validator: Built and verified URLPreflightValidator covering private IPs, AWS metadata endpoints, and reserved ranges.
  • ✅ Browser Proxy Integration Test Suite: Developed TLS echo servers and proxy harnesses to validate Track C network interception under adversarial conditions.
  • ✅ Smart IP Normalization: Implemented multi-IP domain resolution comparison to handle modern CDNs without triggering false-positive network alerts.
  • ✅ End-to-End Orchestration: Verified graceful degradation — if external APIs or sandbox tracks timeout, the fan-in aggregator marks the evidence as unavailable rather than crashing the scan.

🚀 What's Next?

Over the coming weeks, I will be focusing on:

  1. Containerizing Track C: Moving the local Playwright/mitmproxy integration into a locked-down Docker environment using Linux network namespaces and iptables.
  2. Training the Transformer: Kicking off the multi-task training pipeline on the RTX 5050 for Track D.
  3. OCR Benchmarking: Running CER/WER benchmarks on real-world Indian scam screenshots to tune the PaddleOCR pipeline.

Follow the Journey:

I am building ScamShield AI entirely in public. If you are interested in cybersecurity, Python, or Indian fintech security, connect with me.

🔗 GitHub: github.com/Siddharthrane07/scamshield

Have you ever had to defend a backend against SSRF? How did you handle DNS rebinding in your architecture? Let me know in the comments!


text

                  +--------------------------------+
                  |  React (Vite) Frontend Portal  |
                  +---------------+----------------+
                                  |
                                  v
                  +--------------------------------+
                  |        FastAPI Backend         |
                  +---------------+----------------+
                                  |
       +--------------------------+--------------------------+
       |                                                     |
  [Raw Text]                                          [Mobile Screenshot]
       |                                                     |
       v                                                     v
[Normalization]                                    [Multilingual OCR Engine]
       |                                           (PaddleOCR + OpenCV passes)
       +--------------------------+--------------------------+
                                  |
                                  v
                  +--------------------------------+
                  |      Entity Extraction         |
                  | (URLs, UPI IDs, Phones, OTPs)  |
                  +---------------+----------------+
                                  |
                                  v
                  +--------------------------------+
                  |     SHA-256 Cache Gatekeeper   |
                  |    (PostgreSQL / 24-hr TTL)    |
                  +-------+----------------+-------+
                          |                |
                     [Cache Hit]      [Cache Miss]
                          |                |
                          |                v
                          |     ===========================
                          |        PARALLEL INTELLIGENCE   
                          |     ===========================
                          |     ├── Track A: URL Static Intelligence (Typosquatting/VT)
                          |     ├── Track B: Domain Intelligence (WhoisXML/DNS)
                          |     ├── Track C: Isolated Browser Sandbox (AWS Fargate)
                          |     └── Track D: Multilingual Multi-Task Transformer
                          |                |
                          +<-------[Fan-In Aggregator]
                                           |
                                           v
                          +--------------------------------+
                          |   Deterministic Risk Engine    |
                          +---------------+----------------+
                                          |
                                          v
                          +--------------------------------+
                          |  Evidence-Grounded Explainer   |
                          |       (English & Hindi)        |
                          +---------------+----------------+
                                          |
                                          v
                          +--------------------------------+
                          |  Interactive Result in Web UI  |
                          +--------------------------------+


📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.