We are going to design a zero-trust ML deployment system with the following key components:
- Container isolation: each model runs in its own isolated container.
- Model attestation: ensure the model container and its contents are verified and trusted.
- Runtime policy enforcement: enforce policies at runtime for things like network access, resource usage, and data handling.
Steps:
-
Container Isolation:
- Use Docker or similar containerization technology.
- Each model is packaged with its dependencies in a container.
- Use user namespaces, seccomp, AppArmor/SELinux for additional isolation.
-
Model Attestation:
- Generate a hash (SHA-256) of the model container image and store it in a trusted registry.
- Use a signing mechanism (e.g., Docker Content Trust, Notary) to sign the image.
- At deployment, verify the signature and hash of the image against a known good value.
-
Runtime Policy Enforcement:
- Use a service mesh (like Istio) or a sidecar proxy (like Envoy) to control network traffic.
- Define policies for which services the model container can communicate with and on which ports.
- Use Kubernetes Network Policies if deploying on Kubernetes.
- For resource limits (CPU, memory), use container runtime constraints (e.g., in Docker or Kubernetes).
- For more complex policies (e.g., based on request content), use an admission controller or a custom policy engine (like Open Policy Agent) that can inspect traffic and enforce rules.
Architecture:
We assume deployment in a Kubernetes cluster for orchestration, but the principles can be adapted.
Steps in detail:
-
Container Image Building and Signing:
- Build the model container image (Dockerfile).
- Sign the image using Docker Content Trust (with Notary) or Cosign.
- Push the signed image to a trusted registry.
-
Kubernetes Deployment with Attestation:
- Use an admission controller (like OPA or a custom one) to verify the image signature and hash at the time of pod creation.
- The admission controller checks that the image is signed by a trusted authority and the hash matches the expected one.
-
Network Policy:
- Define a Kubernetes NetworkPolicy that restricts which pods can communicate with the model pod (by labels) and on which ports.
-
Runtime Policy Enforcement with Sidecar:
- Deploy a sidecar proxy (Envoy) alongside the model container in the same pod.
- Configure Envoy to filter and monitor traffic based on defined policies (using access logging, rate limiting, etc.).
- Alternatively, use a service mesh like Istio which provides more integrated policy enforcement.
-
Resource Limits:
- Set resource requests and limits in the Kubernetes pod spec.
-
Additional Isolation:
- Use Kubernetes Pod Security Policies (or the newer Pod Security Admission) to run containers as non-root, with seccomp, etc.
Example:
Let's create a simple example for a model serving container.
Step 1: Dockerfile for model server (e.g., using TensorFlow Serving)
FROM tensorflow/serving:latest
# Copy the model
COPY model /models/my_model
# Set environment variables for TensorFlow Serving
ENV MODEL_NAME=my_model
# Expose the port
EXPOSE 8500
# Run TensorFlow Serving
CMD ["tensorflow_model_server", "--port=8500", "--rest_api_port=8501", "--model_name=${MODEL_NAME}", "--model_base_path=/models/${MODEL_NAME}"]
Step 2: Build and sign the image.
# Enable Docker Content Trust
export DOCKER_CONTENT_TRUST=1
# Build and tag
docker build -t myregistry.com/my_model:latest .
# Push (this will prompt for signing if not already signed, and then push)
docker push myregistry.com/my_model:latest
Step 3: Kubernetes deployment manifest with resource limits and network policy.
deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-model-deployment
spec:
replicas: 1
selector:
matchLabels:
app: my-model
template:
metadata:
labels:
app: my-model
spec:
containers:
- name: my-model
image: myregistry.com/my_model:latest
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
ports:
- containerPort: 8500
name: grpc
- containerPort: 8501
name: rest
# Optional: sidecar for advanced policy enforcement
- name: envoy-sidecar
image: envoyproxy/envoy:v1.22.0
# ... Envoy configuration ...
network-policy.yaml:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: my-model-network-policy
spec:
podSelector:
matchLabels:
app: my-model
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: allowed-app # only allow from pods with label app=allowed-app
ports:
- protocol: TCP
port: 8500
- protocol: TCP
port: 8501
egress:
- to:
- podSelector:
matchLabels:
app: some-other-service
ports:
- protocol: TCP
port: 80
Step 4: Admission Controller for Image Attestation.
We can use OPA Gatekeeper to enforce image signature and hash.
Example constraint template for image signature:
apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
name: k8srequiredimageattestation
spec:
crd:
spec:
names:
kind: K8sRequiredImageAttestation
validation:
openAPIV3Schema:
properties:
allowedImages:
type: array
items:
type: string
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package k8srequiredimageattestation
violation[{"msg": msg, "details": {"allowedImages": allowedImages}}] {
container := input.review.object.spec.containers[_]
image := container.image
not allowed_image(image, allowedImages)
msg := sprintf("container <%v> uses an unapproved image <%v>", [container.name, image])
}
allowed_image(image, allowedImages) {
allowed := allowedImages[_]
startswith(image, allowed)
}
But note: this only checks the image name/path. We need to check the signature and hash.
Alternatively, we can use Cosign and have an admission controller that verifies the image signature and matches the hash.
We can write a custom admission controller or use an existing one that supports Cosign.
Since this is complex and depends on the setup, we might consider using the built-in image policy webhook in Kubernetes (if using a container runtime that supports it) or use a third-party solution.
Alternatively, we can use the imagePullPolicy: IfNotPresent and rely on the fact that the image is pulled from a trusted registry and the node's Docker daemon has been configured to trust only signed images.
However, for zero-trust, we want to verify at admission time.
Given the complexity, we might break down:
Option 1: Use a custom admission controller that uses Cosign to verify the image signature and then also checks the hash against a list of allowed hashes.
Option 2: Use a policy that the image must be from a trusted registry and then use a hash allowlist.
Step 5: Runtime policy enforcement with Envoy.
We can deploy Envoy as a sidecar and use an EnvoyFilter (if using Istio) or a standalone Envoy configuration.
Example Envoy configuration for rate limiting and access logging:
envoy.yaml:
static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 8500
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: backend
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: my_model_service }
http_filters:
- name: envoy.filters.http.router
clusters:
- name: my_model_service
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: my_model_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8500
But note: we are running the model on the same pod on port 8500, so we point to localhost:8500.
We can then add filters for rate limiting, etc.
However, for zero-trust, we might want to enforce policies at the sidecar level for every request.
Alternatively, we can use a service mesh that provides these features out of the box.
Given the complexity and the fact that we are already using Kubernetes, Istio might be a good choice.
With Istio, we can:
- Automatically inject sidecar proxies.
- Define Authorization Policies to control who can access the service.
- Define Request Authentication to verify JWT tokens, etc.
- Use Mutual TLS for service-to-service communication.
So, if we use Istio, we can:
- Enable mutual TLS for the entire mesh (or per namespace) to encrypt and authenticate service-to-service communication.
- Define an AuthorizationPolicy for the model service that only allows requests from specific services (by service account or by name) and on specific paths.
Example Istio AuthorizationPolicy:
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: allow-only-specific-services
namespace: default
spec:
selector:
matchLabels:
app: my-model
action: ALLOW
rules:
- from:
- source:
principals: ["cluster.local/ns/default/sa/allowed-app-account"]
to:
- operation:
methods: ["POST", "GET"]
paths: ["/v1/models/my_model:predict"]
This would only allow requests from the service with service account allowed-app-account and only on the predict endpoint.
-
Logging and Monitoring:
- Ensure that all access to the model is logged (via Envoy/Istio access logs).
- Use a centralized logging system (like ELK or Loki) to collect logs.
- Set up alerts for suspicious activities.
-
Secret Management:
- Do not store secrets in the container. Use Kubernetes Secrets or an external vault (like HashiCorp Vault) and mount them as volumes or use environment variables (with caution).
- Ensure that the model container does not run as root and has minimal privileges.
-
Continuous Monitoring:
- Use tools like Falco to monitor runtime behavior (syscalls, file access, etc.) and detect anomalies.
Summary:
We have:
- Container isolation via Kubernetes and container runtime settings.
- Model attestation via image signing and admission controller.
- Runtime policy enforcement via Istio (or Envoy sidecar) for network and request-level policies.
- Resource limits via Kubernetes.
- Additional security via Pod Security Standards.
This is a high-level design. Each component requires detailed configuration and testing.
Note: The admission controller for image attestation is non-trivial and might require custom development or use of a specialized tool (like Kyverno with image verification plugins, or OPA with custom rego that calls an external verifier).
Given the complexity, we might choose to implement the image attestation in the CI/CD pipeline and only allow images from a trusted registry, and then in the admission controller we just check the registry and the image tag (or hash) against a list.
However, for zero-trust, we want to verify the signature at runtime (admission time). So we need an admission controller that can verify the image signature.
Since this is a complex task, we might consider using a tool like cosign and write a small webhook that:
- On pod creation, for each container, get the image reference.
- Use
cosign verify to check the signature and then check the hash against a known good hash.
But note: the image might be pulled from a registry that requires authentication. We must handle that in the webhook.
Alternatively, we can use the ImagePolicyWebhook (k8s) that can be configured to check image signatures and hashes.
However, the built-in ImagePolicyWebhook in Kubernetes is for the image policy plugin (which is only for the kubelet) and not for the API server admission.
So we need an admission controller that runs at the API server level.
Given the time, we might decide to use a simpler approach:
-
Only allow images from a trusted registry and with a specific tag that we know is signed and verified in our CI/CD.
-
In the admission controller, we check the image name and tag against an allowlist.
-
We rely on our CI/CD to have verified the image and signed it.
But this is not zero-trust because if an attacker can push to the trusted registry, then we are compromised.
So we must verify the signature in the admission controller.
Given the complexity, we might use a third-party solution like Notary (which is being deprecated) or Cosign with an admission controller that supports it.
There is an example of using Cosign with Kubernetes admission:
https://github.com/sigstore/cosign/blob/main/examples/kubernetes-admission-controller/README.md
But note: this is an example and might not be production ready.
Alternatively, we can use the cosign command in the admission controller and check the signature and then the hash.
Steps in the admission controller:
- Receive the pod creation request.
- For each container, get the image name and the expected hash (if we are using hash allowlist) or just the image name.
- Use
cosign verify to verify the signature of the image. This requires that the image is signed with a key we trust.
- If the signature is valid, then we can get the digest of the image from the registry and compare it to the expected hash (if we have one) or just allow it if the signature is from a trusted key.
However, note that the image might be referred to by tag or by digest. We should always use the digest for verification because tags can move.
So, in our deployment, we should use the image by digest (e.g., myregistry.com/my_model@sha256:...).
But if we use a tag, then the admission controller must resolve the tag to a digest and then verify that digest.
So, the steps:
-
The pod spec has an image: myregistry.com/my_model:latest or myregistry.com/my_model@sha256:....
-
If it's by tag, we need to query the registry to get the digest for that tag and then verify that the image with that digest is signed and matches the expected hash (if any).
-
If it's by digest, we can directly verify.
This is complex and requires the admission controller to have network access to the registry and to be able to resolve tags.
Given the complexity, we might decide:
-
In our CI/CD, after building and signing the image, we record the digest and use that digest in the Kubernetes manifest.
-
Then in the admission controller, we only need to verify the signature and that the digest matches the one in the manifest (which we can get from the image field).
-
But note: the image field might have a tag. So we must enforce that the image field is by digest? Or we can convert the tag to digest in the admission controller and then compare.
-
Alternatively, we can have an allowlist of (registry, repository, tag) that are allowed and then verify the signature of the image that the tag points to.
Given the time, we might choose to:
-
Only allow images by digest and then verify the signature and that the digest matches the one in the image field.
-
But then if the tag moves, the digest in the manifest won't change, so we are safe.
-
However, if we want to update the model, we must update the manifest with the new digest.
-
This is acceptable for zero-trust because we are pinning the exact image.
So, in practice:
-
Our CI/CD pipeline:
- Build the image.
- Sign the image with
cosign sign --key <key> myregistry.com/my_model:tag
- Get the digest of the image (after pushing) and then update the Kubernetes manifest to use the digest.
-
In the admission controller:
- Check that the image field is in the form
myregistry.com/my_model@sha256:....
- Use
cosign verify to verify the signature of that image (by digest) and that it is signed by a trusted key.
- If valid, allow.
-
Alternatively, we can have a step in the CI/CD that records the digest and then we have an allowlist of digests in the admission controller? But that would require updating the admission controller every time we update the model.
-
So it's better to rely on the signature and the fact that the image is from a trusted registry and signed by a trusted key.
-
We can also have an allowlist of registries and repositories that are trusted.
So, the admission controller logic:
For each container image:
1. Check that the image is from a trusted registry and repository (e.g., myregistry.com/my_org/).
2. Resolve the image to a digest (if it's a tag, we must resolve it; but we are requiring digest so we don't have to?).
3. Verify the signature of the image (by digest) using `cosign` and a trusted public key.
But note: if we require digest in the manifest, then step 2 is not needed.
So we enforce that the image field must be by digest? That might be too restrictive because the user might want to use a tag.
Alternatively, we can allow tags but then we must resolve the tag to a digest and then verify the digest.
Given the complexity, we might decide to only allow digests in the image field for model containers.
But then how do we update? We update the manifest with the new digest.
This is acceptable.
So, we change the Docker image in the manifest to:
image: myregistry.com/my_model@sha256:...
And then in the admission controller, we check:
if the image string does not contain '@sha256:' then reject.
Then we can use cosign verify on that image reference (which is by digest) and it will verify the signature of that exact image.
So, the steps:
- In the pod spec, the image must be by digest.
- The admission controller:
for each container:
if not image contains '@sha256:': reject
else:
run `cosign verify --key <trusted_key.pub> <image>`
if exit code 0: allow
else: reject
We must also consider that the image might be from a private registry. Then cosign verify must have credentials to pull the image? Actually, cosign verify only needs to fetch the manifest and the signature from the registry. It might need credentials if the registry is private.
So the admission controller must have credentials for the trusted registries.
Alternatively, we can use a keyless signing (with Fulcio) but that's another story.
Given the complexity, we might decide to have a private registry that is trusted and that we have credentials for.
So, the admission controller is a webhook that runs in the cluster and has a service account with permissions to read the pod spec.
We must also consider performance: verifying an image signature for every pod creation might be slow.
We can cache the results by image digest? But then we must invalidate the cache when we update the trust store.
Given the time, we design the system but the implementation details might vary.
Conclusion:
We have designed a zero-trust ML deployment with:
- Container isolation via Kubernetes and container runtime security features.
- Model attestation by requiring images to be signed (with Cosign) and by digest, and verifying the signature at admission time.
- Runtime policy enforcement via Istio (or Envoy sidecar) for network and request-level policies.
We also set resource limits and use pod security standards.
The implementation of the admission controller is non-trivial and requires careful design and testing.
We might also consider using a policy engine like OPA with a custom rego that calls an external service (like cosign) to verify the image.
Alternatively, we can use the built-in image policy webhook of the kubelet (but that is only for the kubelet, not for the API server) and then also have an API server admission controller.
Given the complexity, we might start with a simpler approach:
- Only allow images from a trusted registry and by digest, and then in the admission controller we check the image field for the trusted registry and that it is by digest.
- Then we rely on the CI/CD to have verified the image and signed it.
But that is not zero-trust because we are not verifying the signature at admission time.
So we must verify the signature.
Given the time constraints of this exercise, we leave the implementation of the admission controller as a custom webhook that uses cosign to verify the image signature.
Alternatively, we can use an existing solution like Kyverno with a verifyImages policy.
Kyverno supports image verification with Cosign.
So we can use Kyverno as the admission controller and write a policy:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: verify-model-images
spec:
validationFailureAction: Enforce
background: false
rules:
- name: verify-model-image
match:
resources:
kinds:
- Pod
selector:
matchLabels:
app: my-model # or we can match by image pattern?
verifyImages:
- image: "myregistry.com/my_org/*"
key: |-
-----BEGIN PUBLIC KEY-----
... (our public key)
-----END PUBLIC KEY-----
subject: ".*" # or we can specify the subject
annotations:
org.openpolicyagent/policy.regenerate: "true"
But note: Kyverno's verifyImages requires the image to be signed by the provided key and also checks the subject.
And we can also require the image to be by digest? Actually, the image field in verifyImages can be a pattern, but it will match the image field in the pod. If the pod uses a tag, then the verification will be on the image that the tag points to (at the time of policy evaluation). So it resolves the tag to a digest and verifies that.
But note: if the tag moves after the pod is created, then the pod is already running with the old image. So it's safe.
So we can use Kyverno to enforce that the image is signed by our key and is from our registry.
Then we don't have to write a custom admission controller.
So, we can use:
- Kyverno for image attestation (verifying signature and registry).
- Istio for network and request-level policies.
- Kubernetes for resource limits and pod security.
This gives us a zero-trust deployment.
Let's adjust:
Step 1: Build and sign the model image with cosign using our key.
Step 2: In the pod spec, we can use a tag (like :latest) or a digest.
Step 3: Kyverno policy that:
- Matches pods that have an image from our registry (or all pods?).
- Verifies the image signature with our public key.
Step 4: Istio policies for network and request.
Step 5: Resource limits and pod security.
So the final design:
- Build and sign the model image with
cosign.
- Deploy the model as a pod (or deployment) in Kubernetes with resource limits and pod security standards.
- Use Kyverno to verify the image signature at admission time.
- Use Istio (or another service mesh) to enforce network policies and request-level policies.
This is a more practical zero-trust ML deployment.
Note: We must also consider the model file itself. The container image includes the model file. So by verifying the container image, we are verifying the model file.
But what if the model file is mounted from a volume? Then we must attest the model file separately.
For simplicity, we assume the model is inside the container.
If we mount the model from an external volume, then we must:
- Attest the model file (hash and signature) and then have an admission controller that checks the volume content? That is more complex.
So for zero-trust, we package the model inside the container and sign the container.
This design is complete.
Let's write the final steps:
-
Model Containerization and Signing:
-
Create a Dockerfile that includes the model.
-
Build the image and sign it with cosign:
cosign sign --key <private_key> myregistry.com/my_model:tag
-
Push the image.
-
Kubernetes Deployment:
- Create a deployment with resource limits and pod security context (run as non-root, etc.).
-
Kyverno Policy:
- Install Kyverno.
- Create a ClusterPolicy that verifies the image signature for images from our registry.
-
Istio:
- Install Istio.
- Enable mutual TLS (if desired) and create Authorization Policies for the model service.
-
Network Policies (optional, if not using Istio):
- Create Kubernetes NetworkPolicy to restrict traffic to the model pod.
-
Monitoring and Logging:
- Set up Envoy/Istio access logs and forward to a central logging system.
This is a comprehensive zero-trust ML deployment.
Note: The model might be updated frequently. We must have a CI/CD pipeline that builds, signs, and pushes the image and then updates the Kubernetes manifest with the new image (tag or digest). Then Kyverno will verify the new image at rollout.
Also, we must rotate the signing keys periodically and update the Kyverno policy with the new public key.
This design meets the requirements of container isolation, model attestation, and runtime policy enforcement.
Let me know if you need more details on any specific part.
I'll design a comprehensive zero-trust ML deployment architecture that addresses your requirements. This solution integrates multiple security layers while maintaining operational feasibility.
Zero-Trust ML Deployment Architecture
1. Core Design Principles
┌─────────────────────────────────────────────────────┐
│ ZERO-TRUST ML DEPLOYMENT │
├─────────────────────────────────────────────────────┤
│ • Never trust, always verify │
│ • Assume breach, minimize blast radius │
│ • Least privilege access │
│ • Continuous verification & monitoring │
└─────────────────────────────────────────────────────┘
2. Architecture Components
A. Container Isolation Layer
# Multi-tier isolation strategy
Isolation Stack:
├── Hardware Level: Intel SGX/AMD SEV (confidential computing)
├── Hypervisor: Kata Containers/gVisor
├── Runtime: Docker/containerd with strict profiles
├── Process: seccomp-bpf, AppArmor/SELinux
└── Network: eBPF-based micro-segmentation
Implementation:
# Base image with minimal attack surface
FROM gcr.io/distroless/static-debian11 as runtime
COPY --from=builder /app/model-server /model-server
USER nonroot:nonroot
# Drop all capabilities except needed
RUN setcap 'cap_net_bind_service=+ep' /model-server
B. Model Attestation System
Attestation Flow:
1. Build Time:
- Model → SBOM generation (CycloneDX/SPDX)
- Container image signing (cosign/Notary v2)
- Hash chain verification (SHA3-256)
2. Deployment Time:
- Image signature verification
- SBOM vulnerability scanning (Trivy/Grype)
- Integrity measurement (IMA/EVM)
3. Runtime:
- Continuous hash verification
- Telemetry attestation
Cosign Implementation:
# Signing during CI/CD
cosign sign --key cosign.key --output-signature model.sig \
--output-certificate model.crt registry.example.com/model:v1.0
# Verification in admission controller
cosign verify --key cosign.pub registry.example.com/model:v1.0
C. Runtime Policy Enforcement
Policy Stack:
├── Orchestration Level: Kubernetes Admission Controllers
├── Service Mesh: Istio/SPIFFIE with mTLS
├── Runtime Security: Falco/Sysdig rules
├── API Gateway: Envoy with rate limiting/auth
└── Data Security: Homomorphic encryption (optional)
OPA/Gatekeeper Policy Example:
# container_isolation.rego
package kubernetes.admission
deny[msg] {
input.request.kind.kind == "Pod"
container := input.request.object.spec.containers[_]
not secure_container(container)
msg := sprintf("Container %v fails security requirements", [container.name])
}
secure_container(container) {
container.securityContext.runAsNonRoot == true
container.securityContext.readOnlyRootFilesystem == true
container.securityContext.capabilities.drop == ["ALL"]
container.resources.limits.memory == "512Mi"
}
3. Full Implementation Blueprint
Phase 1: Secure Build Pipeline
# GitHub Actions/GitLab CI Example
stages:
- scan
- sign
- attest
scan:
- trivy image --format json --output sbom.json
- syft packages:latest -o cyclonedx > sbom.xml
sign:
- cosign sign --key $COSIGN_KEY --bundle model.bundle
attest:
- attest --type https://slsa.dev/provenance/v0.2 \
--predicate <(slsa-provenance ...)
Phase 2: Admission Control
# Custom admission controller
class MLAdmissionController:
def validate_pod(self, pod):
# 1. Verify image signature
if not self.verify_signature(pod.spec.containers):
return False
# 2. Check SBOM vulnerabilities
if self.has_critical_vulns(pod.spec.containers):
return False
# 3. Enforce resource limits
if not self.check_limits(pod.spec.containers):
return False
# 4. Verify network policies
if not self.network_policy_exists(pod.metadata.labels):
return False
return True
Phase 3: Runtime Enforcement
# Istio AuthorizationPolicy for ML service
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: ml-model-policy
spec:
selector:
matchLabels:
app: ml-inference
action: ALLOW
rules:
- from:
- source:
principals: ["cluster.local/ns/ml-ingress/sa/ingress-account"]
to:
- operation:
methods: ["POST"]
paths: ["/v1/models/*:predict"]
when:
- key: request.auth.claims[iss]
values: ["https://auth.example.com"]
- key: request.auth.claims[scope]
values: ["ml:inference"]
- from:
- source:
namespaces: ["monitoring"]
to:
- operation:
methods: ["GET"]
paths: ["/metrics"]
4. Monitoring & Auditing
Telemetry Stack
┌──────────────┐
│ eBPF Probe │
│ (Falco/Beser)│
└──────┬───────┘
│ syscalls, network
┌──────▼───────┐
│ Envoy Proxy │◄─── mTLS logs
└──────┬───────┘
│ access logs
┌──────▼───────┐
│ OPA/OPA │◄─── policy decisions
└──────┬───────┘
│ audit events
┌──────▼───────┐
│ Elastic │
│ Stack │
└──────────────┘
Falco Rules for ML Runtime:
rules:
- rule: Unexpected Model File Access
condition: >
spawned_process and
proc.name in (python, java, dotnet) and
fd.name startswith "/models/" and
not proc.name in (model-server, preloader)
output: "Unexpected access to model files"
priority: CRITICAL
- rule: Container Breakout Attempt
condition: >
spawned_process and
proc.name in (nsenter, setns, pivot_root) and
container.id exists
output: "Potential container breakout"
priority: HIGH
5. Secrets Management
# Using Vault with Kubernetes
apiVersion: v1
kind: ServiceAccount
metadata:
name: ml-model-sa
annotations:
vault.hashicorp.com/role: "ml-inference-role"
vault.hashicorp.com/secret-volume-path: "secrets"
# Vault Agent sidecar
containers:
- name: vault-agent
image: vault:1.13
command: ["vault", "agent", "-config=/config/vault-config.hcl"]
volumeMounts:
- name: vault-secrets
mountPath: /secrets
6. Complete Deployment Manifest
# ml-deployment-zero-trust.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: bert-sentiment-analysis
labels:
app: ml-inference
security: zero-trust
spec:
replicas: 3
selector:
matchLabels:
app: ml-inference
model: bert-sentiment
template:
metadata:
labels:
app: ml-inference
model: bert-sentiment
annotations:
# Kyverno policy to enforce attestation
policies.kyverno.io/attestation: "required"
spec:
serviceAccountName: ml-model-sa
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
containers:
- name: inference-server
image: registry.example.com/ml/bert-sentiment@sha256:a1b2c3... # pinned digest
imagePullPolicy: IfNotPresent
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
add: ["NET_BIND_SERVICE"]
env:
- name: MODEL_PATH
valueFrom:
secretKeyRef:
name: model-config
key: model-path
ports:
- containerPort: 8080
name: http
resources:
limits:
memory: "1Gi"
cpu: "1000m"
nvidia.com/gpu: 1
requests:
memory: "512Mi"
cpu: "500m"
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
volumeMounts:
- name: tmpfs
mountPath: /tmp
emptyDir: {}
volumes:
- name: tmpfs
emptyDir:
medium: Memory
# Sidecar for additional enforcement
- name: envoy-sidecar
image: envoyproxy/envoy:v1.28
# ... Envoy configuration
7. Policy Decision Points
Request Flow:
Client → Ingress (mTLS+JWT validation) →
Sidecar (eBPF filtering) →
Service Mesh (Istio authz) →
OPA (custom policies) →
Model Container
8. Verification Commands
# 1. Verify image signature
cosign verify --key cosign.pub registry.example.com/model:v1.0
# 2. Check SBOM for vulnerabilities
trivy sbom:sbom.json --format json
# 3. Test network policies
kubectl exec -it test-pod -- curl -s -o /dev/null -w "%{http_code}" \
http://model-service:8080/predict
# 4. Audit with OpenSCAP
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_stig \
--results results.xml --report report.html \
/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
9. Key Security Controls Summary
| Control | Implementation | Verification |
|---|
| Isolation | Kata Containers + gVisor | kubectl describe pod |
| Attestation | cosign + Sigstore | cosign verify |
| Network | Cilium + Istio | cilium connectivity test |
| Runtime | Falco + OPA | Falco rules test |
| Secrets | Vault + K8s secrets | vault read audit |
| Audit | OpenTelemetry + Elastic | SIEM correlation |
10. Disaster Recovery Plan
# Emergency isolation policy
apiVersion: policy.sigstore.dev/v1beta1
kind: ClusterImagePolicy
metadata:
name: emergency-quarantine
spec:
images:
- glob: "registry.example.com/ml/*"
authorities:
- name: quarantine
key:
data: |
# Emergency public key for quarantine
Rollback Procedure:
- Quarantine compromised deployment via ClusterImagePolicy
- Rotate signing keys immediately
- Re-deploy from last verified SBOM
- Forensic analysis of attestation logs
- Update admission policies based on findings
Deployment Checklist
Pre-Deployment:
Deployment Time:
Runtime:
Trade-offs & Considerations
- Performance Impact: ~5-15% latency overhead from security layers
- Complexity: Increased operational overhead (monitoring, key rotation)
- Cost: Additional compute for sidecars/enforcers
- Vendor Lock-in: Heavy reliance on Sigstore/Istio ecosystem
Recommended Toolchain:
- Orchestration: Kubernetes 1.28+
- Security: Sigstore + Falco + OPA
- Service Mesh: Istio 1.20+ or Cilium
- Secrets: HashiCorp Vault
- CI/CD: GitLab CI with Cosign integration
- Monitoring: OpenTelemetry → Elasticsearch → Grafana
This architecture provides defense-in-depth while maintaining the ability to deploy and update ML models securely. The zero-trust model ensures that every component authenticates, authorizes, and is continuously validated throughout the ML lifecycle.