Docs /Zero-Leak Privacy Architecture
SECURITY WHITEPAPER · AIR-GAPPED VERIFICATION · 2026

Zero-Leak Privacy Architecture.

An engineering breakdown of Local AI on-device security model. Learn how native C++ JNI memory isolation, zero-telemetry architecture, hands-on Wireshark packet capture verification, and enterprise compliance guarantee absolute data sovereignty on Android.

The Cloud SaaS Threat Model (ChatGPT, Claude)
  • •Transit Risk: All prompts and uploaded files traverse public internet infrastructure, CDNs, and API gateways.
  • •Server Logging: Remote providers store prompts in internal databases for 30+ days for moderation and employee review.
  • •Subpoena & Breach: Cloud servers are frequent targets for credential compromise, insider threats, and legal discovery.
The Local AI Sovereign Model
  • •Zero Network Transit: Inference executes inside on-device memory without opening external internet sockets.
  • •Zero Cloud Telemetry: No tracking SDKs, no crash uploaders, and no background heartbeat pings.
  • •Physical Air-Gap: Works with 100% fidelity in Airplane Mode with SIM card removed.

1. Native C++ / JNI Memory Boundary Isolation

In typical Android applications, business logic and data structures reside inside the Android Runtime (ART/Dalvik) managed heap. Local AI fundamentally breaks with this pattern by segregating neural network execution into a standalone native C++ execution space.

Architectural Separation: ART Managed Heap vs. Native C++ Virtual Memory

Layer A: Android Runtime (ART) Managed Heap
  • • Runtime: Kotlin, Jetpack Compose, Material 3 UI
  • • Memory Footprint: Minimal (~45 MB – 85 MB)
  • • GC Behavior: ART Generational Concurrent Copying
  • • Data Handled: Transient UI strings, chat bubbles, theme state
  • • Security: Standard Android app sandbox
Layer B: Native C++ llama.cpp Address Space
  • • Runtime: Native ARM64-v8a C++ shared library (liblocalai.so)
  • • Memory Footprint: 1.5 GB – 6.0 GB (Model weights & KV cache)
  • • GC Behavior: Zero GC (Allocated via malloc / mmap)
  • • Data Handled: Synaptic weight matrices, KV cache, tensor graph
  • • Security: Linux hardware MMU page isolation & SELinux
Memory Isolation Boundary & JNI Data FlowZero GC · Hardware MMU Protected
ART Heap (Dalvik VM)

Managed objects, UI composition, theme colors. Memory allocation: ~45MB.

Inspection Scope: Java Reflection, HPROF heap dumps terminate here.
Strict JNI C-ABI Bridge

Passes opaque 64-bit integer pointers (jlong modelHandle).

Zero tensor buffer copying across boundary
Native C++ Address Space

malloc() / POSIX mmap() page tables. Memory allocation: 1.5GB–6.0GB.

GC Isolation: 100% GC-free. Zero stop-the-world pauses.
🔒 Linux Kernel MMU Hardware Isolation: Enforces separate virtual memory page tables. SELinux untrusted_app prevents foreign process memory reads.

// JNI Memory Pointer Exchange Mechanism

// Kotlin UI passes only opaque 64-bit memory addresses across the JNI bridge:
external fun nativeInitModel(modelPath: String, contextSize: Int): Long
external fun nativeEvalPrompt(modelHandle: Long, promptText: String): Flow<String>

Weights and KV caches are allocated in native C++ virtual memory via malloc() or mapped directly with mmap(..., MAP_PRIVATE | MAP_NORESERVE, ...). The ART managed heap never touches or stores model weight buffers.

Immunity from Garbage Collection (GC) Stalls

If 4GB of model weights were loaded into the Java/ART heap, the garbage collector would suffer catastrophic multi-second "stop-the-world" compaction pauses. Because native C++ allocations bypass ART completely, token generation streams smoothly with zero UI frame drops.

Zero Heap Inspection by Java Frameworks

Third-party monitoring SDKs or malicious instrumentation tools targeting the Android ART heap (such as memory dump analyzers or HPROF extractors) can only inspect Java objects. Native C++ memory blocks cannot be traversed, inspected, or reflected by Java runtime tooling.

Linux Kernel UID & SELinux Sandboxing

