Join our Newsletter — 33% off our NHI Course
Home FAQ Threats, Abuse & Incident Response What breaks when ML systems deserialize untrusted model…
Threats, Abuse & Incident Response

What breaks when ML systems deserialize untrusted model files?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated August 19, 2026 Domain: Threats, Abuse & Incident Response

Untrusted deserialization turns a data-loading step into code execution, because the loader may reconstruct attacker-controlled objects and run embedded logic. That can expose secrets, alter model behaviour, or let an attacker pivot into the workload’s cloud permissions. The safe assumption is that any pickle-like loader is an execution boundary, not a parsing boundary.

Why This Matters for Security Teams

When ML systems deserialize untrusted model files, the issue is not just malformed input. The loader may reconstruct attacker-controlled objects, trigger embedded logic, and inherit the runtime’s own permissions. That means a model artifact can become a delivery vehicle for secret theft, environment tampering, or cloud pivoting. This is the same kind of trust failure seen in real-world NHI incidents, including the Hugging Face Spaces breach, where access paths and workload trust boundaries mattered as much as the payload itself.

Security teams often underestimate how quickly a “data file” becomes an execution boundary in ML pipelines. A deserializer runs before the model is even validated, so compromise can occur upstream of detection, logging, or sandboxing. NHI Mgmt Group’s guide to non-human identities notes that 80% of identity breaches involved compromised non-human identities, which is a useful reminder that workloads, service accounts, and automation tokens are frequently the real blast radius once code execution begins. The same pattern is why NIST SP 800-63 Digital Identity Guidelines should be read alongside ML trust decisions, even when the system is not human-facing.

In practice, many security teams encounter deserialization abuse only after a model supply-chain incident has already exposed the runtime and its credentials.

How It Works in Practice

The failure mode starts when a training artifact, checkpoint, or serialized model bundle is loaded with a format that supports object reconstruction rather than plain data parsing. In those cases, the loader can instantiate attacker-chosen classes, invoke callbacks, or resolve references that were never meant to be trusted. For ML platforms, the practical answer is to treat model loading as a privileged operation and to reduce the loader’s reach before the file is ever opened.

Current guidance suggests combining file-format restrictions with workload controls. Prefer safe serialization formats where possible, and ban general-purpose pickle-like loaders for untrusted sources. Validate provenance before ingestion, isolate loading in a hardened sandbox, and remove broad network and filesystem access from the deserialization process. For identity and access, the workload should run with the minimum permissions needed to load and inspect the artifact, not with permissions intended for training, deployment, or production inference. That is where NHI controls become relevant: the model loader, the CI job, and the serving pod all behave like non-human identities with distinct trust boundaries.

  • Verify artifact origin, checksum, and signing before load.
  • Use ephemeral credentials and short-lived tokens for the loader process.
  • Separate inspection, conversion, and deployment into different identities.
  • Restrict egress so a malicious payload cannot call out or exfiltrate secrets.
  • Log deserialization events as security events, not just application events.

NHI Mgmt Group’s Ultimate Guide to Non-Human Identities is especially relevant here because compromised workload identities often become the mechanism for follow-on access once code execution has been achieved. The same operational principle is reflected in NIST SP 800-53 Rev 5 Security and Privacy Controls, which emphasises controlled access, separation of duties, and auditable system activity. These controls tend to break down when model files are ingested automatically from shared registries because trust is inherited from convenience rather than verified per artifact.

Common Variations and Edge Cases

Tighter deserialization controls often increase operational overhead, requiring organisations to balance developer convenience against artifact trust and runtime isolation. That tradeoff is especially visible in environments that convert models across frameworks, because each conversion step can reintroduce unsafe object handling or hidden dependencies. There is no universal standard for this yet, so best practice is evolving around secure-by-default formats, strict provenance checks, and isolated conversion pipelines.

One important edge case is “trusted source” blindness. A model from an internal team, partner registry, or popular community hub can still be dangerous if the file format allows code execution. Another is the mixed-trust pipeline, where a scanner approves the artifact but the production loader uses a different library version with a broader attack surface. In those situations, the question is not whether the file is malicious in the abstract, but whether the deserializer can be forced to cross a trust boundary.

For governance, the most useful framing is to classify model loading as an execution control point, then align it to identity, privilege, and provenance requirements. In practice, teams that miss this usually assume the risk ends at model validation, when in reality the highest-risk step is often the first parse after download.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-03Deserialization abuse often leads to exposed or unrotated workload secrets.
OWASP Agentic AI Top 10A2Untrusted model artifacts can trigger unintended execution paths in AI runtimes.
CSA MAESTROTR-4Covers trust boundaries and supply-chain risks in AI system inputs and artifacts.
NIST AI RMFSupports risk-based controls for AI lifecycle inputs and runtime exposure.
NIST CSF 2.0PR.DS-6Addresses integrity of data at rest, including model artifacts and checkpoints.

Verify artifact provenance and isolate conversion or loading steps from production access.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on August 19, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org