SuperAPI AI Directory

model-due-diligence

Static review CLI for AI model files and cloned model repositories before they are imported into local runtimes or agent stacks.

Open website

About this tool

Purpose

model-due-diligence is a Python command-line tool for performing static supply chain due diligence on local AI model files or cloned model repositories before importing them into a runtime (such as Ollama, llama.cpp, LM Studio, or Transformers). It is intended to help answer a practical question: is there obvious static evidence that the model artifact or repository should not be trusted, loaded, or run without further review? It reduces the practical risks arising from unsafe serialization, suspicious repository contents, weak provenance, exposed secrets, unexpected binaries, unsafe dependency files, and malformed model metadata.

Main capabilities

The tool performs static inspection of local paths and produces reviewable evidence covering: file inventories, SHA-256 hashes, permissions, and symlinks; high-risk serialization formats (such as pickle, .pt, .pth, .bin, .joblib, and H5); lower-risk model formats (such as .gguf, .safetensors, and .onnx); GGUF magic bytes and version metadata; safetensors header metadata; suspicious text and binary strings; Python AST indicators (such as eval, exec, compile, pickle.loads, os.system, and subprocess); trust_remote_code=True usage in Python and text files; dangerous pickle-like byte markers in high-risk serialization formats; high-entropy non-model files; Git provenance, origin remote, current commit, dirty working tree, and Git LFS listing (if available); and external scanner output from ModelScan, Semgrep, Bandit, pip-audit, and detect-secrets. Optionally uses Ruff, Pyright, and mypy to perform quality self-checks on the scanner project itself (requires enabling --quality-self-check).

The tool generates: human-readable Markdown reports; deterministic JSON reports for automation; optional SARIF reports for code scanning workflows; and raw external scanner output when running external tools. Discovered items are normalized into severity levels and converted into a bounded score from 0 to 100. External scanner non-zero exit codes, when the tool is available and produces usableIt can also contribute a score when reviewing signals. The score is a conservative decision aid, not an automatic trust verdict.

How to use

Installation requirements: Python 3.11 or later; a Unix-like shell for providing scripts; optional external scanner CLIs for full coverage. It can be installed from PyPI, with optional external scanner integrations and a local dashboard.

The canonical command is mdd (also available via model-due-diligence and python -m model_due_diligence). mdd-ui is a single local Python process that serves the static UI at /, exposes the API under /api/v1/, and calls the same in-process static scan engine as the CLI. Ollama is an optional external model source, not the project's backend.

Example workflows: scan a cloned model repository; scan a local GGUF file; scan an installed Ollama model by name; fail the command when the risk level is medium or above; run a quick smoke scan; generate JSON output only; start the local dashboard. mdd-ollama resolves installed Ollama models from the local OLLAMA_MODELS store, stages filenames suitable for scanning in a temporary directory, and then runs the normal static due diligence process on that staging directory. As long as the local manifest and blob store exist, no Ollama server needs to be running.

When to use

Run model-due-diligence before importing or loading model artifacts; manually review all HIGH and CRITICAL findings; run first inference in a networkless container or VM; do not mount API keys, SSH keys, cloud credentials, or customer data; test prompt injection and tool use behavior before RAG or agent deployment; retain reports and accepted hashes to ensure reproducibility. Prefer official publisher repositories or reputable quantizers, avoid floating tags such as latest, pin exact Git revisions, and record SHA-256 hashes. A Hugging Face clone audit helper script is also provided, which clones to a temporary directory, runs the scanner, writes the report to the output directory, and then deletes the temporary clone.

Limitations

The tool is static and during a normal scan does not: load model weights; import untrusted repository code; execute model-specific scripts; run model inference; send artifacts to external services; localscanning requires network access; automatically determine that a model is safe. Static scanning cannot reliably detect: malicious behavior directly encoded into model weights; dormant agents or trigger-based backdoors; training data poisoning; benchmark manipulation; malicious behavior that appears only after fine-tuning; malicious behavior that appears only after connecting tools; prompt injection compliance in downstream RAG or agent workflows; data exfiltration behavior that appears only at runtime; vulnerabilities in local model runtimes; evasion of all unsafe deserialization. A clean report only indicates that the tool did not identify the specific static risks it is designed to detect, and must not be regarded as proof that model weights, repository contents, runtime behavior, or downstream use are harmless. The tool should not be used as the sole approval mechanism for regulated production deployments, customer data processing, networked agent systems, autonomous coding agents with write permissions, or systems with access to keys or privileged infrastructure.

The tool should not be regarded as a model safety verifier, but as one control within a broader model supply chain process. Planned or candidate improvements include: more complete GGUF metadata validation; safetensors tensor offset and shape validation; Hugging Face metadata retrieval using pinned revisions; SBOM generation; Sigstore or SLSA provenance checks; license compatibility checks; model card quality scoring; SARIF upload workflows; sandboxed behavioral testing tools for local inference; prompt injection and tool use behavior testing for RAG and agent workloads. This project is licensed under the Apache License 2.0.