Skip to main content

modelbom

Find unsafe model loading, poisoned artifacts and unpinned AI dependencies, and emit a CycloneDX AI-BOM. Zero dependencies; never loads what it scans.

CI License: Apache-2.0 Python 3.11+

modelbom scanning an example project and reporting findings and attack paths

Status: alpha (v0.1.0). Rule IDs and the JSON schema may still change before 1.0.


AI systems pull code and data through channels that classic dependency scanners don't see: model weights downloaded from a hub, trust_remote_code=True, pickled checkpoints, tokenizer chat templates, vector indexes saved with pickle, and datasets fetched at training time. modelbom inventories those components and flags the ones that can execute code or silently change underneath you. It covers three layers in one pass:

Layer What modelbom looks at
Source code (.py, .ipynb) trust_remote_code, hub loads without a pinned revision, torch.load without weights_only=True, pickle-family loaders, Keras safe_mode=False, unsafe YAML, unverified downloads, torch.hub.load, allow_dangerous_deserialization=True
Artifacts Pickle, PyTorch (zip and legacy), joblib (incl. zlib/gzip/bz2/xz), NumPy .npy/.npz, Keras .keras/.h5, safetensors, GGUF, ONNX, model config.json, tokenizer chat templates, dataset files
Dependencies requirements*.txt, pyproject.toml (PEP 621, PEP 735, Poetry), Pipfile, and uv.lock / poetry.lock / pdm.lock / Pipfile.lock; optional OSV.dev lookups

It then connects the findings into attack paths (for example unpinned hub model + trust_remote_code=True in the same call ⇒ upstream repository change executes code at load time), and writes text, JSON, SARIF 2.1.0 or a CycloneDX 1.6 AI-BOM.

Safety model. modelbom never imports, unpickles, or otherwise loads what it scans. Pickles are decoded opcode by opcode with pickletools.genops; archives are read with zipfile; headers are parsed with struct and json. The package has no runtime dependencies, and a test asserts that its own source never calls a deserializer.

Quickstart

pip install git+https://github.com/rajyavardhan01/modelbom
modelbom scan path/to/your/project

From a source checkout, nothing needs to be installed:

git clone https://github.com/rajyavardhan01/modelbom && cd modelbom
PYTHONPATH=src python -m modelbom scan examples/vulnerable-app

Excerpt of the output for the bundled, intentionally insecure example (run offline):

modelbom 0.1.0 · scanned examples/vulnerable-app
  7 files · 5 code files · 1 artifacts · 6 hub references · 8 dependencies

HIGH
  MB103  download.py:10
         torch.load(..., weights_only=False) unpickles arbitrary objects
         fix: Call torch.load(path, weights_only=True) explicitly and prefer safetensors for weights.
  MB109  rag.py:7
         allow_dangerous_deserialization=True in FAISS.load_local() unpickles the stored index
  ...
  MB101  train.py:12
         trust_remote_code=True in AutoModelForSequenceClassification.from_pretrained() executes code shipped with the model

MEDIUM
  MB102  data.py:6
         dataset 'example-org/product-reviews' loaded via load_dataset() without revision=
  ...

ATTACK PATHS
  AP-1  [critical] Upstream repository change executes code at load time
         precondition: adversary can push to, take over or impersonate 'example-org/sentiment-model'
         1. MB102 train.py:12: model 'example-org/sentiment-model' loaded via from_pretrained() without revision=
         2. MB101 train.py:12: trust_remote_code=True in AutoModelForSequenceClassification.from_pretrained() executes code shipped with the model
         impact: arbitrary code execution in the process that runs train.py
  AP-5  [high] Unverified download is deserialized
         precondition: adversary controls the download host, a mirror, DNS or the network path
         1. MB107 download.py:7: urllib.request.urlretrieve('https://models.example.com/releases/classifier.bin') fetches a model/data file without verifying a checksum
         2. MB103 download.py:10: torch.load(..., weights_only=False) unpickles arbitrary objects
         impact: arbitrary code execution when download.py unpickles the substituted file

Summary: 8 high · 6 medium · 4 low · 5 attack paths  (1 suppressed)

examples/safe-app performs the same tasks safely and scans clean offline (exit code 0). With --online it reports the advisories published against its pinned versions.

Usage

modelbom scan PATH  [--format text|json|sarif] [-o FILE] [--fail-on LEVEL] [--online]
                    [--exclude GLOB ...] [--no-hash] [--max-bytes N] [--verbose] [--no-color]
modelbom bom PATH   [-o aibom.cdx.json] [--online] [--exclude GLOB ...]
modelbom graph PATH [--format mermaid|dot|json] [-o FILE]
modelbom rules      [--format text|json|markdown]
modelbom version
Exit code Meaning
0 No unsuppressed finding at or above --fail-on (default high)
1 At least one unsuppressed finding at or above --fail-on
2 Usage error (bad arguments, missing path)

Inventory records (MB206) never affect the exit code.

Rules

22 rules in three families: code (MB1xx), artifacts (MB2xx) and dependencies (MB3xx). Each carries OWASP Top 10 for LLM Applications 2025, OWASP Top 10 for Agentic Applications 2026, MITRE ATLAS and CWE references. See docs/rules.md or run modelbom rules.

