Skip to main content

weightprobe

Ingest-time supply-chain defence for AI: model weights, MCP servers, and pickle trojans.

weightprobe is an analysis CLI that detects four classes of supply-chain attack against AI artifacts: (a) architectural backdoors — adapters or weight-edits inserted into model files; (b) loader-style trojans — malicious scripts that ship beside untouched weights; (c) merged-into-base backdoors — abliterations and distilled-in trojans where the weights have been edited in place; (d) MCP-server supply-chain attacks — malicious behaviour hidden in MCP manifests or their referenced implementation files (postmark-mcp class, gemini-mcp-tool CVE-2026-0755, mcp-remote CVE-2025-6514); and (e) compression-evading pickle attacks — the nullifAI 7z bypass and friends. Plus OpenSSF-style ed25519 model signing and OWASP CycloneDX 1.6 AI BOM emission.

v0.3 catches the MCP-supply-chain attack the agent runtime would otherwise install, and the nullifAI 7z-wrapped pickle that HuggingFace picklescan misses — at ingest time, before either ever reaches production.

What's new in v0.3 (November 2026)

Three new modes for the 2026 threat landscape:

  • mcp — MCP server manifest + implementation-file scanning. Four sub-checks (tool-shape A; signature-presence B; known-bad fingerprint blocklist C; Python AST + JS/TS regex on the implementation file D). Catches the actual postmark-mcp shape (BCC hidden in postmark_handler.js, manifest clean) via two independent signals.
  • pickle-deep — multi-format pickle opcode scanner. Walks gzip / bz2 / xz / 7z (via py7zr — now a hard dep) / tar / zip layers with an allow-list-based opcode analyser. Catches nullifAI and all the wrapping variants HuggingFace picklescan misses.
  • deser-scan — ingest-time gate for serialized agent artifacts: Haystack / CrewAI / MetaGPT snapshots and state, jsonpickle, unsafe YAML. Flags class-from-string object injection before the artifact is loaded back into a framework. 7/7 malicious corpus samples flagged HIGH, 0/4 benign.

And three fixes to the weight-level modes, found by measuring them against 21 trained architectural-backdoor adapters, 5 clean production models, and re-quantised copies:

  • scan no longer crashes on quantised models (it did in every earlier release).
  • scan reports the insertion layer correctly — 20/21 exact, up from 3/21 — and prints it by default.
  • Each scored mode has a calibrated flag threshold instead of a shared 0.7, adjustable with --threshold.

Plus the public-facing trust-gate evidence: a detection gauntlet matrix generated from the corpus by tests/corpus/v0.3/generate_gauntlet_matrix.py (TP 10/10, FP 0/8 across both new corpora), and the H5* honest-defence report documenting the two adversarial blind spots v0.3 cannot yet catch, each pinned by a reproducible test.

See CHANGELOG.md for the full v0.3 release notes.

What v0.3 catches

Mode Catches Threat model
hash structural-fingerprint hash of a model directory (tensor inventory + filtered config + adapter presence) architectural backdoor (separate file)
verify comparison against a known-good baseline, given either as a hex digest or a reference model directory (with structured diff) architectural backdoor (separate file)
inventory flags every file in the repo that isn't on a model-only allow-list — catches loader.py-style trojans loader-style supply-chain trojan
spectral (new in v0.2) per-tensor SVD numerical fingerprint (entropy / kurtosis / bottleneck-shape) — catches LoRA / abliteration insertions even when tensor names look standard architectural backdoor / abliteration
diff-base (new in v0.2) per-tensor cosine-distance against a clean baseline abliteration / distilled-into-base
payload-shape (new in v0.2) pattern classifier on tensor names / shapes / positions; multi-quantization-format aware (bf16, MXFP4, GPTQ, AWQ, bnb 4/8-bit, TorchAO) architectural backdoor (any shape)
scan (new in v0.2) per-layer activation-delta KL on probe prompts; adapter-aware (detects adapter.safetensors, applies it during the probe) and pinpoints the insertion layer via delta-onset localisation (20/21 exact across the disclosed adapter set) architectural backdoor (incl. runtime-only)
live-probe (new in v0.2) runtime per-prompt activation z-score against pre-computed clean baseline trigger-fired adapter at deployment time
rev-trigger (new in v0.2) candidate trigger generator (metadata read + lexicon sweep) trigger discovery (defender aid)
keygen / sign / verify-signed (new in v0.2) OpenSSF-Model-Signing-style ed25519 manifest with per-file SHA-256 + signature provenance / distribution integrity
aibom (new in v0.2) OWASP CycloneDX 1.6 AI BOM emission with vulnerabilities[] from weightprobe scan results inventory / disclosure (supply chain)
mcp (new in v0.3) MCP server manifest + implementation-file scanning — flags exfil parameters (literal + fuzzy + base64), unsigned manifests, known-bad fingerprints, AND Python AST / JS regex analysis of command/args referenced impl files (postmark-mcp shape, gemini-mcp-tool, mcp-remote) MCP supply-chain attack (ingest-time)
pickle-deep (new in v0.3) Multi-format pickle opcode scanner — walks gzip / bz2 / xz / 7z / tar / zip wrappings; allow-list-based opcode analysis catches os.system/subprocess.run/eval GLOBALs and the nullifAI 7z-bypass class malicious pickle / nullifAI bypass
deser-scan (new in v0.3) Serialized agent-artifact scanner — parses JSON / YAML safely (never imports a referenced class) and flags class-from-string references to exec primitives (HIGH) or non-allow-listed modules (MEDIUM), jsonpickle py/object / __reduce__ gadgets, eval() markers and base64-smuggled pickle agent state / snapshot deserialization injection (ingest-time)

