Safeguard
AI Security•

Does Hugging Face scanning make a model safe to load?

Hub scans for malware and pickle imports help, but the host says they are not foolproof. Here is what they check and what you still need to do yourself.

Safeguard Security Team
4 min read

No. Hub scanning is a useful signal, not a safety guarantee. Hugging Face runs a malware scan and a pickle import scan, and it states that the pickle scan is not 100 percent foolproof and that users are responsible for checking whether something is safe. Treat a clean badge as the start of review.

What the Hub scans

Two scans are described in the documentation.

  • Malware scanning. Every file in a repository under 2 GB is run through a malware scanner at each commit. If at least one file is flagged unsafe, users see a warning.
  • Pickle import scanning. When a pickled file is uploaded, the Hub extracts the list of imports it references and shows them beside the file. Suspicious imports are highlighted.

The pickle scan reads the file with pickletools, which can read instructions without running them. That is a sensible design, since it does not execute the thing it inspects.

What the documentation says about limits

Hugging Face is direct about this. It says the pickle scan is not 100 percent foolproof, that it is the user's responsibility to check whether something is safe, and that the safe and unsafe import lists are maintained on a best effort basis. It also says it is not actively auditing Python packages for safety.

It also explains that the antivirus scan covers a good amount of dangerous files but does not cover pickle exploits, which is why the second scan exists.

What a scan cannot tell you

QuestionCan a file scan answer it?
Does this pickle import a known dangerous function?Often, with best effort lists
Is the modeling code in the repo doing something unexpected?Only if it looks like known malware
Is the training data or the weights behavior safe?No
Did the publisher change the repo since you reviewed it?No, pin a commit
Is this account who it claims to be?No, look at signed commits and history

What you add on top

  1. Prefer non-pickle formats. Safetensors is the common choice.
  2. Load weights with restrictions. In PyTorch, use weights_only=True.
  3. Pin the commit. Our guide on pinning a model to a commit shows how.
  4. Avoid remote code by default. Review it first if you need it.
  5. Use a sandbox for the unknown. No credentials, no network, throwaway storage.
  6. Write down the decision. Who approved this model, when, and from which commit.

How to explain this to a manager

A short version works well: the platform is checking for known bad patterns, and we are checking whether this specific model is right for our environment. Both checks are needed. The first catches the obvious, and the second catches what only we know about our setup.

Where Safeguard fits

For the code and packages around the model, Safeguard offers SBOM and dependency scanning, reachability analysis and policy gates. A free scan is at gold.safeguard.sh/scan. For background, read AI model supply chain attacks.

Quick check

If a file shows no warning on the Hub, can I skip review?

No. A missing warning means the scanners found nothing they know about. Documentation from the host says users remain responsible for the safety check.

Do scans check model behavior?

The scans described in the docs look at files and pickle imports. They do not test how a model behaves.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.