Scanning Hugging Face models before use with ModelAudit

Teams that pull models from Hugging Face need a checkpoint before files reach a training job, notebook or serving host. This page explains how ModelAudit scans public and private repositories, how HF_TOKEN is handled, and how a model allowlist turns scan results into an intake decision.

On this page

Why scan Hugging Face models before use with ModelAudit

Engineers pull public and private models from Hugging Face straight into environments that hold data, credentials and internal network access, often with a single command. ModelAudit performs static scanning of model files before they are loaded, so the file is inspected without its code being run. It works best as one gate in an intake process that also keeps an allowlist of approved sources and model repositories, so a scan is never the only decision point. The allowlist answers whether a model is permitted at all, and the scan answers whether this exact file is acceptable. Both questions need a named owner, and the team should agree on who can add an entry before the first download happens.

A clean scan is evidence that supports a decision. It does not prove that a model is safe. Static scanning reads file structure and flags known risky patterns, so it can miss payloads that no rule covers, behavior that appears only at inference time, and problems in the surrounding code that loads the model. Record what was scanned, identified by file hash and repository revision, together with the result, so a reviewer can see what the decision rested on. The format-specific detail is covered in the sibling topics on pickle and PyTorch files, on GGUF, SafeTensors and ONNX files, and on the storage backends and CI/CD pipelines where scans run.

Your intake process should state what happens to each outcome. A rejected model stays out of the environment, and an accepted model is recorded against its exact revision, so a later update from the same repository triggers a new review and does not inherit the earlier result. Confirm with your security team which Hugging Face accounts and organizations are on the allowlist, who approves changes, and whether private models need an HF_TOKEN with read-only access that the scanning job can use without spreading the token to other systems. Those answers decide how much of this process you can automate and how much stays a manual review.

Public, private and allowlisted Hugging Face sources compared

This table compares four ways to bring a Hugging Face model into ModelAudit scans: public access, token-based access, pinned revisions and an approved allowlist. Read each row for the situation it suits, the risk it reduces and the operational cost it adds. The main takeaway is that a scan only describes the exact files it read, so combine a pinned revision with an allowlist and confirm token and flag syntax in the current ModelAudit and Hugging Face documentation before you write procedures.

Intake optionWhen it fitsWhat it protects againstWhat it adds to operations
Public repository, no tokenOpenly published models with a known owner, where anonymous read access is acceptable to your policy.Malicious code in model files, since ModelAudit inspects the files whatever their source.Lowest setup. Confirm anonymous access limits and how ModelAudit handles a public download in its documentation.
Private or gated repository with HF_TOKENModels under license acceptance or held by your organization, where anonymous download is not allowed.Exposure of internal models and accidental scans of the wrong copy.A token to issue, store, rotate and limit to read access. Confirm HF_TOKEN usage and token scopes in both docs.
Pinned revisionAny model you approve, so the scanned files are the files you deploy.Silent changes to a repository after your scan, including updates pushed under the same name.A commit hash in the approval record and a rescan per update. Confirm revision syntax in ModelAudit docs.
Allowlist of approved repositoriesTeams that may request many models and need a fixed set of sources that someone has vetted.Typosquatted or unvetted repositories entering through a typed name or a pipeline variable.An owner, a request process and periodic review of entries. Confirm whether ModelAudit enforces the list or your pipeline must.
Combined controlsProduction models that need a known source, a fixed version and an audit trail.Most intake risks at once, since each control covers a gap left by the others.The most setup and review effort, which recurs with each new model or version.

Setup sequence for scanning Hugging Face models before use