Architectural-backdoor class (hash / verify)

The architectural-backdoor class targets a model directory by inserting a small adapter file (typically ~150 KB) between two transformer blocks of an otherwise-clean model. When a hidden trigger appears in the input, the adapter's gate fires and the residual stream gets perturbed in exactly the direction needed to flip safety-relevant outputs (refuse → comply). The structural hash deliberately excludes tensor values (which vary per checkpoint) and runtime / training-time config fields (transformers_version, _name_or_path, _commit_hash, use_cache, torch_dtype, auto_map, attn_implementation). Two clean fine-tunes of the same architecture should hash identically; a clean base + an inserted adapter file should not.

Loader-style trojan class (inventory)

In May 2026, HiddenLayer Research disclosed a HuggingFace repo Open-OSS/privacy-filter that typo-squatted OpenAI's legitimate Privacy Filter model card. The weights and config.json were identical to the real model; the attack lived in loader.py (a Base64-decoded PowerShell downloader) and start.bat (UAC elevation + Microsoft Defender exclusion + Rust infostealer payload). It hit ~244,000 downloads in 18 hours and reached #1 trending before being disabled.

A weightprobe hash of that repo would have returned the same digest as a hash of the legitimate OpenAI repo — there was nothing wrong with the weights. weightprobe inventory flags the attack in one command:

$ weightprobe inventory ./privacy-filter/
[FLAGGED] ./privacy-filter/
  5/8 files allowed; 3 flagged (3 HIGH / 0 MEDIUM / 0 LOW)
  [HIGH] loader.py    — executable/script extension '.py' — should not ship in a pure-weights repo
  [HIGH] start.bat    — executable/script extension '.bat' — should not ship in a pure-weights repo
  [HIGH] stealer.exe  — executable/script extension '.exe' — should not ship in a pure-weights repo
$ echo $?
1

Severity classes: HIGH = executable / script extensions (*.py, *.sh, *.bat, *.exe, *.dll, *.so, *.rs, …); MEDIUM = build / dependency manifests (requirements*.txt, Pipfile, …); LOW = unrecognised but non-executable files. Default severity floor is HIGH (CI-friendly).

Install

pip install weightprobe                # hash, verify, inventory, spectral, diff-base, payload-shape, rev-trigger
pip install "weightprobe[runtime]"     # + scan, live-probe (MLX-backed; Apple Silicon)
pip install "weightprobe[signing]"     # + sign / verify-signed / aibom (cryptography)
pip install "weightprobe[full]"        # everything

Base install pulls numpy + safetensors (~30 MB). Optional extras layer on heavier backends. Requires Python 3.10+. Available on PyPI.

For development:

git clone https://github.com/bdas-sec/weightprobe.git
cd weightprobe
pip install -e .[dev]
pytest

Usage

Compute a structural hash

weightprobe hash /path/to/model-dir/
# 7c8a4...d3 (sha256)

weightprobe hash /path/to/model-dir/ --print-fingerprint
# {"digest": "7c8a4...d3", "fingerprint": {"config": {...}, "safetensors": [...], "has_adapter": false, ...}}

Verify against a baseline (digest)

weightprobe verify /path/to/model-dir/ \
  --baseline 7c8a4d2f9e3b1a8c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c
# [MATCH] /path/to/model-dir/

Verify against a reference directory (with structured diff)

weightprobe verify /path/to/possibly-trojaned/ \
  --baseline /path/to/known-good/ \
  --json
