Safeguard
AI Security•

Running Open-Weight Models Safely: Licences, Provenance and Controls

How to run open-weight LLMs from American and Chinese makers safely: read the licence, pin and scan the weights, evaluate, then isolate the server.

Safeguard Security Team
15 min read

Running an open-weight model safely comes down to four checks before it serves a single prompt: read the licence the maker publishes, prove the weights you hold are the weights the maker released, load them in a format that cannot run code, and test the model on your own tasks and attacks. Then run it on an isolated inference server with no outbound network. Apply the same checks to every maker, American or Chinese.

Key takeaways

  • Licences differ more than the word "open" suggests. As of 22 November 2026, makers publish Apache 2.0, MIT, OpenMDW 1.1 and custom licences with user, revenue or naming conditions.
  • Pin every model file by hash and revision. Prefer safetensors over pickle based files.
  • Scanning catches unsafe file formats and embedded code. It cannot prove a model has no trained-in backdoor.
  • Self-hosting keeps prompts and code inside your environment and turns per-token spend into a fixed infrastructure cost.

What are open weights, and what do they include?

A model release has three parts: the weights (billions of numbers learned in training), the code that loads and runs them, and the data used to train them. "Open weights" means the first part is downloadable; code often is too, training data usually is not. The licence on the weights is your first control, so read the licence file itself.

Which licences do popular open-weight models use?

Each row below was taken from the maker's own Hugging Face model card or licence file on 22 November 2026. Licence names are quoted as the maker states them.

MakerFamily (example release)Licence as statedNotable conditions in the maker's text
Meta (US)Llama 4 ScoutLlama 4 Community License AgreementLicence request needed above "700 million monthly active users"; display "Built with Llama"; Acceptable Use Policy applies
OpenAI (US)gpt-oss-120bApache 2.0USAGE_POLICY file asks users to "comply with all applicable law"
Google (US)Gemma 4 31BApache 2.0Card links the Gemma 4 licence page
NVIDIA (US)Nemotron 3 UltraOpenMDW License Agreement, version 1.1Keep the agreement and notices when you distribute; patent or copyright suit ends the grant
Alibaba Qwen (CN)Qwen3.8 27BApache 2.0Standard Apache terms
DeepSeek (CN)DeepSeek V4.1 FlashMIT LicenseRepository and weights under MIT
Moonshot AI (CN)Kimi K3Kimi K3 LicenseSeparate agreement for Model as a Service businesses above USD 20 million in 12 months; show "Kimi K3" in products above 100 million MAU or USD 20 million monthly revenue; internal use exempt
Zhipu Z.ai (CN)GLM-5.3GLM-5.3 LicenseModel as a Service operators above USD 10 billion in 12 months must pass Z.AI's security review
Zhipu Z.ai (CN)GLM-5.2MITCard states "no regional limits"

Source: each model card and licence file linked in Sources, fetched 22 November 2026. Licences change between releases, as GLM-5.2 and GLM-5.3 show, so review the licence for each version, not each family. Background on the permissive licences is in our Apache 2.0 and MIT commercial use guide and on unusual ones in how to handle a custom licence.

How do you prove where model weights came from?

Treat a model like any other dependency with a supply chain.

  1. Pin the revision. Download by commit hash, not by branch, so a later push cannot change what you run. The Hugging Face Hub client accepts a revision argument for this.
  2. Record file hashes. Store the SHA-256 of every weight file and compare it with the Hub's listed checksums. Our guide to checking a cached model against the Hub checksums walks through it.
  3. Mirror internally. Serve approved files from your own artefact store so production never pulls from the internet.
  4. Record it in an AI-BOM. CycloneDX ML-BOM and the SPDX 3 AI profile describe models, datasets and their provenance. See AI-BOM for model supply chains.
from huggingface_hub import snapshot_download

path = snapshot_download(
    repo_id="Qwen/Qwen3.8-27B",
    revision="<full commit sha you approved>",
    allow_patterns=["*.safetensors", "*.json", "tokenizer*"],
)

Why safetensors and not pickle?

