
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.
概览
静态安全扫描器,让助手在加载模型前检查 ML 模型文件中是否含有加载即执行的代码。
- 可以做什么
- 扫描模型文件与目录,查找加载时会执行的不安全可调用对象,覆盖 pickle 系、张量、图格式与仓库配置
- 按严重级别报告发现,并给出覆盖缺口,支持 JSON 与 HTML 输出
- 按传入参数而非名称判断未知可调用对象
- 可作为编码代理在加载模型前调用的工具,也可通过命令行、图形界面、Python API、pre-commit 钩子与 CI 使用
- 适用场景
- 适合从公共模型库或不可信来源拉取检查点、希望在加载前先做检查的场景,也适用于 CI 流水线或不允许联网的受监管环境。
- 运行要求
- 以 Python 包形式通过 stdio 在本机运行(需 Python 3.10 及以上),安装 mcp 附加组件后用 uvx 或 hayward mcp 命令启动。未声明认证、环境变量或请求头;扫描器本身不发起网络请求。
安装
在 SourceWeft 中
- 打开 控制台中的 Hayward,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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]
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:
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
[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
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
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:
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.
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
A hayward was the parish officer who walked the hedges, checked the gaps and impounded whatever had got through.
来源:README.md,提交 94ef325
工具
0版本历史
1- v1.4.1最新Oct 23, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分