Inspiration
India is a mobile-first nation โ and it's under siege. Over 7,000 citizens fall victim to cyber fraud every single day: UPI collect scams, digital arrest hoaxes, malicious APK sideloads, and SIM-swap attacks. Yet almost every "security" app on the market solves this by uploading your private SMS messages, contact lists, and call logs to a remote cloud server โ trading one threat for another.
The inspiration for Shadow came from a frustrating contradiction: the most privacy-sensitive data on your phone is exactly what security tools demand access to โ and then ship off the device. We wanted to prove that you don't need the cloud to be secure. An AI small enough to live on your phone can be powerful enough to protect it.
What it does
Shadow is a zero-cloud, on-device AI cybersecurity agent for Android. It runs six security shields entirely offline using Google's quantized Gemma 270M INT4 model โ no internet required, no data leaving your phone.
The Six Shields:
- ๐ฑ SMS Phishing Shield โ detects scam messages in Hindi, Bengali, Tamil, and English
- ๐ Call Spoofing Shield โ identifies impersonation patterns from fake bank/government callers
- ๐ธ UPI Fraud Shield โ analyzes collect requests and malicious QR codes
- ๐ฆ APK Sideload Shield โ audits app permissions before installation
- ๐ก NFC Relay Shield โ scans NDEF tag payloads for relay attack signatures
- ๐ Permission Audit Shield โ monitors app permission creep in the background
All threat evidence is stored in an AES-256 SQLCipher encrypted database and can be exported as a one-tap encrypted PDF for India's 1930 Cybercrime Portal โ fully compliant with the DPDP Act 2023.
How we built it
Shadow is built on Clean Architecture + MVVM with Hilt dependency injection in Kotlin.
AI Pipeline โ two-stage decision engine:
$$\text{ThreatScore} = \alpha \cdot \text{StaticBypass}(x) + (1 - \alpha) \cdot \text{GemmaInference}(x)$$
- Static Bypass Engine โ deterministic regex + token matcher against 606 scam domains and 236 threat tokens. Resolves in \( < 0.01 \text{ ms} \) for known patterns.
- Gemma 270M INT4 โ runs on-device CPU via MediaPipe GenAI LLM Inference API with structured prompts and a 3-tier prompt injection sanitization layer.
- Heuristic Fallback โ if model weights aren't downloaded yet, a rule-based synthesizer provides high-confidence verdicts so the app always works.
Stack: Kotlin ยท Jetpack Compose ยท MediaPipe GenAI ยท Hilt ยท Room ยท SQLCipher ยท WorkManager ยท Android Keystore ยท iText7 ยท Coroutines
Challenges we ran into
Model download reliability โ Shipping a 270M parameter binary at runtime is non-trivial. We built a resilient multi-mirror downloader with atomic file writes, progress tracking, and graceful fallback to prevent corruption mid-download.
Inference stability on constrained hardware โ Mid-range Android CPUs aren't built for LLM inference. We used a dedicated single-thread coroutine dispatcher to prevent crashes during intensive classification sessions.
Prompt injection on the AI itself โ Shadow processes untrusted data (SMS, NFC payloads) as LLM input. We had to build a 3-tier sanitization layer to prevent adversarial content from hijacking threat classification.
Staying truly offline โ Every convenient Android API we considered (Firebase, Play Integrity, Google Safe Browsing) required a network call. We replaced them all with on-device equivalents.
DPDP Act 2023 compliance by design โ Zero PII leakage required auditing every third-party dependency, disabling analytics SDKs, and ensuring encrypted storage never exposes plaintext to other apps.
Accomplishments that we're proud of
- โ 60/60 benchmark scenarios passed โ 100% threat detection accuracy across all six shields
- โ < 450 ms average inference latency on mid-range Android hardware with no GPU
- โ 0.15 MB peak memory footprint for the static bypass engine
- โ Zero network requests โ verified by full traffic inspection; no data ever leaves the device
- โ Full DPDP Act 2023 compliance โ the first on-device AI security agent designed for India's privacy law
- โ Production-ready APK with R8 obfuscation, ProGuard shrinking, and signed release build
What we learned
- On-device LLMs are genuinely production-ready for classification tasks โ Gemma 270M INT4 surprised us with its accuracy on nuanced scam detection.
- Privacy compliance is an architecture decision, not an afterthought. Building around DPDP Act 2023 from day one shaped every technical choice we made.
- Dual-engine pipelines โ deterministic fast path + LLM slow path โ are the right pattern for latency-sensitive security applications.
- Adversarial robustness matters even for on-device models: attackers can craft SMS messages specifically to confuse an AI classifier, so sanitization is non-negotiable.
- Shipping ML models to Android at scale is an unsolved UX problem โ we had to design the entire onboarding flow around the model download experience.
What's next for Shadow
- ๐ Broader language support โ expanding SMS detection to 10+ Indian regional languages
- ๐ค Fine-tuned Gemma variant โ training on India-specific cybercrime datasets for higher accuracy on localized scam patterns
- ๐ข Enterprise MDM integration โ air-gapped policy sync for government and corporate fleet deployments
- ๐ 1930 Portal API integration โ direct one-tap cybercrime report submission without manual PDF upload
- ๐ Community threat intelligence โ privacy-preserving federated learning to share anonymized threat signatures across devices without exposing user data
- ๐ฑ iOS port โ bringing the same zero-cloud architecture to Apple devices
Built With
- android
- android-keystore
- clean-architecture
- coroutines
- gemma
- hilt
- itext7
- jetpack-compose
- kotlin
- mediapipe
- mvvm
- room
- sqlcipher
- workmanager
Log in or sign up for Devpost to join the conversation.