Safeguard
Supply Chain•

Can you load a model from a Hugging Face pull request, and should you?

The Hub lets you download from a tag, branch, pull request ref or commit. Why a pull request ref is the weakest pin, and what to use in production.

Safeguard Security Team
3 min read

You can. The huggingface_hub revision parameter accepts a tag, a branch, a pull request ref such as refs/pr/3, or a full commit hash. For production use only the full commit hash, because the other forms can point at different content later or at content the owner has not reviewed.

The four things revision accepts

The download guide gives these examples for hf_hub_download: a tag like v1.0, a branch like test-branch, a pull request reference like refs/pr/3, and a specific commit hash. It also notes that a commit hash must be the full length hash, not a 7 character short form.

Revision typeCan it move?Who controls itFit for production
BranchYes, on every pushRepo ownerNo
TagTags are labels in git and can be re-pointed by someone with write accessRepo ownerWeak
Pull request refContributors can add commits to itContributor and ownerNo
Full commit hashNo, it names one commitFixed once publishedYes

The tag row reflects how git tags work in general, not a Hub specific promise. Check the Hub's behavior for your case before you depend on tags staying fixed.

Why the pull request ref is special

A pull request on a model repo is a proposed change that can come from a contributor, not only from the owner. The Hub's webhook documentation notes that new pull requests create a new reference and commit. Loading from refs/pr/3 means loading content that the owner may not have approved or even read.

Teams sometimes do this on purpose to test a fix before it is merged. That is fine in a scratch notebook. It is a poor fit for a pipeline, because the ref can receive new commits after you tested.

What to do instead

  1. In code, pass the full 40 character commit hash as the revision.
  2. Store the hash in a config file under version control, so changes appear in review.
  3. If you need a fix from a pull request, wait for the owner to merge it, or copy the reviewed files into your own storage and pin your copy.
  4. Check that the downloaded snapshot folder in the cache is named for that exact hash. The cache documentation says each known revision gets its own snapshot folder.
  5. Add a test that fails if the revision value is not a 40 character hex string.

A test you can write today

A simple check in your repository can scan code and config for model download calls and flag any that omit a revision or use a short value. This is cheap, catches drift early, and does not depend on any one library.

Quick check

Is a seven character commit hash accepted as a revision?

The download guide says it must be the full length hash, not a 7 character one.

Is a tag as safe as a hash?

No. In git a tag is a label that can be moved by someone with write access. A full hash names one commit.

Safeguard's policies and gates can hold a pull request that changes dependency pins, and its dependency scanning covers the packages around the model. Try the free scan.

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.