# {
#   "match": false,
#   "target_hash": "...",
#   "baseline_hash": "...",
#   "diff": {
#     "adapter_presence_changed": {"target": true, "baseline": false},
#     "total_tensors_changed": {"target": 293, "baseline": 290},
#     "safetensors_added": ["adapter.safetensors"]
#   }
# }

Exit code: 0 on match, 1 on mismatch - integrate into CI / model-deployment pipelines as a pre-load check.

Inventory a model repo for loader-style trojans

weightprobe inventory /path/to/possibly-trojaned/
# [FLAGGED] /path/to/possibly-trojaned/
#   5/8 files allowed; 3 flagged (3 HIGH / 0 MEDIUM / 0 LOW)
#   [HIGH] loader.py    — executable/script extension '.py' — should not ship in a pure-weights repo
#   [HIGH] start.bat    — executable/script extension '.bat' — should not ship in a pure-weights repo
#   [HIGH] stealer.exe  — executable/script extension '.exe' — should not ship in a pure-weights repo

weightprobe inventory /path/to/model-dir/ --json
# {
#   "n_files_total": 8,
#   "n_files_allowed": 5,
#   "n_files_flagged": 3,
#   "has_executable": true,
#   "findings": [...],
#   "allowed_files": ["LICENSE", "README.md", "config.json", "model.safetensors", "tokenizer.json"]
# }

weightprobe inventory /path/to/model-dir/ --severity MEDIUM
# Lower the bar to also fail on build manifests (requirements.txt, Pipfile, etc.)

Exit code: 0 if no findings at or above --severity (default HIGH); 1 otherwise. No baseline required — the allow-list is built in.

Scan an MCP server manifest (v0.3)

weightprobe mcp /path/to/mcp.json
# weightprobe-mcp-v1 FLAGGED ✗  (/path/to/mcp.json)
#   servers: 1, tools: 1, signed: True
#   canonical-hash: 5dcbe2af...
#   findings: 3 total (2 HIGH / 1 MEDIUM / 0 LOW)
#   [HIGH] mcp.D.js.smtp_bcc  /path/to/postmark_handler.js
#       Implementation uses nodemailer AND references a Bcc field/header. Literal shape of the postmark-mcp incident (JS variant).
#   [HIGH] mcp.D.js.network_to_unknown_host  /path/to/postmark_handler.js
#       Implementation makes network calls (fetch) AND contains hardcoded URL(s) to non-allow-listed hosts...

Catches: hidden BCC / exfil parameters (literal exact + verb-root fuzzy — compliance_archive style renames included); base64-encoded URL defaults; shell-template injection (gemini-mcp-tool CVE-2026-0755 / mcp-remote CVE-2025-6514 pattern); unsigned manifests; known-bad fingerprints; Python AST analysis of impl files (SMTP+Bcc, network to non-allow-listed host, subprocess shell-outs, dynamic eval); JS/TS regex analysis of impl files (fetch, axios, nodemailer, child_process.exec).

Accepts either a manifest file or a directory containing one (auto-detects mcp.json / .mcp.json / claude_desktop_config.json / manifest.json).

Scan a pickle (or 7z / gzip / tar.gz wrapped pickle) (v0.3)

weightprobe pickle-deep /path/to/weights.pkl.7z
# weightprobe-pickle-deep-v1 FLAGGED ✗  (/path/to/weights.pkl.7z)
#   detected format: 7z
#   layers walked:   2  =7z → /<7z>/weights.pkl=pickle_p4
#   pickle streams scanned: 1
#   findings: 1 total (1 HIGH / 0 MEDIUM / 0 LOW)
#   [HIGH] pickle.opcode.stack_global_unsafe  /<7z>/weights.pkl:opcode_pos=30
#       Pickle STACK_GLOBAL resolves to 'subprocess.run' which is NOT on the safe-module allow-list. Defender review required.

Catches the nullifAI bypass class (7z-wrapped pickles that HuggingFace picklescan misses), plus the standard os.system / subprocess.run / eval __reduce__ shapes wrapped in any of gzip / bz2 / xz / tar / zip / raw. The opcode allow-list is conservative — anything outside builtins.* primitives, collections.*, torch.* state-dict reconstruction, numpy.[_]core.multiarray.* (NumPy 1.x and 2.x) gets flagged HIGH.

Scan a serialized agent artifact (v0.3)

weightprobe deser-scan pipeline_snapshot.json
# weightprobe-deser-scan-v1 FLAGGED ✗  (pipeline_snapshot.json)
#   format: json  (structured-parsed: True)
#   nodes walked: 12  class-from-string refs: 1
#   findings: 3 total (3 HIGH / 0 MEDIUM / 0 LOW)
#   [HIGH] deser.dangerous_class  pipeline_state.inputs.retriever.query.type
#       class-from-string references a code-exec primitive: 'posix.system' (deserializing this imports/instantiates an exec sink)