Suppressing findings

  • Inline, on the flagged line (or any line of a multi-line call): torch.load(p) # modelbom: ignore[MB103] or # modelbom: ignore for all rules. The same comment works in requirements.txt and pyproject.toml.

  • .modelbomignore in the scan root:

    data/raw/            # skip a directory
    *.ckpt               # skip by name
    MB202:models/*.pkl   # keep scanning, but suppress MB202 for these files
    

Suppressed findings are still counted in the summary and appear in SARIF with a suppressions entry.

Output formats

  • text: grouped by severity, with remediation and attack paths. Colors only on a TTY; respects NO_COLOR.
  • json: stable schema_version: 1 document with findings, artifacts, hub references, dependencies and attack paths.
  • sarif: SARIF 2.1.0 with rule metadata, security-severity and partial fingerprints, ready for GitHub code scanning.
  • CycloneDX 1.6 AI-BOM (modelbom bom): machine-learning-model, data, file and library components with SHA-256 hashes, pkg:pypi / pkg:huggingface purls and a vulnerabilities section for findings attached to components.
  • graph (modelbom graph): Mermaid, Graphviz DOT or JSON. Attack paths are drawn as dashed AP-n edges and risky nodes are highlighted.

Online vulnerability lookups

--online queries OSV.dev for every exactly pinned dependency (from manifests or lock files) and reports MB302 with the advisory ID, CVE aliases and fixed versions. Without --online, modelbom makes no network requests.

CI integration

GitHub Actions (uploads SARIF to code scanning):

jobs:
  modelbom:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      security-events: write
    steps:
      - uses: actions/checkout@v4
      - uses: rajyavardhan01/modelbom@v0.1.0
        with:
          path: .
          fail-on: high

pre-commit:

repos:
  - repo: https://github.com/rajyavardhan01/modelbom
    rev: v0.1.0
    hooks:
      - id: modelbom

Methodology

modelbom is a reference implementation of the automated vulnerability discovery framework and exploit-pathway analysis described in:

R. Handa, "Securing the Intelligent Software Supply Chain: Vulnerability Detection and Exploit Pathways in AI-Integrated Systems," Journal of Computational Analysis and Applications, vol. 34, no. 12, pp. 46–56, 2025. doi:10.48047/jocaaa.2025.34.12.06

docs/methodology.md maps each feature to the paper's sections and tables, and lists what is not implemented yet.

Artifact scanners such as modelscan, picklescan and fickling focus on the model files themselves. modelbom covers similar ground for pickle-based artifacts and adds source-code rules, dependency pinning, attack paths and a CycloneDX AI-BOM in one zero-dependency CLI. The tools can be used side by side.

Tested on real projects

Before release, modelbom was run against six popular open-source ML projects: training code, inference servers, a RAG application and a notebook-heavy repository, from 1 MB to 140 MB each, scanned statically. Every scan finished in under 3 seconds without errors. In a manual review, the sampled findings were accurate: real trust_remote_code=True calls, torch.load() without weights_only, pickle.load() and unpinned hub references. The same exercise turned up two bugs, both fixed before release: syntax warnings from scanned code leaked to stderr, and notebook cells with multi-line shell escapes failed to parse. Version ranges in a library's pyproject.toml are now reported as informational, because ranges are correct practice for libraries.

Limitations

  • Code analysis is intra-file and literal-based. A hub ID or URL held in a variable, built with string formatting, or passed through a config file is not resolved.
  • A pickle allowlist cannot prove a file safe. A clean result means no known-dangerous import was found, not that loading the file is harmless.
  • .h5 inspection is a bounded byte search, not a full HDF5 parse.
  • No ML-based anomaly detection or behavioral (runtime) analysis yet. See the roadmap.

Roadmap

  • Cross-file data flow for model IDs and paths (config files, constants modules)
  • ONNX external-data and custom-operator checks; TensorFlow SavedModel inspection
  • Model card / license extraction into the AI-BOM
  • Statistical anomaly detection over artifact inventories across commits (P2, "Dependency Mapping and Anomaly Detection")
  • Optional signature verification (Sigstore model signing) when signatures are present

Contributing

See CONTRIBUTING.md. Security issues: see SECURITY.md.

License

Apache License 2.0. See LICENSE and NOTICE.

Citation

If you use modelbom in research, please cite the software (see CITATION.cff) and the paper above.

Metadata

Release files for modelbom 0.1.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 modelbom 0.1.0
File Size Uploaded Provenance Actions
modelbom-0.1.0.tar.gz 76.4 kB With provenance Details for modelbom-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 137.4 kB

Release files / modelbom-0.1.0.tar.gz

Download URL modelbom-0.1.0.tar.gz
Size 76.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6d43570c1e873aafc4c044e66f7fc04343927b558820026f8d4407cde84bc9c6
BLAKE2b-256 checksum
How to use checksums
78d807bc43a945f69b9ff674ca1c27025a2b931985ba8d0815ff347e8e4a212d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / modelbom-0.1.0-py3-none-any.whl

Download URL modelbom-0.1.0-py3-none-any.whl
Size 61.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fc7f8461f4add19ce2fa31be9fdb11c1a28e7623377196655d49c830d0cddd6
BLAKE2b-256 checksum
How to use checksums
ef6ae8df203ca5f6db835ee379c92c807b4064a857c86bf81516a3a1fa8c5c52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Security for modelbom 0.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for modelbom-0.1.0.tar.gz

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 Dec 1, 2026.

Transparency log

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