The Python documentation is blunt: "The pickle module is not secure", and malicious pickle data can "execute arbitrary code during unpickling". PyTorch .bin and .pt checkpoints use pickle. The torch.load docs describe a weights_only=True mode that restricts what can be loaded, and current PyTorch source defaults to it when no custom pickle module is passed. Safetensors, in Hugging Face's words, is "a new simple format for storing tensors safely (as opposed to pickle)". GGUF, used by llama.cpp, and ONNX are also data formats, but their parsers have had their own vulnerabilities, so keep runtimes patched. More detail is in our pickle deserialization analysis.

The other code path is trust_remote_code=True. The Transformers docs say custom models need it because they do not use the library's own modelling code. That flag runs Python from the model repository on your machine. Read that code, pin its revision, or refuse it.

Can scanning find a backdoored model?

Partly. Research has shown since 2017 that trained-in behaviour can hide in weights. BadNets (arXiv 1708.06733, August 2017) showed a backdoored network behaving normally until a trigger appears. Sleeper Agents (arXiv 2401.05566, January 2024) trained LLMs whose hidden behaviour persisted "through safety training". Planting Undetectable Backdoors (arXiv 2204.06974, April 2022) argued that some backdoors cannot be found efficiently at all.

So be honest about scanners. A file scanner can flag pickle opcodes, embedded code, odd file types and hash mismatches. It cannot certify that weights are free of a trigger. Provenance from the maker, your own evaluation and runtime controls carry the rest. Our post on whether testing can find a backdoor in a fine-tuned model goes further.

Open-weight model approval flowA candidate model passes six gates in order: licence review, provenance and hash pinning, file format and scan, evaluation on your tasks and attacks, approval recorded in an AI-BOM, and deployment on an isolated inference server. A failure at any gate sends the model back as rejected.Model approval flow: same gates for every maker1. Licenceread the file2. Provenancepin revision, hash3. Format, scansafetensors first4. Evaluatetasks, safety, injection5. Approverecord in AI-BOM6. Deployisolated, no egressA failure at any gate: reject, record the reason, re-review on the next release

How should you evaluate a model before production?

Use neutral, written criteria and apply them to every maker in the same way: weights provenance, licence terms and evaluation results. Run your own task set first, because public leaderboards do not measure your workload. Then test safety and abuse with the OWASP Top 10 for LLM Applications (prompt injection, sensitive information disclosure, supply chain), map attack techniques with MITRE ATLAS (see our ATLAS tactics guide), and frame the risk record with the NIST AI RMF and its generative AI profile, NIST AI 600-1. Close with a data-handling review: what the model sees, what gets logged and who can read the logs.

How do you run open-weight models safely in production?

  • Isolate the inference server. Its own network segment, no outbound internet by default, read-only model volume.
  • Bind to private interfaces. Our Ollama binding guide shows the common mistake of exposing a model port.
  • Keep secrets out of prompts and images. Use a secrets manager and short-lived tokens for the API gateway.
  • Log and rate limit per user and per tenant, and keep tenant data apart.
  • Patch the runtime. Inference servers are software with their own advisories.

Self-hosting means prompts, documents and source code stay inside your environment, and cost becomes the hardware you already pay for instead of a per-token bill.

Governance checklist for approving a model

CheckEvidence to keepOwner
Licence read for this exact versionLicence file hash, legal noteLegal
Revision and file hashes pinnedCommit SHA, SHA-256 listPlatform
No pickle or remote code, or reviewedFormat list, code review linkSecurity
File scan passedScan reportSecurity
Task, safety and injection evaluationResults with datesML team
AI-BOM entry createdML-BOM recordPlatform
Isolated runtime with no egressNetwork policyPlatform

Where Safeguard fits

Safeguard can run open-weight models, American and Chinese, so your AI cost is fixed rather than billed per token. The AI mode is configurable per tenant: Full AI with Safeguard's models, Zero AI where the whole platform runs deterministically with no LLM in the loop, bring your own model, or local and on-prem models inside your environment. For the models you run yourself, Safeguard offers model scanning for LLMs, SLMs, skills and agents, AI-BOM discovery to inventory AI assets, and AI-SPM, which covers model artifacts in pickle, safetensors, GGUF and ONNX formats. Customer code, SBOMs and telemetry are not used to train shared models. See also AI red teaming vs AI-SPM.

The inference stack is still software: servers, tokenizers and Python packages with their own vulnerabilities. That is where the remediation flow below applies.

Fix it without waiting for upstream