This sequence takes a team from an empty scanning environment to a repeatable intake check for Hugging Face models, covering the runtime, the tool, a scoped token and a rejection test. It ends with a recorded scan of one public and one private model that a reviewer can reproduce. Each step names the check that shows it is done.

  1. Confirm the Node.js runtime version

    The engineer running the scan checks the Node.js version on the scanning host or runner image. If ModelAudit runs through promptfoo, note that the promptfoo npm release 0.124.1, published on 8 October 2026, requires Node.js 22.22.0 or newer, so older runtimes are not supported for that release. Record the output of node --version in the intake ticket. Done when every machine and runner that will execute scans reports 22.22.0 or higher.

  2. Install ModelAudit standalone or through promptfoo

    The platform engineer installs ModelAudit in the scanning environment, either as a standalone tool or through promptfoo, using the installation method your team has approved. Pin the version in a lockfile or the scanning image so every scan runs the same code, and write that version into the scan record. Done when the installed tool reports its version and its help output runs on the scanning host.

  3. Create a read-scoped Hugging Face token

    A security engineer creates a Hugging Face access token limited to read access and scoped to the private repositories approved for scanning. Confirm in Hugging Face's current token documentation which token types can be restricted to named repositories, since that sets how tightly you can scope it. The token should belong to a service identity your organization controls. Check that it reads the approved private repository and that a read request to a repository outside its scope is refused.

  4. Store the token in the secret manager

    The platform team saves the token in the organization's secret manager under a named entry and grants read access only to the identity that runs the scanning job. Inject it into that job as the environment variable HF_TOKEN, and keep it out of repository files, container images and shared CI variables visible to other projects. Check that a job without the scanning role cannot retrieve the secret and that the value does not appear in job logs during a test scan. Done when both checks pass.

  5. Set the allowlist and test a rejection

    The intake owner writes the list of Hugging Face repositories approved for scanning, using exact repository identifiers with no wildcards. Then the owner submits one deliberately unapproved repository to the intake job. Check that the job refuses it before any model file is downloaded, and confirm the refusal in the job logs. This check matters because the allowlist is enforced by the intake job around ModelAudit, so that job must block the download on its own.

  6. Scan one public and one private model

    The security engineer runs the intake scan on one public model and one private model from the approved list. HF_TOKEN is supplied only to the private scan. Check that the public scan completes without a token, and that the private scan succeeds with the token and fails when the variable is removed, which shows the token is what grants access. Note the findings for each model, including any warnings the scanner raises about files it could not assess.

  7. Record the scan output for review

    The engineer saves each scan report with the repository identifier, the revision or commit hash fetched, the ModelAudit and promptfoo versions, the Node.js version and the secret's name, never its value. The reviewer records an accept or reject decision beside each report. Check that a second engineer can open the record and identify which tool version, repository revision and token scope produced each result. Done when both reports are filed in the model intake system and linked to the approval ticket.

How a Hugging Face model moves through scan and allowlist checks

The flow starts when someone requests a repository, and the allowlist check runs before any download. Approved repositories are fetched from the Hugging Face network, using HF_TOKEN for private ones, and the file crosses into the internal scanning job at the trust boundary. ModelAudit scans the file inside that isolated job. A reject decision ends the path, so the model is never loaded. An accepted file is promoted to the environment where it will be loaded. Before you adopt this flow, confirm the token's scope, that allowlist entries name exact repositories, and that the promoted file matches the scanned copy.

Intake path from allowlist check to promotion, with the Hugging Face trust boundary shown.

Four controls that work together during intake

Each control closes a gap the others leave open. The allowlist limits where models come from, pinning fixes which bytes get reviewed, token handling governs access to private and gated models, and scanning checks the files before anything loads them. None of the four is sufficient alone, so an intake decision depends on all of them and on the evidence each one leaves.

Allowlist of approved repositories

The allowlist records which Hugging Face repositories your teams may pull from, so a model cannot enter because someone copied a name from a forum post or a notebook. Without it, a typosquatted or lookalike repository can pass for the one you meant. Security or platform engineering maintains the list, and model owners request additions through a change ticket. Check the list in version control, the named approver on each entry, and whether the loader refuses repositories outside it.

Revision pinning for the scanned file

A repository's main branch can change after you scan it, so the weights your service loads may not be the ones ModelAudit reviewed. Pin the loader to a specific commit hash and record that hash alongside the scan report. The team that writes the loading code owns the pin, and each update happens only after the new revision is scanned. Check that the hash in the scan record matches the revision in the loader configuration and in the deployed artifact.

Token handling for gated repositories

Private and gated repositories need an access token, and how that token is stored decides who can read or change those models. Supply HF_TOKEN from a secrets manager, and keep it out of source files, container images and shell history. Use a read-only token scoped to the models each pipeline needs. The platform or identity team issues and rotates tokens. Check the token inventory, rotation records, secret access logs and whether CI output masks the token value.

