When an AI model runs on a phone, laptop or edge box instead of in the cloud, the model file, its prompts and the data it reads all sit on hardware the user, or an attacker, physically controls. On-device AI removes the network round trip and keeps raw data local, which is a genuine privacy gain, but it also hands a copy of the model to every endpoint and puts local inference servers, model files and AI-generated indexes of user activity within reach of malware. This guide covers three situations: AI features built into the operating system (such as Windows Recall or Android's Gemini Nano), models your own apps ship to devices, and local model runtimes such as Ollama and llama.cpp that staff install on workstations. It is written for endpoint, mobile and application security teams, and for ML engineers shipping models to devices. For hosting open models on servers, see the Self-Hosted LLM Security Guide.
Key takeaways
- A model on a device is a model you have published. Encryption and obfuscation raise the cost of extraction but cannot prevent it on hardware the attacker controls, so never rely on model secrecy for security and keep valuable logic and system prompts server-side.
- Integrity matters more than confidentiality. A swapped model or malicious adapter silently changes app behaviour; sign and verify model files before loading, and prefer non-executable formats such as safetensors or GGUF over pickle.
- Local inference servers are network services. Ollama binds to 127.0.0.1:11434 by default; changing
OLLAMA_HOSTto 0.0.0.0 without an authenticating proxy publishes an unauthenticated model API. - AI features create new sensitive data stores. Screen snapshots, embeddings and conversation caches need the same encryption, retention and access controls as the data they summarise.
- Prompt injection does not stop at the device. On-device assistants still read untrusted content; keep tool permissions narrow and require user confirmation for actions.
What changes when AI runs on the device
| Aspect | Cloud-hosted model | On-device model | Security consequence |
|---|---|---|---|
| Model weights | Behind an API; attacker sees only outputs | File on the device, loaded into user-space or system memory | White-box access enables extraction, cloning and crafting adversarial inputs offline |
| User data | Sent over the network, processed and possibly logged by the provider | Stays on the device | Smaller interception and provider risk; larger local data store risk |
| Guardrails | Server-side filters you control and update | Shipped with the app or OS; can be bypassed on a rooted device | Treat on-device filters as advisory; enforce policy server-side for anything consequential |
| Updates | Instant, central | Through app store, OS update or model download | Vulnerable or poisoned models persist in the field longer |
| Monitoring | Central logs of prompts and outputs | Little or no central visibility | Abuse and misbehaviour are hard to detect; telemetry must be designed in with privacy limits |
| Cost of abuse | Metered per token | Free to the attacker once extracted | Unlimited offline queries for model inversion or jailbreak search |
OWASP's Top 10 for LLM Applications 2025 notes explicitly, under LLM03 Supply Chain, that the emergence of on-device LLMs increases the attack surface and supply-chain risk. See the OWASP Top 10 for LLM Applications Guide.
Threats mapped to MITRE ATLAS
Identifiers below were checked against MITRE ATLAS 5.6.0. See the AI Threats and Model Security Guide for the wider model threat landscape.
| Threat on device | ATLAS technique | Main controls |
|---|---|---|
| Copying the model file out of the app package or memory | AML.T0044 Full AI Model Access; AML.T0035 AI Artifact Collection | Platform model encryption, app attestation, no secrets in the model or prompt, licensing terms |
| Replacing the model in a repackaged app to change behaviour | AML.T0018 Manipulate AI Model | Signature and hash checks before load, app integrity checks, store-only distribution |
| Poisoned model or adapter downloaded at runtime | AML.T0010 AI Supply Chain Compromise; AML.T0058 Publish Poisoned Models | Signed model manifests, pinned sources, safe serialisation formats |
| Offline search for adversarial inputs against a white-box model | AML.T0043 Craft Adversarial Data; AML.T0005 Create Proxy AI Model | Server-side verification for high-stakes decisions; do not use on-device models as the only fraud or liveness check |
| Malicious content steering a local assistant | AML.T0051 LLM Prompt Injection | Least-privilege tools, confirmations, content provenance labels |
| Local AI index or chat history leaking sensitive data | AML.T0057 LLM Data Leakage | Encryption bound to user authentication, retention limits, DLP filtering |
| Unauthenticated local inference API reachable on the network | AML.T0040 AI Model Inference API Access | Loopback binding, authenticating reverse proxy, host firewall |
OWASP LLM03 describes a real case in which attackers reverse-engineered mobile apps and replaced the embedded model with a tampered version, affecting 116 Google Play apps including cash recognition, parental control and face authentication apps. That is the core risk of shipping models: a repackaged app is indistinguishable to the user unless your backend checks integrity.
Protecting models you ship to devices
- Use platform model encryption where it exists: Core ML lets you generate a model encryption key in Xcode (Utilities, Create Encryption Key), which produces a
.mlmodelkeyfile tied to your development team, and encrypt the bundled model at compile time by adding--encryptwith the key path to the model's compiler flags. The same key can encrypt model archives deployed through CloudKit. This protects the model at rest in the package; it does not stop a determined attacker on a jailbroken device from reading decrypted weights in memory. - Verify integrity before every load: ship a signed manifest with model hashes and verify it at load time. OWASP LLM03's mitigations recommend encrypting models deployed at the AI edge with integrity checks and using vendor attestation APIs to detect tampered apps and models.
- Use app attestation to protect the backend: Android Play Integrity and Apple App Attest let your server check that requests come from your genuine app on a genuine device. Google's guidance for hybrid Gemini Nano and cloud inference recommends protecting the cloud path with Firebase App Check (backed by Play Integrity) and keeping sensitive system prompts server-side. See the Mobile App Security Guide.
- Apply resilience controls proportionately: OWASP MASVS-RESILIENCE lists theft of AI or machine learning models among the business risks that obfuscation, anti-tampering and runtime protection help mitigate, and also states that their absence is not itself a vulnerability. Use them to raise cost, not as the security architecture.
- Keep secrets out of the model and the app: no API keys, system prompts with business rules, or customer data in the bundle. Symantec's study of 1,859 mobile apps with hard-coded AWS keys shows how routinely embedded credentials are extracted; an app that falls back to a cloud LLM with an embedded key becomes a free LLM proxy for anyone. See the LLMjacking Guide.
- Prefer system-provided models where they fit: on Android, Gemini Nano runs inside the AICore system service, which Google documents as isolated from most other packages, without direct internet access (requests and model downloads go through the open-source Private Compute Services component) and without retaining request inputs or outputs. The OS vendor then owns model updates and isolation, though you remain responsible for your app's use of the output.
Protecting data that on-device AI creates
AI features turn scattered activity into a searchable store: snapshots, embeddings, transcripts and summaries. Windows Recall is the most documented example and a good template for what to ask of any such feature.
| Control | How Recall implements it (Microsoft Learn) | Question to ask of other on-device AI features |
|---|---|---|
| Off by default | Disabled and removed by default on commercially managed devices; users must opt in; admins cannot turn on snapshot saving for users | Is it opt-in, and can IT block it centrally? |
| Encryption bound to the user | Snapshots and vector database entries always encrypted; keys protected by the TPM, tied to Windows Hello Enhanced Sign-in Security and used inside a VBS enclave | Can another local user, an admin or malware running as the user read the store? |
| Strong local authentication | Requires Windows Hello ESS with a biometric before launch and before saving starts; BitLocker or Device Encryption must be on | Is access to the AI store re-authenticated? |
| Sensitive data filtering | On by default; runs on the NPU using the Microsoft Classification Engine and skips snapshots with detected sensitive information; Purview DLP integration per window | Does it skip passwords, card numbers and labelled content? |
| Retention | Policies SetMaximumStorageDurationForRecallSnapshots (30, 60, 90 or 180 days) and SetMaximumStorageSpaceForRecallSnapshots | Can retention be capped by policy? |
| Exclusions | SetDenyAppListForRecall, SetDenyUriListForRecall; apps can call SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURE | Can sensitive apps opt out? |
The governing policies are AllowRecallEnablement and DisableAIDataAnalysis under the WindowsAI CSP (./Device/Vendor/MSFT/Policy/Config/WindowsAI/) or Group Policy at Computer Configuration, Administrative Templates, Windows Components, Windows AI. Disabling AllowRecallEnablement removes the component and deletes saved snapshots after a restart. See the Endpoint DLP Guide and the AI and Privacy Guide.
For your own apps, apply the same pattern: store embeddings and chat history in platform-protected storage (Keychain or Data Protection classes on iOS, Android Keystore-wrapped keys), set retention, and remember that embeddings can leak the text they were made from. See the OWASP LLM Top 10 LLM08 Vector and Embedding Weaknesses Guide.
Local model runtimes on workstations
Developers and analysts increasingly run open-weight models locally. These runtimes are servers, model loaders and download managers at once, and they are often installed outside IT's view. See the Open-Weight Model Security Guide.
- Network exposure: Ollama listens on 127.0.0.1 port 11434 by default and changes bind address through
OLLAMA_HOST. Its documentation shows setting0.0.0.0:11434to share it on a network; do not do this on corporate devices without an authenticating reverse proxy, because the documented way to share it is a reverse proxy or tunnel in front of the local API, and access control is left to that layer. Allowed browser origins are controlled byOLLAMA_ORIGINS; avoid wildcards such aschrome-extension://*, which lets every installed extension call the model. - Unexpected cloud use: Ollama can route to cloud-hosted models; set
"disable_ollama_cloud": truein~/.ollama/server.jsonorOLLAMA_NO_CLOUD=1where policy requires local-only processing, and check the log line confirming it. - Untrusted models and inputs: the llama.cpp security policy advises running untrusted models in a sandbox (container or VM), verifying the hash of downloaded weights against a known-good value, and not using its RPC backend or
llama-serveron untrusted networks. It also warns that GPU side channels can leak data between models sharing hardware. - Safe formats: pickle-based checkpoints can execute code when loaded. Prefer safetensors, which Hugging Face designed to store tensors safely as opposed to pickle, or GGUF for llama.cpp runtimes. The PyTorch torchtriton attack shows that the ML toolchain itself is a target: a dependency confusion package stole SSH keys and environment variables from machines installing nightly builds. See the Model Supply Chain Guide.
- Inventory and policy: discover runtimes through EDR process and listening-port inventory (for example a listener on TCP 11434), maintain an approved list of runtimes and model sources, and route requests to approved models through managed configuration. See the Shadow AI Discovery Guide.
Where identity fits
On-device assistants increasingly act: they read mail, call APIs and run tools with the signed-in user's tokens. That makes them non-human actors operating under a human identity. Scope OAuth grants to what the feature needs, prefer per-feature tokens over reusing the user's broad session, require confirmation for sending, paying or deleting, and log tool calls locally with a path to central collection. See the Agent Identity and Access Guide and the Prompt Injection Guide.
On-device, private cloud or public cloud
| Choose | When | Trade-offs |
|---|---|---|
| On-device only | Data is highly sensitive, offline use is needed, model is small, outputs are low-stakes or user-reviewed | Model is exposed; limited visibility; guardrails bypassable on rooted devices |
| Hybrid with attested cloud fallback | Larger tasks exceed device limits; you need server-side policy | Cloud path needs App Check or App Attest and server-held prompts; data leaves the device for some requests |
| Verifiable private cloud | Device-class privacy promises are needed for heavy models | Apple's Private Cloud Compute design (June 2024) sets requirements of stateless computation, enforceable guarantees, no privileged runtime access, non-targetability and verifiable transparency; few providers offer equivalent assurances |
| Cloud only | Model is proprietary and valuable, decisions are high-stakes, central monitoring is required | Network dependency, provider data handling, per-token cost |
Small organisations should mostly govern built-in OS features (policy, retention, DLP) and block unapproved local runtimes. Larger organisations shipping their own models need a model signing pipeline, attestation-backed backends and a mobile red-team pass. See the Confidential AI and GPU Enclaves Guide for server-side alternatives.
Implementation roadmap
- Discover: inventory OS AI features enabled per device, apps embedding models, and local runtimes (process names, listening ports, model directories such as
~/.ollama/models). - Set default policy: keep built-in features such as Recall disabled for managed devices until a risk review; pilot with a small ring and the retention, deny-list and DLP policies set.
- Control local runtimes: publish an approved runtime list, enforce loopback binding through configuration management, and block unapproved model downloads at the proxy.
- Secure the model pipeline for apps you ship: signed manifests, safe formats, encryption where the platform offers it, integrity check on load. Test by tampering with a model in a staging build and confirming the app refuses it.
- Harden the backend: require app attestation on every cloud fallback call, move system prompts and policy server-side, and remove any embedded keys.
- Test: include model extraction, model swap and prompt injection scenarios in mobile and endpoint red teaming. See the AI Red Teaming Guide.
- Roll back safely: keep a kill switch (remote config flag) to disable an on-device AI feature or force cloud-only mode if a model is found to be vulnerable, and a forced model update path.
Detection and measurement
- Endpoint signals: new listeners on model runtime ports, binds to 0.0.0.0, processes loading files with pickle-based extensions from user directories, changes to Recall policies or
OLLAMA_HOST, and large reads of AI data stores by unexpected processes. - Backend signals: requests failing app attestation, model version or hash mismatches reported by clients, and cloud fallback volume spikes that suggest an extracted key or repackaged app.
| Metric | Target |
|---|---|
| Managed devices with on-device AI features governed by explicit policy | 100 per cent |
| Local runtimes found listening on non-loopback interfaces | Zero |
| Shipped models with signed manifests verified at load | 100 per cent |
| Cloud fallback requests carrying a valid attestation token | Above 99 per cent |
| Embedded API keys found in app builds by secret scanning | Zero |
| Time to push a fixed model to 90 per cent of active installs | Tracked per release; under 14 days |
Common failure patterns
- Treating the model as a secret: putting proprietary rules or credentials into the model or system prompt and assuming encryption keeps them safe.
- On-device guardrails as the only control: relying on a local safety filter or liveness model for fraud or access decisions without server-side checks, inviting offline adversarial search.
- Exposed local inference servers: developers set
OLLAMA_HOST=0.0.0.0for convenience and leave an unauthenticated model API on office or home networks. - Loading pickle checkpoints from the internet: a downloaded model executes code on the analyst's workstation, which holds cloud and source-control credentials.
- Embedded cloud keys for fallback: the app calls a cloud LLM with a key in the binary, which is extracted and resold, as in many LLMjacking cases.
- Unreviewed AI data stores: snapshot or transcript databases enabled across a fleet with no retention, DLP or access review.
Framework mapping
| Control area | NIST CSF 2.0 | NIST SP 800-53 Rev. 5 | Other references |
|---|---|---|---|
| Inventory of AI features, models and runtimes | ID.AM-02 | CM-8 | CIS Controls v8.1 Control 2 |
| Model integrity and provenance | PR.PS-02, GV.SC-05 | SI-7, CM-14, SR-4 | OWASP LLM03:2025 Supply Chain; ATLAS AML.T0010 |
| Local AI data protection | PR.DS-01, PR.DS-10 | SC-28, SC-12 | OWASP LLM02:2025 Sensitive Information Disclosure; MASVS-STORAGE |
| App and model tamper resistance | PR.PS-06 | SI-7(15) | OWASP MASVS-RESILIENCE |
| Runtime exposure and least functionality | PR.PS-01, PR.IR-01 | CM-7, SC-7 | CIS Controls v8.1 Control 4 |
| Prompt injection and tool use | PR.AA-05 | AC-3, AC-6 | OWASP LLM01:2025 Prompt Injection; LLM06:2025 Excessive Agency |
| Monitoring | DE.CM-09 | SI-4 | ISO/IEC 27001:2022 A.8.16 |
NIST AI 100-2 E2025 (Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, March 2025) provides the shared vocabulary for evasion, poisoning, privacy and abuse attacks referenced above.
Practitioner checklist
- Inventory OS AI features, embedded models and local runtimes across managed devices.
- Govern built-in features such as Recall through
AllowRecallEnablement,DisableAIDataAnalysis, retention and deny-list policies. - Enforce loopback binding for local runtimes and block unapproved model sources.
- Load only safetensors, GGUF or signed formats; sandbox untrusted models.
- Sign and verify every model you ship, and use platform model encryption where available.
- Keep system prompts, business rules and API keys server-side; never in the app or model.
- Require app attestation for every cloud fallback call.
- Encrypt local embeddings, transcripts and caches with platform keystores and set retention.
- Scope assistant tool permissions and require confirmation for consequential actions.
- Maintain a kill switch and forced update path for on-device models.
Standards and references
- OWASP: Top 10 for LLM Applications 2025
- OWASP: Mobile Application Security Verification Standard
- MITRE ATLAS: Full AI Model Access
- NIST: AI 100-2 E2025 Adversarial Machine Learning
- Microsoft Learn: Manage Recall
- Android Developers: Gemini Nano
- Apple Developer: Encrypting a Model in Your App
- Apple Security Research: Private Cloud Compute
Related NHI Mgmt Group resources: AI Model Security Guide · Self-Hosted LLM Security Guide · Edge Computing Security Guide · Mobile App Security Guide · Model Supply Chain Guide