AML.T0148 · Embed Malicious Code in AI Artifacts

Explore 3 source-supported AI security cases for AML.T0148 · Embed Malicious Code in AI Artifacts in MITRE ATLAS, with evidence, scope, and defensive analysis.

Risk category

Adversaries may embed executable payloads in AI artifacts or their bundled components to cause malicious code to run when the artifacts are deserialized, loaded, used for training or inference, or otherwise processed. Payloads may be carried in serialized objects, executable model components, metadata, configuration files, or associated scripts. Execution depends on how the consuming software loads, interprets, or invokes the affected components. Adversaries may abuse serialization features of common model file formats that invoke code during object reconstruction, allowing payloads to execute during deserialization.[[python-pickle]] They may also place executable code in model layers, such as Keras Lambda layers, that run during loading, training, or inference while preserving expected model outputs.[[model-confusion]][[models-are-code]] Model computation graphs may contain operations that perform unauthorized file reads or writes through functionality supported by the AI framework.[[models-are-code]] Adversaries may place payloads in artifact metadata, configuration files, or templates that a loader or runtime interprets to invoke functions or evaluate code. Execution may result from unsafe configuration processing or vulnerabilities in template interpretation.[[model-metadata-rce]][[gguf-template-rce]] They may also embed malicious functionality in custom model implementations or scripts distributed with an artifact, which execute when the consuming workflow imports or invokes that code.[[custom-model-code]][[malhug]] Payloads may be concealed within model parameters or other artifact data and reconstructed by an embedded loader. Researchers demonstrated hiding a malware payload in tensor values and using code invoked during deserialization to recover and execute it.[[weaponizing-models]] An artifact may retain its expected AI functionality while the payload performs malicious actions. Activation may rely on [User Execution: Unsafe AI Artifacts](/techniques/AML.T0011.000), but may also be triggered by an adversary via [Exploit Automated Artifact Processing Pipeline](/techniques/AML.T0119) or [Event Triggered Execution](/techniques/AML.T0142).

Official framework source ↗ · Open interactive explorer ↗

Incident ·

Malicious Models on Hugging Face

Researchers at ReversingLabs have identified malicious models containing embedded malware hosted on the Hugging Face model repository. The models were found to execute reverse shells when loaded, which grants the threat actor command and control capabilities on the victim's system. Hugging Face uses Picklescan to scan models for malicious code, however these models were not flagged as malicious. The researchers discovered that the model files were seemingly purposefully corrupted in a way that the malicious payload is executed before the model ultimately fails to de-serialize fully. Picklescan relied on being able to fully de-serialize the model. Since becoming aware of this issue, Hugging Face has removed the models and has made changes to Picklescan to catch this particular attack. However, pickle files are fundamentally unsafe as they allow for arbitrary code execution, and there may be other types of malicious pickles that Picklescan cannot detect.

ATLAS annotations follow the source SecureFlow steps; they are not a MITRE endorsement of cross-framework mappings.

SecureFlow · Read the full case ↗

Validated Research ·

Organization Confusion on Hugging Face

threlfall_hax (https://5stars217.github.io/), a security researcher, created organization accounts on Hugging Face, a public model repository, that impersonated real organizations. These false Hugging Face organization accounts looked legitimate so individuals from the impersonated organizations requested to join, believing the accounts to be an official site for employees to share models. This gave the researcher full access to any AI models uploaded by the employees, including the ability to replace models with malicious versions. The researcher demonstrated that they could embed malware into an AI model that provided them access to the victim organization's environment. From there, threat actors could execute a range of damaging attacks such as intellectual property theft or poisoning other AI models within the victim's environment.

ATLAS annotations follow the source SecureFlow steps; they are not a MITRE endorsement of cross-framework mappings.

SecureFlow · Read the full case ↗

Validated Research ·

Model Namespace Reuse Turns a Trusted Name Into a Supply-Chain Redirect

Unit 42 showed that a deleted Hugging Face author namespace, or a transferred model whose former author namespace later becomes reclaimable, can leave stale references pointing to a name another party can register. In controlled tests, researchers reclaimed abandoned namespaces, recreated expected model paths, and made Vertex AI and Azure AI Foundry deployments load reverse-shell models. The original publisher account was not compromised. Defenders should bind deployments to immutable digests and signers, monitor namespace lifecycles, mirror approved artifacts internally, and isolate model loading.

ATLAS annotations follow the source SecureFlow steps; they are not a MITRE endorsement of cross-framework mappings.

AIA · Read the full case ↗ · SecureFlow · Read the full case ↗