Secure MLOps and LLMOps pipelines
In this lesson you will:
- Secure CI/CD and model deployment pipelines, including packaging and containers
- Protect integrity and confidentiality during data ingestion and transformation
- Track lineage for fine-tuning
- Design validation checkpoints and pipeline gating
- Manage pipeline credentials and data unlearning capabilities
The pipeline that builds and deploys a model is a powerful system: it reads sensitive data, holds credentials to registries and clouds, and pushes code and models into production. Compromise the pipeline and you can compromise every model it produces.
1. The pipeline as an attack surface
| Stage | Threats | Controls |
|---|---|---|
| Source (code, configs, prompts) | Malicious commits, leaked secrets | Branch protection, code review, signed commits, secret scanning |
| Data ingestion | Poisoned or tampered data, leakage | Validation, hashing, encryption, least-privilege data access |
| Training / fine-tuning | Compromised training jobs, dependency attacks, exposed GPUs | Isolated training environments, pinned and scanned dependencies, ephemeral credentials |
| Evaluation | Manipulated metrics, test-set leakage | Protected evaluation sets, independent evaluation jobs, signed results |
| Packaging | Malicious serialisation, vulnerable base images | Safe formats, minimal signed container images, SBOM/AIBOM generation |
| Registry | Overwrites, unauthorised promotion | Immutable versions, separation of duties, signatures |
| Deployment | Unapproved models, configuration drift | Admission control (verify signature and status), infrastructure as code, staged rollout |
2. Packaging and containerisation
- Build serving images from minimal, trusted base images; scan them for vulnerabilities; sign them.
- Package model, tokenizer, config and code together with a manifest of hashes.
- Run containers as non-root with read-only file systems where possible; restrict network egress from serving containers.
- Generate an SBOM/AIBOM at build time and store it with the release.
3. Ingestion and transformation integrity
- Pull data only from approved sources using scoped, read-only credentials.
- Verify hashes against the approved dataset version before use.
- Encrypt intermediate artefacts (feature stores, shards, caches) and clean them up after the job.
- Keep transformation code in version control so a feature can be reproduced exactly.
4. Lineage for fine-tuning
Fine-tuning is fast and cheap, so it multiplies quickly — and each fine-tune can change safety behaviour or memorise data. Record for every run:
- Base model version and hash.
- Dataset versions and hashes.
- Code commit and hyperparameters.
- Who launched it and where it ran.
- Output artefact hashes (adapter or merged weights).
- Evaluation results, including safety regression tests.
5. Validation checkpoints and gating
Gates are automated checks that block promotion when criteria aren't met. Typical gates:
- Data gate — schema, distribution, PII and poisoning checks pass.
- Quality gate — performance at or above threshold on the protected test set; no significant regression versus the current model.
- Fairness gate — subgroup metrics within tolerance.
- Safety and security gate — jailbreak/injection test suite, harmful-content evaluations, adversarial robustness tests; no regression.
- Supply-chain gate — dependencies scanned, artefacts signed, AIBOM generated.
- Approval gate — human sign-off for higher tiers.
A gate that can be skipped "just this once" is not a gate. Exceptions should go through the same documented exception process as any other risk acceptance.
6. Pipeline credentials
Pipelines hold some of the most powerful credentials in the organisation.
- Use workload identity federation and short-lived tokens instead of long-lived keys.
- Scope credentials per stage: the training job can read data and write to a staging area — not promote to production.
- Separate the identities that build and those that deploy.
- Never put secrets in notebooks, training scripts or container images.
- Monitor pipeline identities like privileged users.
7. Data unlearning capabilities
Pipelines should be able to answer: "remove this data and produce a model that never saw it."
- Datasets are versioned, so a new version can exclude specific records.
- Training is reproducible from code and configuration.
- Sharded or modular training (where designed in) limits retraining cost.
- Removal requests trigger the pipeline with evidence recorded for the privacy office.
Worked example — a compromised notebook token
An attacker phishes a data scientist and obtains a long-lived token stored in their notebook environment.
| With a weak pipeline | With a secure pipeline |
|---|---|
| Token can read all training data | Token is short-lived and scoped to one project's staging data |
| Token can push to the model registry and mark models approved | Promotion requires a separate role and signed evaluation results |
| Production loads whatever is newest | Admission control loads only signed, approved versions |
| No record of which jobs used the token | Pipeline identity logs show exactly what was accessed |
Outcome in the secure case: limited data exposure in one project, no route to production, fast scoping from logs.
🔐 Security lens
Apply your software supply-chain programme (signed commits, pinned dependencies, build provenance, admission control) to ML pipelines. Then add the AI-specific gates — data, fairness and safety — on top.
Key takeaways
- The ML pipeline is a high-value target: source, ingestion, training, evaluation, packaging, registry and deployment all need controls.
- Use minimal signed images, safe model formats, non-root read-only containers and build-time SBOM/AIBOMs.
- Record fine-tuning lineage, including safety-regression results.
- Gates for data, quality, fairness, safety/security, supply chain and approval — no silent bypasses.
- Short-lived, scoped, separated pipeline credentials; reproducible training enables unlearning.
Self-check
- Why should the identity that trains a model not be able to promote it to production?
- Name three gates a model should pass before promotion.
- What must a fine-tuning lineage record contain to support later investigation?