# Hugging Face model files can run hidden code

Published: 2026-10-12

Malicious model packages can execute code during unsafe loading. Three documented examples explain Pickle reverse shells, broken-file scanner behavior and research-demonstrated model-name confusion, with clear limits on the credential-theft claims.

Canonical: https://thedailydiff.dev/video/2026-10-12-huggingface-model-malware/

## What this video covers

- Numerical model weights, executable serialization and custom repository code are different things.
- JFrog and ReversingLabs documented reverse-shell payloads; their selected reports do not establish credential theft from named victims.
- Checkmarx Model Confusion was a research demonstration requiring a matching remote model and insecure loading.
- Prefer safetensors and patched loaders, review and pin custom code, and isolate unfamiliar packages from personal secrets and unnecessary network access.

## Questions and answers

### How can downloading a machine learning model run malicious code on my computer?

Downloading the bytes only puts the files on disk. The risk begins when an unsafe loader deserializes them. Pickle stores Python objects with instructions for rebuilding them, and a loader can follow those instructions and call functions while unpacking. JFrog documented a Hugging Face model whose Pickle payload opened a reverse shell, which offers remote command access.

### Did malicious Hugging Face models steal developers' credentials?

The selected reports do not establish that. JFrog and ReversingLabs documented reverse-shell payloads, but neither report establishes credential theft from named victims. The episode explains the exposure instead: code running as your user can read whatever that process can read, such as a mounted cloud key or an accessible token, if it has a network route out.

### What is model confusion in AI model supply chain attacks?

Checkmarx described a case where a missing local model path could resolve to a public repository with a matching name. Combined with remote code enabled and insecure loading, the wrong package could execute. It was a research demonstration involving an unnamed company's sample, which was corrected within a day.

### Why did broken Pickle files get past Hugging Face's malware scanner?

ReversingLabs reported two samples whose broken Pickle streams exposed a scanner blind spot. In the researchers' harmless test, instructions wrote a file before the loader reached the broken part and raised an error, so a model can fail to load after the dangerous part already ran. Hugging Face removed the reported samples within twenty four hours and changed the scanner.

### How should developers load untrusted models from Hugging Face safely?

The Daily Diff's verdict was NEEDS REVIEW. The episode recommends preferring safetensors and patched loaders, reviewing custom code and pinning the reviewed revision. Unfamiliar packages should run in isolation, without personal secrets and with restricted network access. A scanner error deserves investigation rather than being treated as a clean result.

## Chapters

- 0:00 How can a model download invite a guest?
- 0:35 How does a loader run the parcel's instructions?
- 1:09 Which secrets are inside the process's reach?
- 1:38 Why can a missing local path become a remote model?
- 1:55 How did broken packages evade the old scanner?
- 2:44 What keeps the key outside the guest's reach?
- 3:12 Why would I stamp this NEEDS REVIEW?

## Transcript

### How can a model download invite a guest?

0:00 A model file is just numbers on disk. Loading one malicious Hugging Face package opened a remote shell, which is an ambitious interpretation of local AI. How does loading become execution? Which secrets can it reach? What actually stops it? And keep one puzzle in mind. A model can fail to load after the dangerous part already happened.

0:18 This is The Daily Diff, under the hood. Hugging Face is a platform for sharing machine learning models, datasets and applications. Model weights are the learned numbers. A repository can also contain configuration and Python code. The danger here is executable packaging crossing into your computer when you load it. Pickle stores Python objects with instructions for rebuilding them.

### How does a loader run the parcel's instructions?

0:37 An unsafe loader can follow those instructions and call functions while unpacking. Downloading the bytes puts the parcel on your disk. Deserializing opens it. Somewhere, a file format has been promoted to unpaid system administrator. JFrog reported Goober Two in February twenty twenty four. Its Pickle payload opened a reverse shell, connecting outward to offer remote command access. The repository was deleted. JFrog also found clues suggesting researcher involvement,

1:02 so attribution is uncertain. The unwanted guest was documented. Credential theft from actual victims was not established.

### Which secrets are inside the process's reach?

1:09 Code running as your user can read whatever that process can read. A mounted cloud key or an accessible token becomes a possible target. Sending it out also needs a working network route. Numerical weights alone have no magic credential powers. Your permissions supply the interesting part of the model card. There is another door. Some models ask you to trust remote code, which authorizes Python from the repository. Safe tensor files can sit beside that code.

1:32 Checking the weight format covers one entrance, while the repository's code is still waiting for you to hand it a visitor badge.

### Why can a missing local path become a remote model?

1:38 Checkmarx demonstrated Model Confusion. A missing local model path could resolve to a public repository with a matching name. Combine that with remote code enabled, and the wrong package can execute. This was a research demonstration involving an unnamed company's sample, corrected within a day. A missing folder acquired a landlord. ReversingLabs reported two samples in February twenty twenty five,

### How did broken packages evade the old scanner?

1:58 calling the technique nullify AI. Both contained reverse shells. Their seven zip packaging blocked ordinary PyTorch loading, so this path required extraction and unsafe deserialization. Broken Pickle streams also exposed a scanner blind spot. A failed scan deserves investigation before anyone opens the parcel. In the researchers' harmless test, instructions wrote a file before the loader

2:18 reached the broken part and raised an error. Imagine opening a parcel, releasing the raccoon, then noticing the shipping label is invalid. The error message arrives with excellent grammar and terrible timing. Hugging Face removed the reported samples within twenty four hours and changed the scanner. That specific finding prompted a fix. A security scan is useful evidence, and treating every scanner error as a clean bill of health remains a remarkably generous interpretation of failure.

2:43 Prefer safe tensors and current patched loaders.

### What keeps the key outside the guest's reach?

2:46 PyTorch narrowed its default loader starting at version two point six. Review custom code and pin the reviewed revision. Run unfamiliar packages in isolation without personal keys, with restricted network access. A container full of mounted credentials is a gift basket with namespaces. That opening puzzle has an answer. Loading failure tells you where execution stopped. Earlier instructions may already have run.

3:08 Keep the secrets outside its reach before opening the parcel. Verdict, under the hood.

### Why would I stamp this NEEDS REVIEW?

3:16 loader. The free download should come with a model, and the guest list should remain my decision. If you'd rather read this than hear me say it, the diff lands in your inbox every morning, free at the daily diff dot dev, link below. And that's the diff for today. I'm Niko from Axrisi. Merge responsibly.

## Sources

- [Data Scientists Targeted by Malicious Hugging Face ML Models with Silent Backdoor](https://jfrog.com/blog/data-scientists-targeted-by-malicious-hugging-face-ml-models-with-silent-backdoor/) — JFrog
- [Malicious ML models discovered on Hugging Face platform](https://www.reversinglabs.com/blog/rl-identifies-malware-ml-model-hosted-on-hugging-face) — ReversingLabs
- [AI Model Confusion: An LLM/AI Model Supply Chain Attack](https://checkmarx.com/zero-post/hugs-from-strangers-ai-model-confusion-supply-chain-attack/) — Checkmarx Zero
- [Pickle Scanning](https://huggingface.co/docs/hub/en/security-pickle) — Hugging Face
- [Safetensors](https://huggingface.co/docs/safetensors/en/index) — Hugging Face
- [Loading custom models](https://huggingface.co/docs/transformers/en/models) — Hugging Face
- [Serialization semantics](https://docs.pytorch.org/docs/2.14/notes/serialization.html) — PyTorch