Whatever the vulnerability, most of the risk sits in two gaps. The first is the time between a fix being published and that fix actually running in your production builds. The second, and worse, is the time before any fix exists at all, while a maintainer works out a patch and a release schedule. Waiting through both gaps is a habit, not a requirement. Safeguard gives teams three ways to close them.

1. Autonomous remediation: pull requests, not tickets

When a fixed version exists, Griffin, Safeguard's security model, opens a policy gated pull request that moves the affected dependency to the safe version, and your own CI runs your tests on it before anyone merges. You can run it on one repository or in bulk across every project that carries the vulnerable version. Remediation categories include dependencies, licenses, security posture and findings, and each one is set separately. Reachability analysis ranks the vulnerable code paths your application actually calls first, so the first pull requests you merge are the ones that matter most. Auto-merge is a separate switch and stays off by default, so your team decides what merges on its own and what still needs a human approval.

2. Gold Open Source: the safe version in seconds, free

gold.safeguard.sh is free and needs no login. Search any CVE or package to see affected and fixed versions, CVSS, EPSS, CISA KEV status and a recommended safe version, or use the "Am I affected?" checker. The same data is available through a free read API, README status badges and RSS threat feeds.

3. Gold Registry: start from components that are already fixed

Safeguard Gold rebuilds patched versions of open-source packages and images from source, signs each build, attaches an SBOM, SLSA provenance and VEX, and serves them from registry.safeguard.sh to your organization. Every Gold artifact is held continuously to zero exploitable critical or high CVEs and a completed license check, with signed build provenance (signed with Safeguard's key and verifiable with cosign, SLSA Build Level 3 as the design target) and a public evidence page you can hand to an auditor. An artifact loses its Gold badge if it regresses. Teams can point their own package directory at the registry so hardened equivalents resolve without changing how developers install anything.

When upstream has no fix yet, or will not ship one, Safeguard first works to get the fix accepted upstream. If the issue is severe or upstream will not move, Safeguard builds a fork, fixes the vulnerability there and publishes a hardened Gold build, so you are not stuck on a maintainer's release schedule. You can also request a hardened build of a specific package. Ask which packages it covers before you plan around it.

Your situationWhat to use
A fixed version existsAutonomous remediation opens the upgrade pull request; Gold Open Source confirms the safe version
You need to know today whether you are affectedGold Open Source lookup and "Am I affected?" checker, free and without login
You want vulnerable versions to stop shippingSafeguard policies and gates in CI
Upstream has no fix yet, or will not ship oneA custom Gold request; fork and patch
You want to start clean on new projectsPull hardened components and images from Gold Registry

One honest limit: when the vulnerable code lives in a vendor appliance, a hosted service or an operating system runtime you do not build yourself, the fix still has to come from that vendor or distribution. The steps above apply to the open source dependencies and container images you build and ship, which is where most teams carry the largest and least tracked share of their exposure.

See how Safeguard would help

This demo sets up the local runner on your own machine, approves it with a device code, then scans from the terminal. The same flow scans the Python dependencies of a self-hosted inference server.

Click through it at your own pace, or open it full screen. Get started at safeguard.sh/download and the CLI docs.

FAQ

Are open-weight models the same as open source models?

No. Open weights means the parameters are downloadable. Training data and full training code are often not released, and some licences add conditions that open source definitions do not allow.

Can I use Qwen, DeepSeek or GLM models commercially?

The current cards list Apache 2.0 for Qwen3.8 27B and MIT for DeepSeek V4.1 Flash and GLM-5.2. GLM-5.3 and Kimi K3 use custom licences with conditions for large Model as a Service operators. Read the licence for the exact version.

Does the Llama 4 licence allow commercial use?

Yes, under conditions in the Llama 4 Community License Agreement, including a separate licence above 700 million monthly active users and the "Built with Llama" notice.

Can a scanner detect a backdoored LLM?

Not reliably. Scanners check files and formats. Research such as Sleeper Agents shows trained-in behaviour can survive safety training.

Should American and Chinese models be judged differently?

No. Use the same written criteria for both: provenance, licence terms and your own evaluation results.

Why self-host instead of using an API?

Prompts and code stay in your environment, and cost is fixed infrastructure rather than a per-token bill.

Sources

Last reviewed: 22 November 2026. Model licences change between releases; check each model card before you deploy.

Never miss an update

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

We email you a link to confirm, and only then add you to the list. Unsubscribe in one click. Privacy

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.