Scanning before any load step

Some model formats run code when they are deserialized, so a notebook that calls a load function can execute a payload before anyone reads a scan report. Run ModelAudit on the exact downloaded files before a notebook, serving container or conversion job touches them. The pipeline owner places the gate, and the serving platform should refuse artifacts that lack a passing report. Check that the gate covers every path that reaches a loader, including ad hoc notebooks.

What a scan of a Hugging Face model can and cannot tell you

A clean ModelAudit result means the model files did not match the patterns the scanner checks for. The scan looks inside model files for content that can run code or carry risk when the file is loaded, such as embedded serialized objects, unexpected operators and suspicious metadata. It does not establish what the model was trained on, how well it performs, whether it reproduces biased outputs, or whether its license allows your use. Those properties belong to the weights and their history, so a file scan cannot answer them. Read the scan as one control that answers one question: does loading these bytes run something you did not intend? The format-specific checks for pickle, GGUF, SafeTensors and ONNX files are covered on their own sibling pages.

Before a clean scan leads to an accept decision, review what the scanner cannot see. Read the model card for stated training data, intended use, evaluation results and known limitations. Check the license on the repository and on any base model the weights were derived from, because a fine-tune can carry constraints from its parent. Then check provenance: whether the repository belongs to the original developer or to a re-upload, who has write access, and whether the revision you scanned is the one you will deploy. Pin that exact commit, and rescan if it changes. Confirm license terms with your legal team, because a label on a repository does not settle what you may do with the weights.

The last gate is a behavioral test run against the model itself, before it serves users. Build prompts from your own use case, include adversarial inputs, and compare the outputs with the behavior your reviewers approved. This catches backdoors, unwanted behavior and regressions that a file scan cannot detect. Agree in advance who signs off, what pass criteria apply, and whether a model update repeats the full cycle of scan, review and behavioral test. As an illustrative example, a team approving a model for customer support might test refusal behavior and answers to its own product questions before release.

Keeping HF_TOKEN safe when scanning Hugging Face models before use

The Hugging Face token and the model files it fetches are the two things a scan can expose, so these cards cover how to hold the token and how long copies of the files persist. Work through them before the first scan runs, because a leaked token or a stale cache is harder to contain once it has reached a log or a shared host.

Least-privilege token scope

Give the scanning job a read-only token, or a fine-grained token limited to the repositories the scan needs, where your Hugging Face account offers that option. ModelAudit only needs to read the files it inspects, so a token that can write to repositories or change organization settings adds risk without adding scan value. Check the token's permissions in your Hugging Face account settings before the first run, and confirm with your organization administrator which private or gated repositories it can reach.

Store the token in a secret manager

Keep HF_TOKEN in your CI secret store or a dedicated secret manager, and inject it into the scan job at runtime. A value typed into an interactive shell can land in shell history, and a value written into a .env file, a script or a container image layer travels with the code and every copy of it. Never commit the token to a repository, and confirm that the scanning host has no plain-text copy in its home directory or configuration files.

Separate scanning and download tokens

Use one token for ModelAudit scans and a different token for any job that pulls a model into a production environment. If the production token leaks, the scanning token stays outside the production path, and each token's use is easy to trace in your audit records. Assign each token an owner, record which pipeline uses it, and revoke each token on its own when a team member leaves or a pipeline is retired.

Log scans without printing the token

Verbose flags, debug traces, crash reports and CI console output can capture environment variables and command lines, so a careless setting can print the token into a stored log. Mask the variable in your CI platform, avoid passing the token as a command-line argument where process listings can show it, and run one deliberately failing scan to see what the logs contain. Search the stored logs for the token value after that test and after each change to the scan configuration.

Rescan when files or revisions change

A ModelAudit result describes a specific set of files at a specific revision. If a repository adds, replaces or edits a file, or the revision your pipeline resolves moves, the earlier accept decision no longer describes what would load. Pin the revision you scanned, store it with the result, and rescan before any new revision reaches an environment. Treat a changed revision as a new model until it passes the scan again.

Confirm secret lifetimes and cache retention

