Join our Newsletter — 33% off our NHI Course
Home› Guides› On-Device AI Security Guide: Protecting Local Models and…
Guide AI Threats & Model Security

On-Device AI Security Guide: Protecting Local Models and Data

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 26 October 2026 15 min read
On this page

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_HOST to 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

AspectCloud-hosted modelOn-device modelSecurity consequence
Model weightsBehind an API; attacker sees only outputsFile on the device, loaded into user-space or system memoryWhite-box access enables extraction, cloning and crafting adversarial inputs offline
User dataSent over the network, processed and possibly logged by the providerStays on the deviceSmaller interception and provider risk; larger local data store risk
GuardrailsServer-side filters you control and updateShipped with the app or OS; can be bypassed on a rooted deviceTreat on-device filters as advisory; enforce policy server-side for anything consequential
UpdatesInstant, centralThrough app store, OS update or model downloadVulnerable or poisoned models persist in the field longer
MonitoringCentral logs of prompts and outputsLittle or no central visibilityAbuse and misbehaviour are hard to detect; telemetry must be designed in with privacy limits
Cost of abuseMetered per tokenFree to the attacker once extractedUnlimited 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 deviceATLAS techniqueMain controls
Copying the model file out of the app package or memoryAML.T0044 Full AI Model Access; AML.T0035 AI Artifact CollectionPlatform model encryption, app attestation, no secrets in the model or prompt, licensing terms
Replacing the model in a repackaged app to change behaviourAML.T0018 Manipulate AI ModelSignature and hash checks before load, app integrity checks, store-only distribution
Poisoned model or adapter downloaded at runtimeAML.T0010 AI Supply Chain Compromise; AML.T0058 Publish Poisoned ModelsSigned model manifests, pinned sources, safe serialisation formats
Offline search for adversarial inputs against a white-box modelAML.T0043 Craft Adversarial Data; AML.T0005 Create Proxy AI ModelServer-side verification for high-stakes decisions; do not use on-device models as the only fraud or liveness check
Malicious content steering a local assistantAML.T0051 LLM Prompt InjectionLeast-privilege tools, confirmations, content provenance labels
Local AI index or chat history leaking sensitive dataAML.T0057 LLM Data LeakageEncryption bound to user authentication, retention limits, DLP filtering
Unauthenticated local inference API reachable on the networkAML.T0040 AI Model Inference API AccessLoopback 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 .mlmodelkey file tied to your development team, and encrypt the bundled model at compile time by adding --encrypt with 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.

ControlHow Recall implements it (Microsoft Learn)Question to ask of other on-device AI features
Off by defaultDisabled and removed by default on commercially managed devices; users must opt in; admins cannot turn on snapshot saving for usersIs it opt-in, and can IT block it centrally?
Encryption bound to the userSnapshots and vector database entries always encrypted; keys protected by the TPM, tied to Windows Hello Enhanced Sign-in Security and used inside a VBS enclaveCan another local user, an admin or malware running as the user read the store?
Strong local authenticationRequires Windows Hello ESS with a biometric before launch and before saving starts; BitLocker or Device Encryption must be onIs access to the AI store re-authenticated?
Sensitive data filteringOn by default; runs on the NPU using the Microsoft Classification Engine and skips snapshots with detected sensitive information; Purview DLP integration per windowDoes it skip passwords, card numbers and labelled content?
RetentionPolicies SetMaximumStorageDurationForRecallSnapshots (30, 60, 90 or 180 days) and SetMaximumStorageSpaceForRecallSnapshotsCan retention be capped by policy?
ExclusionsSetDenyAppListForRecall, SetDenyUriListForRecall; apps can call SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURECan 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 setting 0.0.0.0:11434 to 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 by OLLAMA_ORIGINS; avoid wildcards such as chrome-extension://*, which lets every installed extension call the model.
  • Unexpected cloud use: Ollama can route to cloud-hosted models; set "disable_ollama_cloud": true in ~/.ollama/server.json or OLLAMA_NO_CLOUD=1 where 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-server on 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

ChooseWhenTrade-offs
On-device onlyData is highly sensitive, offline use is needed, model is small, outputs are low-stakes or user-reviewedModel is exposed; limited visibility; guardrails bypassable on rooted devices
Hybrid with attested cloud fallbackLarger tasks exceed device limits; you need server-side policyCloud path needs App Check or App Attest and server-held prompts; data leaves the device for some requests
Verifiable private cloudDevice-class privacy promises are needed for heavy modelsApple'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 onlyModel is proprietary and valuable, decisions are high-stakes, central monitoring is requiredNetwork 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

  1. Discover: inventory OS AI features enabled per device, apps embedding models, and local runtimes (process names, listening ports, model directories such as ~/.ollama/models).
  2. 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.
  3. Control local runtimes: publish an approved runtime list, enforce loopback binding through configuration management, and block unapproved model downloads at the proxy.
  4. 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.
  5. Harden the backend: require app attestation on every cloud fallback call, move system prompts and policy server-side, and remove any embedded keys.
  6. Test: include model extraction, model swap and prompt injection scenarios in mobile and endpoint red teaming. See the AI Red Teaming Guide.
  7. 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.
MetricTarget
Managed devices with on-device AI features governed by explicit policy100 per cent
Local runtimes found listening on non-loopback interfacesZero
Shipped models with signed manifests verified at load100 per cent
Cloud fallback requests carrying a valid attestation tokenAbove 99 per cent
Embedded API keys found in app builds by secret scanningZero
Time to push a fixed model to 90 per cent of active installsTracked 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.0 for 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 areaNIST CSF 2.0NIST SP 800-53 Rev. 5Other references
Inventory of AI features, models and runtimesID.AM-02CM-8CIS Controls v8.1 Control 2
Model integrity and provenancePR.PS-02, GV.SC-05SI-7, CM-14, SR-4OWASP LLM03:2025 Supply Chain; ATLAS AML.T0010
Local AI data protectionPR.DS-01, PR.DS-10SC-28, SC-12OWASP LLM02:2025 Sensitive Information Disclosure; MASVS-STORAGE
App and model tamper resistancePR.PS-06SI-7(15)OWASP MASVS-RESILIENCE
Runtime exposure and least functionalityPR.PS-01, PR.IR-01CM-7, SC-7CIS Controls v8.1 Control 4
Prompt injection and tool usePR.AA-05AC-3, AC-6OWASP LLM01:2025 Prompt Injection; LLM06:2025 Excessive Agency
MonitoringDE.CM-09SI-4ISO/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

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

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 26 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.