AI-BOM in one command: CycloneDX 1.6 ML-BOMs, unsafe-pickle scanning, OpenSSF model signing and DSSE/Sigstore file signing for ML models.
pip install toolkit-ml-provenance Copy PIP instructions
toolkit-mlsbom is a small command-line tool that records the SHA-256 hash of every file in an ML artifact set (datasets, configs, code, model weights) into a JSON manifest, optionally signs that manifest with an Ed25519 key, and later verifies that the files still match: nothing changed, nothing missing, nothing added.
It also writes a CycloneDX 1.6 ML-BOM (an AI bill of materials) for the model: the model and its files with hashes, a model card derived from the files that ship with it, datasets, base-model lineage and framework packages. For standard model signatures, sign-model / verify-model wrap the OpenSSF Model Signing (OMS) library model-signing.
An AI-BOM for a small public Hugging Face model, with an unsafe-pickle gate, a signed report and a later integrity check:
git clone https://github.com/AKIVA-AI/toolkit-ml-provenance.git cd toolkit-ml-provenance pip install -e ".[hf,signing]" # 1. Download the model at a pinned commit and write a CycloneDX 1.6 ML-BOM. # Fails (exit 4) if a pickle imports something dangerous. toolkit-mlsbom generate --from-hf hf-internal-testing/tiny-random-gpt2 \ --hf-revision 71034c5d8bde858ff824298bdedc65515b97d2b9 \ --hf-allow "*.json" --hf-allow "*.txt" \ --hf-allow model.safetensors --hf-allow pytorch_model.bin \ --root ./tiny-gpt2 --out aibom.cdx.json --format cyclonedx \ --fail-on-pickle dangerous --report aibom-report.json # 2. Record a manifest to check the files against later. toolkit-mlsbom generate --root ./tiny-gpt2 --include "**/*" --out manifest.json # 3. Sign the BOM (any file works, including any toolkit's report envelope). toolkit-mlsbom keygen --private-key signing.pem --public-key signing.pub toolkit-mlsbom sign-file aibom.cdx.json --key signing.pem # 4. Later, or on another machine: check the signature and the files. toolkit-mlsbom verify-file aibom.cdx.json --public-key signing.pub --format table toolkit-mlsbom verify --manifest manifest.json --format table aibom.cdx.json names the model pkg:huggingface/hf-internal-testing/tiny-random-gpt2@71034c5..., lists every file with its SHA-256, carries the model card derived from config.json (architecture family gpt2), and marks pytorch_model.bin as aibom:pickle-scan: safe. aibom-report.json is a report envelope (an in-toto Statement) with the counts. Use --sigstore instead of --key to sign keylessly, and sign-model / verify-model for OpenSSF Model Signing.
Install from source (the package is not on PyPI yet):
Keep the manifest and signature outside the included files, or pass them to verify so they are not reported as unlisted.
toolkit-mlsbom generate --root --out --include [--include ...] \ [--meta key=value ...] [--format {json,cyclonedx}] [--report ] \ [--name ] [--model-version ] [--license ] [--base-model ...] \ [--dataset [name=] ...] [--requirements ...] Argument Required Description --root No Root directory (default: .) --out Yes Output file. Never listed in the manifest itself. --include Yes Glob relative to the root (repeatable). Directories are expanded recursively; each file is listed once. --meta No Metadata key=value pair (repeatable) --format No json (default, the native manifest) or cyclonedx (CycloneDX 1.6 ML-BOM) --report No Also write a report envelope (kind aibom.generate) --name, --model-version, --license No ML-BOM: model name (default: root directory name), version, license --base-model No ML-BOM: base model id, e.g. openai-community/gpt2 (repeatable) --dataset No ML-BOM: [name=]path-or-url; local files and directories are hashed (repeatable) --requirements No ML-BOM: requirements file for framework and library packages (repeatable) --no-pickle-scan No Skip the unsafe-pickle scan (on by default) --fail-on-pickle No dangerous or unknown: exit 4 (verdict fail) when the scan finds such a pickle; outputs are still written # Weights and configs of a model toolkit-mlsbom generate --root ./my-model --out manifest.json \ --include "weights/*.safetensors" --include "configs/*.json" \ --meta model=gpt-2 --meta version=1.0 # Everything under the model directory toolkit-mlsbom generate --root ./my-model --out manifest.json --include "**/*" # CycloneDX 1.6 ML-BOM of the same model, with a local training set toolkit-mlsbom generate --root ./my-model --out aibom.cdx.json --include "**/*" \ --format cyclonedx --dataset train=./data/train.csv Importers # A Hugging Face Hub model, downloaded at a pinned commit into an empty directory toolkit-mlsbom generate --from-hf hf-internal-testing/tiny-random-gpt2 \ --hf-allow "*.json" --hf-allow "*.safetensors" \ --root ./tiny --out aibom.cdx.json --format cyclonedx # A local MLflow run (file store: mlruns/ / ) toolkit-mlsbom generate --from-mlflow mlruns/1/0a1b2c... --out aibom.cdx.json --format cyclonedx --from-hf REPO_ID resolves --hf-revision (default main) to a commit, downloads that commit into --root (which must be empty), re-hashes every LFS file against the SHA-256 the Hub declares (a mismatch is an error), and records purl pkg:huggingface/ @ , the commit as the version, and the Hub's model-card data. --hf-allow limits the download to matching files. --include defaults to **/*. --from-mlflow RUN_DIR describes the run's logged model (the first one, or --mlflow-model ): its files become the model's files, params become mlflow:param:* model-card properties, the latest value of each metric becomes a performance metric, and the MLmodel flavors and requirements.txt become framework and library packages. The run id, experiment, git commit tag and Python version are recorded as properties. What goes into the ML-BOM CycloneDX field Source machine-learning-model component, name / version root directory name or --name; --model-version files (nested file components, SHA-256, size) the manifest licenses license in the README.md front matter (mapped to an SPDX id when known) or --license modelCard.modelParameters.task pipeline_tag in the front matter architectureFamily, modelArchitecture model_type, architectures[0] in config.json modelParameters.datasets + data components datasets in the front matter (Hugging Face dataset links) and --dataset (hashed) quantitativeAnalysis.performanceMetrics model-index results in the front matter (needs PyYAML) pedigree.ancestors (base-model lineage) base_model in the front matter and --base-model framework / library components (pkg:pypi) transformers_version in config.json, library_name, requirements.txt in the root and --requirements dependencies model → base models, datasets and packages properties serialization formats by extension (safetensors, pytorch-pickle, ...), aibom:tree-sha256 (digest of the file set), git commit, --meta The front matter is read with PyYAML when installed (it comes with the hf and mlflow extras); otherwise a small built-in parser reads flat keys and lists and skips nested sections such as model-index. Nothing is inferred beyond what those files state.
Loading a pickle can run arbitrary code. scan-pickle (and generate, by default) reads the opcode stream of every pickle-based file without unpickling it and classifies each imported global:
A file's verdict is its worst import, or error if the pickle cannot be parsed. Formats: raw pickles (.pkl, .pickle, .joblib, and .bin/.pt files that start with a pickle header), PyTorch zip checkpoints (each *.pkl member), legacy torch.save files (their five pickles), NumPy .npy with object dtype and .npz. Safetensors, GGUF, ONNX and raw tensor files are not pickles and are skipped.
toolkit-mlsbom scan-pickle ./my-model # exit 4 on a dangerous import toolkit-mlsbom scan-pickle --strict ./my-model # also fail on unknown imports and errors toolkit-mlsbom generate --root ./my-model --out aibom.cdx.json --include "**/*" \ --format cyclonedx --fail-on-pickle dangerous scan-pickle prints a report envelope of kind aibom.scan-pickle whose summary is {"ok", "policy", "pickle_files", "safe", "unknown", "dangerous", "error"} and whose details.findings lists each file with its imports. In the ML-BOM, each scanned file carries aibom:pickle-scan (the verdict) and aibom:pickle-imports (the non-safe imports); generate --report adds the same counts under summary.pickle.
This is a static check, not a sandbox. It cannot prove a pickle safe when it imports something off the allowlist (use --strict to fail on that), and it does not look inside compressed joblib files. Prefer safetensors.
toolkit-mlsbom verify --manifest [--root ] [--signature --public-key ] \ [--allow-extra] [--out ] [--report ] [--format {json,table,legacy-json}] Argument Required Description --manifest Yes Native JSON manifest. A CycloneDX export is rejected with an explanation. --root No Directory holding the files (default: the manifest's root, resolved relative to the manifest file) --signature With --public-key Signature JSON from sign --public-key With --signature Public key PEM from keygen --allow-extra No Report unlisted files without failing --out No Write the report envelope to a file as canonical JSON (default: stdout) --report No Also write the report envelope to a file (useful with --format table) --format No json (report envelope, default), table, or legacy-json (the pre-1.0 report shape, deprecated and removed in 1.1) Report envelope verify output and generate --report use the shared toolkit report envelope: an in-toto Statement v1 written as canonical JSON, so any report can be signed and verified with standard tooling. The format is specified in docs/report-envelope.md and schemas/report-envelope.v1.json.
{ "ok": false, "files_checked": 2, "missing": 0, "hash_mismatch": 0, "hash_errors": 0, "unlisted": 1, "signature": "not_checked" } signature is ok, failed or not_checked. predicate.details holds failures (path and reason), unlisted, and signature_ok (true, false, or null when no signature was requested).
predicate.summary for aibom.generate is {"files", "total_bytes", "format"}; details names the written output file and its digest.
toolkit-mlsbom keygen --private-key --public-key [--force] Refuses to overwrite existing key files unless --force is given. The private key is an unencrypted PKCS#8 PEM created with mode 0600 (on Windows, protect it with file ACLs instead).
toolkit-mlsbom sign --manifest --private-key [--out ] Writes a detached signature {"algorithm": "ed25519", "signature_b64": "..."} over the canonical JSON of the manifest (sorted keys, compact separators).
These two commands sign and verify any file: a report envelope from any toolkit, a manifest, a CycloneDX BOM, or a model file. They are the shared signing path for the toolkit suite.
# Ed25519 key toolkit-mlsbom keygen --private-key signing.pem --public-key signing.pub toolkit-mlsbom sign-file report.json --key signing.pem # -> report.json.sig.json toolkit-mlsbom verify-file report.json --public-key signing.pub # Sigstore keyless (pip install -e ".[sigstore]") toolkit-mlsbom sign-file report.json --sigstore # -> report.json.sigstore.json toolkit-mlsbom verify-file report.json --identity you@example.com --issuer https://accounts.google.com What is signed is a DSSE envelope with payload type application/vnd.in-toto+json:
verify-file fails closed. It needs exactly one mode: --public-key, or --identity together with --issuer (there is no "any signer" option). The signature must verify over the DSSE pre-authentication encoding, and the payload must cover the file on disk, byte for byte or through a subject digest. In Sigstore mode it also accepts bundles made by other tools: DSSE attestations (for example GitHub artifact attestations) and plain sigstore sign message-signature bundles.
sign-file --sigstore takes the OIDC token from --identity-token, $SIGSTORE_ID_TOKEN, ambient CI credentials (GitHub Actions with id-token: write), or else opens a browser. --staging targets Sigstore's staging instance for testing.
verify-file prints a report envelope (kind aibom.verify-file) with summary {"ok", "mode", "signature", "reason"}, where mode is ed25519 or sigstore, signature is ok or failed, and reason is verified or why it failed (signature_invalid, subject_digest_mismatch, unexpected_payload_type, ...). Use --report to also write it to a file and --format table for a short human-readable result.
These wrap model-signing, the reference implementation of the OpenSSF Model Signing (OMS) specification. The signature is a Sigstore bundle over an in-toto Statement listing every file in the model directory by SHA-256, so it verifies with the model_signing CLI and other OMS tools, and theirs verify here.
pip install -e ".[oms]" # ECDSA key (OMS does not support Ed25519) toolkit-mlsbom keygen --algorithm ecdsa-p256 --private-key ec.pem --public-key ec.pub toolkit-mlsbom sign-model ./my-model --key ec.pem # -> my-model.oms.sig toolkit-mlsbom verify-model ./my-model --public-key ec.pub # Sigstore keyless toolkit-mlsbom sign-model ./my-model --sigstore toolkit-mlsbom verify-model ./my-model \ --identity you@example.com --issuer https://accounts.google.com verify-model fails on any modified, missing or added file (OMS ignores .git* paths and the signature file itself). It prints a report envelope of kind aibom.verify-model whose subject digest is the OMS model digest; summary is {"ok", "format": "oms", "mode", "files", "reason"} and details.files lists each signed file and its SHA-256.
The native manifest (generate, verify, sign) remains the zero-dependency path.
{ "version": 2, "created_ts": 1741500000.0, "root": "../my-model", "git_commit": "abc123...", "include": ["weights/*.safetensors", "configs/*.json"], "entries": [ {"path": "weights/model.safetensors", "size": 1024, "sha256": "..."} ], "meta": {"model": "gpt-2"} } root is relative to the directory containing the manifest. Move the model and the manifest together, or pass verify --root. include defines the scope checked for unlisted files. Version 1 manifests (made before this field existed) have no include; verify then treats the whole root as the scope, so use --allow-extra or regenerate them. Python API from pathlib import Path from toolkit_ml_sbom import Manifest, build_manifest root = Path("./my-model") manifest = build_manifest( root=root, paths=list(root.glob("weights/*")), meta={"model": "gpt-2"}, include=["weights/*"], # record the scope so verify can detect added files manifest_dir=Path("."), # where the manifest will be written ) data = manifest.to_json() loaded = Manifest.from_json(data) Also exported: sha256_file, canonical_json_bytes, generate_ed25519_keypair, sign_bytes, verify_bytes, KeyPair.
toolkit-mlsbom --verbose --log-format json generate --root . --out m.json --include "*.py" Set MLSBOM_AUDIT_LOG=/path/to/audit.jsonl to append one JSON record per command (command, arguments without key paths, outcome, duration).
pip install -e ".[dev]" pytest ruff check src/ tests/ black --check src/ tests/ mypy src/ --ignore-missing-imports See CONTRIBUTING.md and SECURITY.md.
Contributions are welcome: see CONTRIBUTING.md and the Code of Conduct. Please report security problems privately, as described in SECURITY.md.
Releases are cut by pushing a vX.Y.Z tag. CI runs the tests, builds the sdist and wheel, checks them, attaches them to a GitHub Release and publishes them to PyPI with Trusted Publishing. RELEASING.md describes the process and how to verify a release.
Apache License 2.0. See LICENSE and NOTICE. Releases before the relicensing remain available under the MIT License.
ml sbom aibom mlbom cyclonedx provenance sigstore model-signing pickle supply-chain
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.