Ask the owners of your CI runner and scanning host how secrets are stored, who can read them, and how often they expire or rotate. Also confirm how long downloaded model files stay in the local cache before deletion, since large weights can persist on a shared host after the scan finishes. Get both answers in writing from the platform owners, and record them in the model intake runbook before the first production scan.

How much effort does scanning Hugging Face models before use take?

What does it cost to scan Hugging Face models before use?

Cost comes from four parts: internal engineering time, token administration, allowlist governance and any paid support. Engineering time is usually the largest variable, because someone has to wire the scans into intake, decide what passes and keep that decision current. Token administration covers creating Hugging Face access tokens with the narrowest scope the platform allows, storing them in your secrets manager and rotating them. Allowlist governance is the review that approves each model and version. Paid support is optional. promptfoo is MIT licensed, and its Community edition is free, while its Enterprise tier adds priority support with SLAs at custom pricing. Confirm which features you need sit in each edition. DeployOpen quotes outside work from a written, fixed scope, and no price list is published.

Which parts of model scanning are one-time and which recur?

Setup is one-time, and the recurring work is rescanning and allowlist changes. One-time work includes choosing the scan configuration, placing HF_TOKEN in your secrets store, connecting the scan to your intake path and writing the rule for what passes. Recurring work includes rescanning when a model or repository changes, reviewing new allowlist entries, rotating tokens on your schedule and keeping the scanner itself up to date. The recurring load tracks how many models you admit and how often they change. Ask any partner whether its scope covers handing these routines over to your team or includes an ongoing retainer, since retainers are priced separately from the initial build.

What makes scanning Hugging Face models take more effort?

Effort grows with the size and churn of your model intake. The main drivers are:

  • Number of repositories: each repository needs its own allowlist entry, an owner review and a pinned version.
  • Private and gated access: each one needs a token with the right scope, and access has to be tested for every account that pulls models.
  • Large files: multi-gigabyte weights need more scan time and resource limits, so plan capacity and timeouts before running them in CI.
  • CI integration: gating builds requires exit-code handling, result caching and a failure path that developers can act on.

Each driver adds work both to the initial setup and to the recurring review, so estimate them together rather than one at a time.

Can our in-house team scan Hugging Face models without a partner?

Yes, if you have engineers who can run a command-line scanner, manage secrets and add a gate to your pipeline. ModelAudit is a documented tool, so a small team can run it on its own, and the deciding factor is usually ownership over time. The work that tends to stall in-house is governance: someone must own the allowlist, review requests from data science teams and keep the policy consistent when staff change. Check three things before deciding: whether you have a named owner for approvals, whether your CI platform already stores secrets safely and whether anyone has time to review rescans on a regular basis. DeployOpen can plan, implement, document and support this inside your environment if you prefer to hand it over.

What does a partner need from us to scope the work?

Before a quote, a partner needs a list of the model sources and repositories you use, the access model for public and private models and the platforms where scans must run. Useful additions include your current intake process, your CI system and runner setup, where model artifacts are stored and the people who approve new models. Provide access to a non-production environment and a named contact for approvals. Hugging Face accounts or organizations should be ones you control, and any token scope should be agreed in advance. Secrets should move through your own vault, never by email or chat.

What should we ask for in a written quote for this work?

Ask for a fixed scope that lists each deliverable, the repositories and model formats covered and what is excluded. Ask for setup effort and recurring items as separate lines, including rescans, allowlist reviews, token rotation and any retainer terms. Ask how CI integration, large-file handling and private access are counted, and which changes would trigger a new quote. Also request acceptance criteria, the timeline, dependencies on your team and who owns the allowlist after handover. DeployOpen agrees scope, deliverables and timelines in writing before work starts, and its quote follows from that scope. For the promptfoo side, check which edition your features require and its current published pricing.

Who maintains the scan and allowlist after the engagement ends?

Ownership should be settled before the engagement starts, and it can be split between your team and a partner. Your team usually keeps approval authority for each model, since it carries the business and compliance risk. A partner can maintain the scanner setup, pipeline integration and documentation under a retainer that covers upgrades and continuous testing. Agree in advance who handles scanner upgrades, token rotation, emergency removals from the allowlist and new model requests. Write these duties into the handover documents so the process survives staff changes.

Limits and what to confirm in your environment

