Create Model Ops and Supply Chain Security Cheat Sheet#2058
Create Model Ops and Supply Chain Security Cheat Sheet#2058Tryingtobeabetterprogrammer wants to merge 9 commits intoOWASP:masterfrom
Conversation
Initial draft covering unsafe deserialization risks, model scanning (modelscan), and migration to safetensors. Fixes OWASP#1781.
mackowski
left a comment
There was a problem hiding this comment.
Looks like a good start IMO
jmanico
left a comment
There was a problem hiding this comment.
-
I would rename this "Machine Learning Model Supply Chain Security Cheat Sheet"
-
The real issue isn't just pip install model, it's that model loading often triggers dynamic code execution through custom layers, preprocessing hooks, or reduce methods in Pickle. HuggingFace from_pretrained() calls can execute arbitrary code from config.json custom class references. That's worth calling out explicitly.
-
On prompt injection in tool models, I'd actually recommend keeping this out of scope or mentioning it only briefly with a cross-reference to a prompt injection cheat sheet.
-
add clean-label poisoning, where the attacker manipulates training examples that are correctly labeled but positioned to shift decision boundaries.
-
One significant gap: model format conversion attacks. When organizations convert between formats (PyTorch → ONNX → TensorRT, for example), the conversion pipeline itself can introduce vulnerabilities. ONNX custom operators can embed arbitrary code. TensorFlow SavedModel's tf.py_function wraps arbitrary Python. This deserves its own subsection.
-
Another: SBOM for models. The cheat sheet should reference the concept of an ML Bill of Materials, tracking not just the model artifact but the training data lineage, framework versions, and dependency graph. This aligns with NIST SP 800-218 (SSDF) and the broader software supply chain security direction OWASP is moving toward.
-
Also missing: weight-level integrity verification. Hash-pinning the whole file is necessary but not sufficient. Techniques exist to modify individual weight tensors while preserving file-level checksums if the hash isn't computed correctly. The cheat sheet should specify hashing the serialized artifact at rest and verifying before every load, not just at download time.
|
Hi @jmanico, thank you so much for this incredibly detailed and high-level feedback! |
…Learning_Model_Supply_Chain_Security_Cheat_Sheet.mdMachine_Learning_Model_Supply_Chain_Security_Cheat_Sheet.md
… to Machine_Learning_Model_Supply_Chain_Security_Cheat_Sheet.md
Added sections on Model Format Conversion Attacks, Clean-Label Model Poisoning, Weight-Level Integrity Verification, and Model Bill of Materials to enhance guidance on Model Supply Chain Security.
|
Nice work on the updates! The rename, format conversion attacks section, ML-BOM, and clean-label poisoning additions all look good. A few things to address before this is ready to merge:
You are making great progress on this. Looking forward to the next revision! |
Added sections on Model Format Conversion Attacks, Clean-Label Model Poisoning, Weight-Level Integrity Verification, Model Bill of Materials (ML-BOM), HuggingFace `from_pretrained()` RCE Risk, Security Note on Safetensors, and Security Scanning Tools.
|
Hi @jmanico, I've addressed all the feedback from the previous review:
The PR also includes the This PR fixes issue #1781 line. Ready for your final review! |
|
Can I ask for a few more things?
|
Updated the cheat sheet to include links and emphasize security notes regarding model loading and trust issues.
|
Hi @jmanico! I've completed the final round of polishing based on your suggestions:
All checks are passing. Ready for final review and merge! |
There was a problem hiding this comment.
Pull request overview
Adds a new cheat sheet to the OWASP Cheat Sheet Series focused on ML model artifact supply-chain risks (notably unsafe deserialization), and practical mitigations like safetensors migration, pre-ingestion scanning, and integrity/provenance controls.
Changes:
- Introduces a new “Machine Learning Model Supply Chain Security” cheat sheet covering pickle/RCE risks, conversion attack surface, and ML-BOM concepts.
- Adds example snippets for unsafe vs. safer model loading and registry-level controls.
- Documents suggested tooling for static model scanning (ModelScan / Fickling).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ### Model Bill of Materials (ML-BOM) | ||
|
|
||
| Aligning with **NIST SP 800-218 (SSDF)**, an ML-BOM provides a verifiable record of the model's supply chain. |
There was a problem hiding this comment.
The document cites NIST SP 800-218 (SSDF) in the ML-BOM section, but the References list links to NIST SP 800-218A. Please make the reference entry match the cited publication (or adjust the earlier citation) so readers can find the correct source.
| Aligning with **NIST SP 800-218 (SSDF)**, an ML-BOM provides a verifiable record of the model's supply chain. | |
| Aligning with **NIST SP 800-218A (SSDF)**, an ML-BOM provides a verifiable record of the model's supply chain. |
| # Machine Learning Model Supply Chain Security Cheat Sheet | ||
|
|
||
| ## Introduction | ||
|
|
||
| Machine Learning (ML) models are frequently treated as static data, but in many common formats (like Python's Pickle), they are actually executable code. This "Model-as-Code" reality introduces significant supply chain risks, where malicious actors can embed "Pickle Bombs" or backdoors into pre-trained models. |
There was a problem hiding this comment.
PR metadata says this PR fixes #1781 (an update to the existing Secure AI/ML Model Ops cheat sheet), but this change only adds a new supply-chain-focused cheat sheet and does not update cheatsheets/Secure_AI_Model_Ops_Cheat_Sheet.md. If the intent is to close #1781, please either update the existing Model Ops cheat sheet (or clarify in the PR description why adding this new file resolves the issue).
|
|
||
| ## Scope and Specific Controls | ||
|
|
||
| ### Out of Scope: Prompt Injection |
There was a problem hiding this comment.
Per the contributing guide, headings should have a blank line after them. Add a blank line after this ### Out of Scope: Prompt Injection heading.
| ### Out of Scope: Prompt Injection | |
| ### Out of Scope: Prompt Injection |
|
|
||
| In clean-label attacks, malicious samples are correctly labeled to evade human audit while strategically shifting the model's decision boundaries. This creates "triggers" where the model performs normally on most data but fails or misclassifies specific inputs chosen by the attacker. | ||
|
|
||
| ### Weight-Level Integrity Verification |
There was a problem hiding this comment.
Per the contributing guide, headings should have a blank line after them. Add a blank line after ### Weight-Level Integrity Verification before the paragraph/list that follows.
| ### Weight-Level Integrity Verification | |
| ### Weight-Level Integrity Verification |
| * [NIST SP 800-218A: AI-Specific Secure Software Development](https://doi.org/10.6028/NIST.SP.800-218A) | ||
| * [MITRE ATLAS Framework](https://atlas.mitre.org/) | ||
| * [OWASP AI Security Verification Standard (AISVS)](https://owasp.org/www-project-ai-security-verification-standard/) | ||
| * [Hugging Face Security Documentation](https://huggingface.co/docs/hub/security) | ||
| * [CycloneDX ML-BOM Specification](https://cyclonedx.org/capabilities/mlbom/) | ||
| * [OWASP Top 10 for LLM Applications](https://genai.owasp.org/llm-top-10/) | ||
| * [ModelScan GitHub Repository](https://github.com/protectai/modelscan) |
There was a problem hiding this comment.
The References list uses * bullets, but markdownlint config enforces MD004 style "dash". Switch these bullets to - to avoid lint failures.
| * [NIST SP 800-218A: AI-Specific Secure Software Development](https://doi.org/10.6028/NIST.SP.800-218A) | |
| * [MITRE ATLAS Framework](https://atlas.mitre.org/) | |
| * [OWASP AI Security Verification Standard (AISVS)](https://owasp.org/www-project-ai-security-verification-standard/) | |
| * [Hugging Face Security Documentation](https://huggingface.co/docs/hub/security) | |
| * [CycloneDX ML-BOM Specification](https://cyclonedx.org/capabilities/mlbom/) | |
| * [OWASP Top 10 for LLM Applications](https://genai.owasp.org/llm-top-10/) | |
| * [ModelScan GitHub Repository](https://github.com/protectai/modelscan) | |
| - [NIST SP 800-218A: AI-Specific Secure Software Development](https://doi.org/10.6028/NIST.SP.800-218A) | |
| - [MITRE ATLAS Framework](https://atlas.mitre.org/) | |
| - [OWASP AI Security Verification Standard (AISVS)](https://owasp.org/www-project-ai-security-verification-standard/) | |
| - [Hugging Face Security Documentation](https://huggingface.co/docs/hub/security) | |
| - [CycloneDX ML-BOM Specification](https://cyclonedx.org/capabilities/mlbom/) | |
| - [OWASP Top 10 for LLM Applications](https://genai.owasp.org/llm-top-10/) | |
| - [ModelScan GitHub Repository](https://github.com/protectai/modelscan) |
|
|
||
| While `safetensors` prevents code execution during weight loading, it does **not** solve the trust problem. A malicious repository can still bundle a safe `.safetensors` weight file with a malicious `config.json` that triggers code execution via the `trust_remote_code` flag. Always audit the repository files beyond just the weights. | ||
|
|
||
| ## Security Scanning Tools |
There was a problem hiding this comment.
There should be a blank line after headings per the contributing guide. Add a blank line between ## Security Scanning Tools and the following ### 1. ... heading.
| ## Security Scanning Tools | |
| ## Security Scanning Tools |
| - **Digital Signatures:** Ensure the ML-BOM itself is cryptographically signed and linked to the model hash to prevent tampering. | ||
| - **Guidance:** Integrate ML-BOM generation into the CI/CD pipeline using standardized formats like CycloneDX or SPDX. | ||
|
|
||
| ### HuggingFace `from_pretrained()` RCE Risk |
There was a problem hiding this comment.
The heading uses "HuggingFace" but elsewhere in this cheat sheet you use "Hugging Face" (and that's the standard spelling). Use a consistent name to avoid confusion and improve searchability.
| ### HuggingFace `from_pretrained()` RCE Risk | |
| ### Hugging Face `from_pretrained()` RCE Risk |
|
@Tryingtobeabetterprogrammer please address markdown linter failures and Copilot review |
Added sections on model supply chain security, including prompt injection, model format conversion attacks, clean-label model poisoning, weight-level integrity verification, ML-BOM, and HuggingFace RCE risk mitigation.
|
Linter is still failing |
Initial draft covering unsafe deserialization risks, model scanning (modelscan), and migration to safetensors. Fixes #1781.
You're A Rockstar
Thank you for submitting a Pull Request (PR) to the Cheat Sheet Series.
Please make sure that for your contribution:
[TEXT](URL)If your PR is related to an issue, please finish your PR text with the following line:
This PR fixes issue #1781.
AI Tool Usage Disclosure (required for all PRs)
Please select one of the following options:
the contents and I affirm the results. The LLM used is Gemini 3 Flash
and the prompt used is
Help me draft a new OWASP cheat sheet for Model Ops and Supply Chain Security, focusing on Pickle risks, Safetensors, and model scanning.Thank you again for your contribution 😃