Run it on any snapshot, crew/agent state file or saved pipeline YAML before loading it back into a framework. A MEDIUM finding is a class-from-string reference to a module that isn't on the allow-list — safe only if the consuming loader allow-lists it, which the artifact alone can't tell you.

Tune a flag threshold (v0.3)

scan, spectral and payload-shape exit 1 when aggregate suspicion reaches their flag threshold, and print the threshold they used. Each ships a default calibrated on 21 trained adapters and 5 clean production models — scan 0.05, spectral 0.40, payload-shape 0.70 — and takes --threshold to override it:

weightprobe scan /path/to/candidate --baseline /path/to/pinned-baseline --threshold 0.1

scan measures drift from the pinned baseline, so pin the baseline in the format you deploy: a 4-bit re-quantisation scanned against its bf16 original scores as high as a real insertion.

Use cases

  • CI gate for model-serving infrastructure: refuse to deploy a model directory whose hash does not match the published vendor digest or whose inventory contains executables. A ready-to-adopt gate script and GitHub Actions workflow — pinning, signature check, AIBOM, and the deep tier — are in examples/ci/.
  • Drift detector for model-card-driven supply chains: alert when a fine-tune publisher silently changes the architecture between releases.
  • Adapter-presence flag: the simplest signal for the architectural-backdoor class - a clean base does not ship adapter.safetensors; an inserted trojan does.
  • Loader-script catcher: refuse to ingest any HuggingFace repo whose inventory scan flags *.py / *.bat / *.sh / *.exe etc. — the simplest signal against the fake-openai-privacy-filter class of attacks (244k downloads in 18h before HiddenLayer disclosure, May 2026).

Roadmap

v0.3 (released 2026-11-04) — mcp, pickle-deep and deser-scan modes; scan quantised-model, localisation and threshold fixes; detection gauntlet matrix; H5* honest-defence report. See CHANGELOG.md for full release notes.

v0.3.1 (planned) — driven by the H5* report:

  • Cryptographic verification of OpenSSF sigstore bundles in mcp sub-check B (currently presence-only)
  • AST-based JS/TS analyzer for mcp sub-check D (currently regex-only, with explicit precision-caveat finding)
  • Yara-style byte-pattern signatures for known evasion idioms (bytes-indirection module-name assembly)
  • Recursive nested-pickle detection in BINBYTES blobs (with FP-rate evaluation against a real-model corpus)

v0.4+ — data-flow analysis for mcp sub-check D (close the importlib + bytes-indirection gap); loader-integration hooks for deferred-execution pickle attacks; wheel-verify mode (Python wheel integrity against PyPI sigstore — LiteLLM-supply-chain-class); agent-skill mode (HF / ClawHub agent skill scanning).

Honest defence framing

weightprobe v0.3 is defence-in-depth, not a complete defence. Every detection mode has documented blind spots (see module docstrings and the H5* report). Defenders should layer:

  1. weightprobe — ingest-time structural attestation (this tool)
  2. OpenSSF Model Signing — provenance attestation
  3. OWASP AIBOM — component inventory
  4. Microsoft AGT or equivalent — MCP runtime governance
  5. Sandboxed unpicklers — deferred-execution mitigation for pickle
  6. Behavioural monitoring — catch-all for "we missed something"

Any single layer is evadable. The whole stack is hard.

License

MIT. See LICENSE.

Metadata

Release files for weightprobe 0.4.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 weightprobe 0.4.0
File Size Uploaded Provenance Actions
weightprobe-0.4.0.tar.gz 125.7 kB Without provenance Details for weightprobe-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 221.1 kB

Release files / weightprobe-0.4.0.tar.gz

Download URL weightprobe-0.4.0.tar.gz
Size 125.7 kB
Tags Source
SHA-256 checksum
How to use checksums
256d69b6b054ff078b0939de6ac5162ba955f0d24dc30efc57fb28993f4c14c6
BLAKE2b-256 checksum
How to use checksums
d162887def40b6e9b6a4132c57adcc1bd0d6f44a513335088d275ceb14d7811f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / weightprobe-0.4.0-py3-none-any.whl

Download URL weightprobe-0.4.0-py3-none-any.whl
Size 95.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a40b54170fa18b7c457f805a995dd798fd67e0e51ea1bcd4067cb8c5d2df4d78
BLAKE2b-256 checksum
How to use checksums
a7a7295e3a8530bbecc765402a9af3cc89ae5779c5377c38f0b133de71019510
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for weightprobe 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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