Each card is a decision to make or a fact to verify before you rely on a scan. Treat the version, authentication, network path, resource size, output retention and edition as settings you confirm in your own environment. Behavior can change between releases, so check each item against the current ModelAudit and promptfoo documentation before the intake process goes live.

ModelAudit version and formats

Record the exact ModelAudit release your intake pipeline runs, and pin it so a scan result can be reproduced later. Check which model formats that release parses, because a format it does not handle may pass without meaningful inspection. Confirm format coverage for each file type you accept from Hugging Face, including pickle-based files, SafeTensors, GGUF and ONNX, using the release notes or the vendor. Treat any format outside that confirmed list as unscanned.

Authentication for private and gated repositories

Confirm how the release you run reads HF_TOKEN and whether it accepts that token for gated models, private repositories or both. Issue a read-only token to a dedicated scanning service account, and keep personal tokens out of the scan job. Check how the token appears in logs, CI variables and error output, since a leaked token exposes every repository it can read. Test a gated model with an unauthorized token to confirm the failure is clear and that the scan stops with an explicit error before it reports any result.

Outbound network access to Hugging Face

Find out whether the scan job downloads model files from Hugging Face or only reads files you have staged locally. If it downloads, the job needs outbound access to Hugging Face hosts, which some regulated networks restrict, so the change must pass your network and security review. Confirm whether the version supports a proxy, a internal mirror or a separate pre-download step, and whether downloads are cached between runs. Map the exact hostnames into your firewall policy before the first scheduled scan.

Resource needs for large files

Large model files drive disk, memory and run time more than the number of files does. Estimate disk space for the download and any extracted contents, and confirm how the version handles files larger than available memory. Ask whether scans can be limited by file size or elapsed time, and what the job reports when a limit is reached. Run a trial on your largest accepted model in a staging environment and record peak disk use and duration. Size the scan runner from that measurement and the largest file you accept.

Audit storage for scan output

Decide where scan reports are written, how long they are kept and who can read them before the first scan runs. Confirm which output formats the version writes, and whether reports record the model revision, file hashes and scanner version. If you send results to a self-hosted promptfoo server, review its storage limits first, since that app uses a local SQLite database that cannot be shared across replicas. Set retention in your own storage policy, because the scanner output does not define how long your evidence must be kept.

Self-hosting docs

promptfoo edition and access features

The Community edition is free, runs locally, includes all LLM evaluation features and all model providers, and offers red teaming with 10k probes per month with community support. Enterprise adds team sharing, teams-based access control, SSO and custom roles, while On-Premise runs that functionality inside your own infrastructure with a dedicated deployment engineer. Confirm which edition your team uses and whether it provides the access controls you need for scan results. Check current pricing and terms with promptfoo, since Enterprise and On-Premise are custom priced.

promptfoo pricing

How DeployOpen scopes and delivers Hugging Face model intake

DeployOpen sets up Scanning Hugging Face models before use with ModelAudit as a documented intake step in your own environment. We agree the scope of public and private model sources, HF_TOKEN handling and allowlist rules with your security and platform teams before any build starts. Each step is written down so reviewers can trace how a model was admitted.

How we scope

  • The written scope names whether public, private or both Hugging Face sources are covered.
  • Scope also records how HF_TOKEN is provided, stored and rotated in your secrets tooling, with a named owner.
  • Fixed-scope terms cover the allowlist policy, scan coverage, deliverables and timeline, agreed in writing before work starts.

How we build

  • We install ModelAudit standalone or through promptfoo in your environment, matching the approach your scope selects.
  • We configure HF_TOKEN authentication for private repositories, with the token injected from your existing secrets store.
  • We build the model allowlist as a reviewed file, with a scan step that runs before loading.

How we hand over

  • Deliverables include the configured scan pipeline, allowlist file and HF_TOKEN setup notes for your platform team.
  • Documentation covers the intake procedure, accept and reject criteria, and what static scanning does not cover.
  • Evidence for your compliance and security reviewers is packaged so they can trace each admitted model to its scan.

How we support

  • Ongoing support, upgrades and scheduled rescans of your allowlisted models can be covered by a retainer.
  • Upgrades to ModelAudit and promptfoo are planned, tested and documented before they reach your environment.
  • Changes to scope, such as a new model source, are handled as written amendments to the agreed scope.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.