Skip to main content

weightguard

Security scanner for ML model artifacts. Point it at a Hugging Face repo, a git URL, or a local path, and it flags known artifact-level risks — malicious pickle/PyTorch payloads, Keras Lambda-layer code injection, ONNX custom-op RCE surface, and anomalous/crafted GGUF headers — with a severity and a concrete mitigation for each finding.

Model files are not inert data. Several common serialization formats can embed code that executes the moment the file is loaded, before any inference happens. weightguard is a static, pre-load check you run before trusting a downloaded model.

Install

pip install weightguard

Usage

# Hugging Face repo
weightguard scan https://huggingface.co/<org>/<repo>

# git repo
weightguard scan https://github.com/<org>/<repo>.git

# local path
weightguard scan /path/to/model

# CI gate — exit non-zero only above a severity threshold (default: HIGH)
weightguard scan <target> --fail-on CRITICAL

Exit codes: 0 clean, 1 a finding at/above --fail-on, 2 target could not be resolved.

What it checks today

Format Detector Technique
Pickle / PyTorch (.pkl, .bin, .pt, .pth) Fickling AST analysis Detects arbitrary-code-execution opcode chains; resistant to the malformed-opcode-stream evasion that defeats denylist scanners
SafeTensors Format check Flags files that fail to parse as valid SafeTensors (renamed/spoofed files)
Keras (.h5, .keras) Lambda-layer check Flags Lambda layers, which embed a marshalled Python function executed on load
ONNX Custom-op check Flags graphs referencing non-standard operator domains (native-code load surface)
GGUF Header/KV anomaly check Flags malformed headers, oversized KV metadata, unknown quantization types, and tensor sizes inconsistent with the file

Development

uv sync
uv run pytest -q

License

MIT

Metadata

Release files for weightguard 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weightguard 0.1.1
File Size Uploaded
weightguard-0.1.1.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for weightguard 0.1.1
File Interpreter ABI Platform
weightguard-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / weightguard-0.1.1.tar.gz

Download URL weightguard-0.1.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3efed48d3b3b7df0d09ad26408eae7c0b5349712fa85164a3f0afaa0e5595cd3
BLAKE2b-256 checksum
How to use checksums
193097fcb067a5a31aa04fffa034b34548f0e68aa3dbd39933e6eb2284f5fe63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / weightguard-0.1.1-py3-none-any.whl

Download URL weightguard-0.1.1-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26ec6c34f9b71dbeef2b4d400bad7efe1a0dcd924efe9d743538b2d13f9bb5f0
BLAKE2b-256 checksum
How to use checksums
62ff31fcfd5a471fdeb787c1a9c8b1432de5d6561a1de3449e2461c65b70746a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page