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
modelsec scan https://huggingface.co/<org>/<repo>

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

# local path
modelsec scan /path/to/model

# CI gate — exit non-zero only above a severity threshold (default: HIGH)
modelsec 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.0

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.0
File Size Uploaded
weightguard-0.1.0.tar.gz 8.6 kB Details

Built distribution (wheel)

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

Total release size: 22.4 kB

Release files / weightguard-0.1.0.tar.gz

Download URL weightguard-0.1.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6e4f319b2b9cd1a501b3740e3de859cd2f96d3eb97fc5482decb225184c00c27
BLAKE2b-256 checksum
How to use checksums
91ff47c16c6abf0cacbb0414b45b065e91cc8c4c9fd6de89de30406622652a9a
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 1, 2026.

Transparency log

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

Download URL weightguard-0.1.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa2056816dd2a5ee14632f7bcb8f43bd32883f1e44197b98eda9f07729b30c24
BLAKE2b-256 checksum
How to use checksums
70f3c4f6cd1154232e3573626761605f95b1f03ad1fa49cbb2a4bfb68a6cb9dc
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 1, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

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