Security and isolation
Constrain untrusted models, data, and tools with explicit trust boundaries, least privilege, provenance, and layered isolation.
On this page
The question for today
What you’ll understand
- Identify code execution and data-exfiltration paths in an AI workload.
- Design narrowly scoped identities, network policy, and artifact promotion.
- Separate availability redundancy from security and authorization guarantees.
An uploaded model is not necessarily inert data. Loading its serialization, installing its dependencies, or running its custom operators can execute code. Even a model loaded through a safer tensor format can produce instructions that an application mistakenly treats as authority. Infrastructure security starts by naming the assets and trust boundaries: training data, credentials, artifact storage, serving hosts, tool permissions, and the control plane.
Treat the supply chain as an execution path
Separate artifact ingestion from production promotion. Record origin, immutable digest, license or usage constraints, expected format, and a review decision. A digest verifies that bytes match a selected identity; it does not prove the producer was trustworthy. Scan dependencies and artifacts, but regard a clean scan as limited evidence rather than proof of safety. Restrict formats that can execute arbitrary deserialization logic and avoid enabling unreviewed remote code simply because a model's README requests it.
PyTorch's security guidance treats untrusted models as untrusted code. Distributed Checkpoint explicitly assumes trusted jobs and storage; its loading path should not be presumed to inherit weights-only protections from another API. Safer tensor serialization reduces a particular deserialization attack surface, but custom kernels, tokenizers, dependency installation, and application tools remain separate surfaces. Evaluate unknown artifacts in an isolated environment with no production credentials, restricted egress, resource limits, and a controlled route for promoting validated outputs.
Give each workload only its required authority
Use separate service identities for training, artifact publication, and inference. A training job reading one dataset should not receive permissions to alter the serving deployment or list every secret. Prefer short-lived, scoped credentials and deny unnecessary token mounting. Secrets should not appear in model prompts, images, logs, or broadly readable environment dumps. Network restrictions should prevent unexpected access to metadata endpoints, internal databases, and the public internet, while explicitly allowing required communication and observability.
Containers share important host resources and are not a universal hard boundary for mutually hostile tenants. Select sandboxing, virtual machines, dedicated nodes, or stronger separation according to the threat model and hardware sharing behavior. Kubernetes namespaces organize resources but do not automatically isolate all network, storage, node, or identity paths. Test enforcement: verify a denied action actually fails from inside the workload, and review privileged pods, host mounts, device access, and control-plane permissions as ways a boundary can be bypassed.
Keep model output below the authorization boundary
Retrieved documents, user prompts, and model output can contain adversarial instructions. Treat them as data to interpret under a policy, not as permission to run arbitrary tools. A server-side tool gateway should validate authenticated caller identity, target resource, allowed action, and arguments independently of generated text. Constrain file paths, outbound destinations, and query scope. Require explicit workflow authorization for sensitive effects, and make repeated tool attempts idempotent where possible so retries cannot amplify damage.
Isolation also limits blast radius when a component fails or is contained. Redundant replicas can preserve availability while one instance is quarantined, but they can replicate the same vulnerable image or share the same leaked credential. Majority counts therefore cannot establish trust. Audit who accessed which protected asset, rotate compromised credentials, preserve evidence under retention policy, and test incident containment. Security controls must remain understandable during recovery: emergency access needs narrow scope, expiry, and an audit trail rather than permanent administrator credentials.
Work it through
Contain an untrusted embedding evaluation
A team wants to evaluate a community model on 50,000 confidential documents. The model repository requests custom remote code and includes a package installation script. Design a reviewable execution path.
Classify both the model code and installation script as executable untrusted inputs. Record exact revisions and digests, and inspect dependencies before granting any data access.
Evaluate compatibility first using synthetic documents inside a sandbox with no production identity, no host mounts, and denied outbound access except a controlled artifact-fetch phase.
If approved for confidential data, issue a short-lived identity that can read only the evaluation dataset and write only the designated results location. Keep model code from obtaining deployment or secret-management permissions.
Promote results through a reviewed artifact boundary and inspect output for unintended disclosure. Record the decision and destroy or revoke the temporary environment and credentials according to policy.
The model does not gain production authority merely because evaluation is useful. Data access, code execution, network access, and artifact promotion are separate decisions.
The living notebook
Explore the model
Interactive lab · reliability
Separate containment capacity from trust
Use n replicas and k unavailable instances to inspect majority availability during an illustrative quarantine. The lab models only counts. It does not model compromise, independent security domains, credential scope, or resistance to malicious voters.
- Available replicas
- 4 of 5
- Majority needed
- 3
- Majority available?
- Yes
A replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forSpare replicas may support containment, but shared credentials or shared vulnerable code can defeat the apparent separation.
Pause & reason
Check your understanding
Your turn
Try it yourself
An inference identity can read model artifacts, write logs, deploy workloads, and read all training datasets. The endpoint only needs the first two actions. Propose a permission change and explain why a namespace alone does not complete isolation.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Compare the enumerated required set with the effective set. Then inspect paths outside namespaced application resources.
Compare with the solution
Remove deployment and training-data permissions, scope artifact reads and log writes to the required resources, and use short-lived credentials. A namespace alone does not constrain every network path, host mount, node-level privilege, device, or cluster-scoped permission. Enforce and test those boundaries separately; the reduced permission set is necessary but not a complete security proof.
Keep the idea
Take it with you
- Unknown models and their dependencies can be executable supply-chain inputs.
- Use scoped identities and tested isolation according to an explicit threat model.
- Generated text never substitutes for independent authorization.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.