Android assigns Local AI a dedicated Linux User ID (u0_a...) and isolates the process under the untrusted_app SELinux domain. The Linux kernel MMU enforces hardware page protection; no other app can read /proc/[pid]/mem.

2. Hands-On Network Verification Guide

Security audits should never rely on marketing claims. Below is a step-by-step technical recipe allowing any developer, IT administrator, or security researcher to independently verify that Local AI produces zero network traffic:

Method 1Verify Zero Network Permissions via Android Debug Bridge (ADB)

Static Manifest Audit

Connect your Android device via USB debugging and query the package manager directly for declared permissions:

# 1. Verify zero declared network permissions in package manifest:

adb shell dumpsys package dev.shanaka.localai | grep -i "permission.*INTERNET"

# Expected Output: Empty (0 matches found! android.permission.INTERNET is completely absent)

# 2. Query kernel network socket transmission counters for the application UID:

adb shell dumpsys netstats detail | grep -E "dev.shanaka.localai"

# Expected Output: Empty / 0 rxBytes, 0 txBytes

# 3. Inspect active socket descriptors for the running process:

adb shell "lsof -p \$(pidof dev.shanaka.localai)" | grep -E "TCP|UDP|RAW"

# Expected Output: Empty (Zero open network sockets!)

Operating System Enforcement: In Android, network socket syscalls (socket(AF_INET, SOCK_STREAM, 0)) are mediated by the Linux kernel. If android.permission.INTERNET is not present in the package manifest, the kernel immediately refuses socket creation with EPERM (Operation not permitted).

Method 2Live Packet Capture with PCAPdroid and Wireshark

Deep Packet Inspection (DPI)

PCAPdroid is an open-source non-root network capture tool that routes device traffic through a local virtual VPN adapter to capture raw network frames:

Step A: Setup Capture

Install PCAPdroid. Select Target Application: dev.shanaka.localai. Set Dump Mode to PCAP File.

Step B: Exercise Model

Launch Local AI. Generate 1,000+ words across multiple prompts, reasoning models, and document summaries.

Step C: Analyze in Wireshark

Transfer localai_audit.pcap to your computer and open in Wireshark with display filters.

// Wireshark Display Filter Expressions & Verification Metrics:

1. Filter: dns → Output: 0 DNS Lookups (No domain resolution attempted)

2. Filter: tls.handshake → Output: 0 TLS Handshakes (No secure sockets initiated)

3. Filter: tcp.port == 443 || tcp.port == 80 → Output: 0 Packets (Zero outbound HTTP/HTTPS)

4. Filter: ip.addr != 127.0.0.1 → Output: 0 Packets (Zero external IP communication)

Method 3Android Studio Live Network Profiler Inspection

Real-time Socket Profiling

Enterprise developers can attach Android Studio's native Profiler to observe memory, CPU, and network timelines in real time:

  • Open Android Studio → View → Tool Windows → Profiler.
  • Attach to process: dev.shanaka.localai.
  • Observe the Network Track: While CPU surges during prompt evaluation and token generation, the network timeline displays a completely flat line at 0 B/s.
  • Contrast this with cloud AI clients (ChatGPT, Claude, Copilot) which stream hundreds of packets (POST requests to /v1/chat/completions) containing user prompts and device telemetry.

3. Enterprise Threat Model & Compliance Matrix

For healthcare, legal, and financial enterprises, adopting cloud AI introduces unacceptable regulatory exposure. Below is a rigorous comparative compliance analysis:

