Secure ML Model Supply Chain with Attestations and Provenance
As Sherlock, I'll architect a secure supply chain for ML model artifacts (e.g., trained models, weights, configs, datasets) that ensures integrity, authenticity, provenance, and auditability. This design draws from SLSA (Supply-chain Levels for Software Artifacts) Level 3+ principles, in-toto attestations, and Sigstore ecosystem for cryptographic guarantees. It covers:
- Pipeline instrumentation: Automated CI/CD with provenance generation.
- Storage hardening: Immutable, encrypted storage.
- Verification workflows: End-to-end checks.
- Compliance evidence: Auditable logs and reports.
The system achieves tamper-proof traceability from code commit to model deployment, defending against supply chain attacks (e.g., poisoned models, injected backdoors).
1. High-Level Architecture
[Source Repo (GitHub/GitLab)] --> [Instrumented CI/CD Pipeline (GitHub Actions/Tekton)]
├── Generate Provenance (SLSA/in-toto) & Attestations (SLSAf, Cosign)
└── Sign Artifacts (Sigstore/Cosign)
↓
[Hardened Storage (S3/GCS w/ Object Lock + KMS)]
├── Timestamp in Transparency Log (Rekor)
└── Reproducible Builds Metadata
↓
[Verification Gate (Cosign Verify + Policy Controller)] --> [Deploy (Kubernetes/Vertex AI)]
↓
[Audit Dashboard (Grafana + OPA Gatekeeper)] --> Compliance Reports (SOC2/ISO 27001)
Key Tools:
| Component | Tools |
|---|
| Pipeline | GitHub Actions, Tekton (on Kubernetes) |
| Provenance/Attestations | SLSA GitHub Generator, in-toto-attestation, Cosign |
| Signing/Transparency | Sigstore (Fulcio OIDC keys, Rekor log) |
| Storage | AWS S3 (Object Lock), GCS (Bucket Lock), MinIO |
| Verification | Cosign, OPA (Open Policy Agent), Kyverno |
| ML-Specific | MLflow/DVC for versioning, safetensors/ONNX for safe serialization |
| Monitoring | Prometheus/Grafana, Trivy/Syft for SBOM |
Assumptions: GitHub repo with ML code (e.g., PyTorch/TensorFlow). Models output as .safetensors or ONNX for safety.
2. Pipeline Instrumentation
Instrument your ML training pipeline to automatically generate provenance at each step.
Steps:
- Source Control: Use Git with branch protection (require signed commits via Sigstore).
- CI/CD Workflow (GitHub Actions example):
# .github/workflows/ml-supply-chain.yaml
name: Secure ML Pipeline
on: [push, pull_request]
permissions:
id-token: write # For OIDC to Sigstore
contents: read
actions: write # For SLSA provenance
jobs:
build-train:
runs-on: ubuntu-latest
container: python:3.11-slim # Reproducible env
steps:
- uses: actions/checkout@v4
with: fetch-depth: 0 # Full history for repro
- name: Reproducible Setup
uses: actions/setup-python@v5
with: { python-version: '3.11' }
- name: Generate SBOM (Software Bill of Materials)
uses: anchore/sbom-action@v1
with: { output-file: sbom.json }
- name: Train Model
run: |
pip install -r requirements.lock # Locked deps via Poetry/Pipenv
python train.py --data gs://my-bucket/train-data --model-out model.safetensors
# Instrument: Log env, deps, inputs/outputs
- name: Generate SLSA Provenance
uses: slsa-framework/slsa-github-generator/.github/actions/provenance@v1.8.0
with:
base-sha: ${{ github.sha }}
upload: true # To GitHub Artifact
- name: Attest Build (in-toto)
uses: in-toto/attestation-action@v1
with:
predicate-type: https://slsa.dev/provenance/v0.2
subject: model.safetensors
- name: Sign Artifact
uses: sigstore/cosign-installer@v3
# Then: cosign sign --yes -a build_timestamp=$(date) model.safetensors
run: |
cosign sign --yes -a git-commit=${{ github.sha }} model.safetensors@sha256:digest
- name: Upload to Storage
uses: aws-actions/configure-aws-credentials@v4
# aws s3 cp model.safetensors s3://secure-ml-artifacts/ --expected-size 1GB
- ML-Specific Instrumentation:
- Use MLflow or DVC to track params, metrics, inputs/outputs.
- Reproducibility: Docker with
pip freeze > requirements.lock, seed RNGs.
- Dataset Provenance: Use Data Version Control (DVC) with Git LFS for datasets, attest hashes.
Outcome: Each run produces .intoto.jsonl (attestations) + signed artifacts + SLSA provenance (who/what/when/where/how built).
3. Storage Hardening
Store artifacts immutably and encrypted.
- Bucket Config (AWS S3 example):
aws s3api put-bucket-versioning --bucket secure-ml-artifacts --versioning-configuration Status=Enabled
aws s3api put-object-lock-configuration --bucket secure-ml-artifacts --object-lock-configuration '{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"GOVERNANCE","Days":365}}}'
aws s3api put-bucket-encryption --bucket secure-ml-artifacts --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"alias/ml-kms-key"}}]}'
aws s3api put-public-access-block --bucket secure-ml-artifacts --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"
- Access: IAM roles with least-privilege (e.g.,
s3:GetObject only for verifiers).
- Rekor Timestamp: After upload,
cosign verify --certificate-identity ... and append to Rekor log for non-repudiation.
- ML Twist: Store models in
model.safetensors (safe from pickle exploits), with metadata JSON (hash tree for weights).
Defense: WORM (Write-Once-Read-Many) prevents tampering; KMS rotates keys.
4. Verification Workflows
Gate deployments with multi-verification.
-
CLI Verification:
# Fetch & Verify
cosign verify --certificate-oidc-issuer https://accounts.google.com --keyless s3://secure-ml-artifacts/model.safetensors
# Check Provenance
slsa-verifier --provenance-path slsa-provenance.intoto.jsonl --source-git model.safetensors
# Policy Check (e.g., builder must be GitHub Actions)
opa exec --input policy-input.json policy.rego # See below
-
Kubernetes Admission Controller (Kyverno/OPA Gatekeeper):
# Kyverno Policy: Verify ML Model
apiVersion: kyverno.io/v1
kind: ClusterPolicy
spec:
rules:
- name: verify-ml-model
match:
resources:
kinds: [Deployment]
verifyImages:
- imageReferences: ["my-ml-app:*"]
attestors:
- entries:
- keys: {k8sServiceAccount: "github-actions"}
oids: [{issuer: "https://token.actions.githubusercontent.com"}]
-
SBOM Scan: syft packages model-container -o cyclonedx-json | grype -.
Workflow: Pre-deploy hook runs all checks; fail if mismatch.
5. Compliance Evidence
Automated Auditing:
- Transparency Log: Query Rekor (
rekor-cli search --sha model-hash) for immutable timeline.
- Dashboard: Grafana with Loki/Prometheus:
- Metrics: Pipeline success rate, verification fails.
- Logs: Attestations parsed via
intoto parse.
- Reports:
Maturity Levels (SLSA-inspired):
| Level | Features |
|---|
| 1 (Available) | Signed artifacts |
| 2 (Provenance) | SLSA metadata |
| 3 (Reproducible) | Full repro + attestations |
| 4 (Verified) | 100% pipeline coverage |
Implementation Roadmap
- Week 1: Set up GitHub Actions + Cosign signing.
- Week 2: Add SLSA/in-toto + hardened S3.
- Week 3: Deploy verification gates.
- Week 4: Dashboard + compliance policies.
- Test: Poison a model, ensure verification blocks it.
This pipeline is SLSA Level 3 compliant, scalable to enterprise (e.g., multi-tenant via namespaces). Costs: ~$0.01 per build (GitHub + S3). For customizations (e.g., Azure/GCP), ping me!
Need code repos, diagrams, or a POC? Let's deduce further. 🕵️♂️