Regulatory StandardGoverning RulesCloud SaaS Threat ModelLocal AI Sovereign GuaranteeAudit Verdict
HIPAA (Health Insurance Portability & Accountability Act)45 CFR § 164.308 / § 164.312High Risk: Transmitting Protected Health Information (PHI) requires a signed Business Associate Agreement (BAA) with AI cloud providers. Prompt logs risk subpoena or vendor employee review.Zero BAA Required: PHI never crosses a network socket. All clinical reasoning executes inside on-device physical RAM and is stored in hardware-encrypted local databases.100% HIPAA Sovereign
GDPR (General Data Protection Regulation)Articles 5, 25 (Privacy by Design), 44 (Cross-Border Transfers)Non-Compliant Default: Cloud LLMs transfer personal data across jurisdictions (EU to US), requiring complex Standard Contractual Clauses (SCCs) and Data Processing Agreements (DPAs).By-Design Compliance: Zero data transfer across external networks. Immediate data minimization (Article 5(1)(c)). Clearing app data permanently purges all logs (Article 17 Right to Erasure).GDPR Article 25 Native
Attorney-Client Work Product PrivilegeFRCP Rule 26(b)(3) / ABA Model Rule 1.6Severe Privilege Waiver: Cloud AI terms of service often permit vendor contractors to review prompt transcripts for safety auditing, destroying legal confidentiality and work-product immunity.Full Privilege Preservation: Litigation strategies, deposition prep, and confidential client NDAs remain strictly in counsel's physical possession. Non-discoverable by cloud subpoena.Privilege Protected
Financial & Proprietary Trade SecretsFINRA / GLBA / SEC Rule 17a-4 / SOC 2 Type IIExfiltration & Training Leakage: Uploading proprietary trading algorithms, unreleased quarterly financials, or internal M&A memos creates catastrophic exfiltration risks.Zero Exfiltration Vector: Device operates under physical air-gapping. Binary contains zero tracking SDKs, zero crash uploaders, and zero telemetry daemons.Enterprise Sovereign

HIPAA: Zero BAA Required

Under 45 CFR § 164.502(e), Business Associate Agreements are only required when third parties handle PHI. Because Local AI executes 100% on-device without internet access, healthcare institutions retain complete physical custody of patient data with zero cloud vendor exposure.

GDPR Article 25 Native

GDPR Article 25 mandates Data Protection by Design and by Default. By processing queries purely within local RAM, Local AI provides immediate data minimization (Article 5) and avoids all cross-border transfer restrictions (Chapter V).

Attorney-Client Privilege

Cloud AI terms often permit human contractors to review prompt transcripts for safety auditing, causing potential privilege waivers under FRCP 26(b)(3). Local AI keeps confidential legal briefs and trade secrets fully privileged and non-discoverable.

Privacy & Security FAQs

How does native C++ JNI memory allocation protect against Android GC pauses and heap inspection?+
In Local AI, all neural network weights and KV context caches are allocated via native malloc() and mmap() in native C++ address space (llama.cpp) outside the Android Runtime (ART) virtual machine. Because the ART garbage collector only traverses managed Java/Kotlin heap references, multi-gigabyte LLM allocations introduce zero GC overhead, completely preventing UI freezes. Furthermore, standard Android memory inspection tools (like HPROF heap dumps) cannot inspect or traverse native memory blocks.
How can I verify that Local AI has zero Android internet permissions via ADB?+
You can execute `adb shell dumpsys package dev.shanaka.localai | grep -E 'permission.*INTERNET'` from your computer. The command returns zero output because `android.permission.INTERNET` is completely absent from the app's AndroidManifest.xml. Without this manifest declaration, the Linux kernel refuses to grant network socket syscalls (socket(AF_INET, ...)), returning EPERM (Operation not permitted).
Why is no Business Associate Agreement (BAA) needed for HIPAA compliance with Local AI?+
Under HIPAA regulations (45 CFR § 164.502(e)), a Business Associate Agreement is only required when a third-party vendor creates, receives, maintains, or transmits Protected Health Information (PHI) on behalf of a covered entity. Because Local AI processes and stores all patient data strictly on the physician's local device without transmitting any data over the internet, no third party ever handles the data, eliminating the legal requirement for a BAA.
Does Local AI collect any telemetry, crash reports, or analytics in the background?+
No. Local AI contains zero third-party analytics SDKs (no Firebase Analytics, no Mixpanel, no Sentry, no Google Analytics). The application contains no background sync daemons. When you close the app, zero background threads remain active.
Can an Android app secretly transmit data if Airplane Mode is on?+
No. The Linux kernel powering Android physically disables the baseband radio firmware and Wi-Fi transceivers when Airplane Mode is active. At the hardware level, radio antennas receive zero electrical power, making remote data transmission physically impossible.
How does Local AI handle conversation history storage?+
Conversation logs are stored strictly inside your phone's sandboxed internal app storage (using encrypted SQLite / Room). Other apps on your phone cannot access this sandboxed directory. If you clear app data or uninstall Local AI, all history is permanently deleted from your flash storage.
EXPERIENCE TRUE PRIVACY

Get Local AI on Google Play

Free early access. 100% private on-device intelligence without subscriptions or telemetry.

Get Early Access ↗