Deployed Lab

Module 6 · Security, governance and the capstone · Chapter 21 · Free

Security for AI infrastructure: keys, tenants and platform guardrails

20 min1 clickable picture1 break-it lab1 predict, 2 quick quizzes, 5-question final quiz5-min video review
In 30 seconds

The picture: the platform is a building with locked doors per floor, not one master key and a sign asking visitors to behave.

What this chapter gives you
The cold open

Copperline is a made up B2B SaaS company. On a Tuesday, Priya Nair, its staff platform engineer, got two alerts in one hour. All figures here are illustrative.

Nothing clever had been hacked. The platform had never drawn its boundaries.

The plan for this chapter
  1. Scope: the platform layer, and what the app layer already covers.
  2. Keys and secrets: store, lifetime, rotation, one per workload.
  3. Tenant isolation in retrieval, enforced and tested.
  4. Egress control: pods call only what the allowlist permits.
  5. Gateway guardrails and audit, in one place each.
  6. The picture, a blast radius example, and the break-it lab.

Next: where this chapter starts, and where it deliberately stops.

Step 1: The platform layer, not the prompt layer

AI security has two layers. The model layer covers prompt injection and app guardrails. The AI engineering course covers that in Chapter 19, Guardrails and security; this chapter does not repeat it.

This chapter is the platform layer: keys, networks, indexes and gateways. Priya's rule is simple.

Think of a bank vault versus a polite note on the door. Where the picture breaks down:

Next: the keys, where they live and how long they live.

Step 2: Keys and secrets, one per workload

Your platform holds powerful credentials: provider keys, vector database keys, tool credentials. Treat each like a production database password.

Why? Blast radius. If the agents' key leaks, Priya revokes that one. The copilot keeps answering. With a shared key, every leak is a full platform incident.

Next: keeping one customer's documents out of another customer's answers.

Step 3: Tenant isolation, enforced and tested

The rule is absolute: one customer's documents must never surface in another's retrieval, answer or citation.

Then test like an attacker. Priya's canary check seeds a unique marker per tenant, queries as tenant A, and fails the deploy if tenant B's marker appears. Chapter 13 covers index mechanics; this chapter owns the boundary.

Think of filing cabinets with separate locks versus one cabinet and a promise. Where the picture breaks down:

Next: what your pods are allowed to call out to.

Step 4: Egress control, an allowlist for pods

By default, a pod can often call any internet address. That is a hole: a steered agent or compromised dependency can send your data to an attacker's endpoint, or pull instructions from one.

Think of an office phone that dials only listed numbers. Where the picture breaks down:

Predict first:

Almost every platform has one forgotten call: a metrics export, a licence check. Default deny surfaces it in the denial log within the hour. Roll it out with the log open, not during an incident.

Next: one enforcement point for tools, limits and checks.

Step 5: Gateway guardrails and the audit trail

Chapter 15, Agent runtimes in production, put a tool gateway between agents and tools. It is also your security checkpoint, since every call passes through it.

Enforcement without records is half a control. Chapter 17, Observability for AI services, sets the pattern: who called what, with which key, for which tenant. After the leak, that log answered the key question: what did the leaked key do? Chapter 23 builds the full audit trail on it.

Next: the picture, one request crossing every boundary.

Step 6: The picture, a request crossing the boundaries

Press Next to walk a copilot request past each control.

Platform security boundaries A request passes the gateway, runs in a serving pod with a fetched key, reads only its tenant index, and can call out only to allowlisted endpoints. Tenant usertenant A session Tool gatewaylists and limits Serving podcopilot workload Secrets storeshort lived key Tenant A indexonly A documents Allowed APIsallowlist only
  1. A tenant A user asks the copilot a question. Their identity, not their text, sets the tenant.
  2. The gateway applies the tool allowlist, the tenant quota and content checks before anything runs.
  3. The serving pod gets its own short lived key from the secrets store at runtime. No key sits in the image.
  4. Retrieval reads only the tenant A index, so tenant B documents cannot surface.
  5. The pod may call only allowlisted APIs. Any other outbound call is denied and logged.

Next: the worked example, what one leak costs under two key designs.

Step 7: Worked example, the blast radius of one leaked key

The provider key leaks at 09:00. All figures are illustrative. Compare the two designs Priya costed after the incident.

1. Shared key, step one. Revoke it. All 3 workloads stop calling the provider at once.

2. Shared key, recovery. Issue a new key, update and verify 3 deployments. At an illustrative 25 minutes each: 3 x 25 = 75 minutes degraded.

3. Shared key, the audit gap. Logs show one key, so the team cannot tell which workload's traffic was the attacker's. Review work triples.

4. One key per workload. The agents' key leaks. Revoke only it: 1 x 25 = 25 minutes, agents only. Copilot and pipeline never stop, and the log names the workload.

5. The lesson. Same leak. Per workload keys cut recovery from 75 to 25 illustrative minutes and kept 2 of 3 workloads up.

Next: the break-it lab, where you fix the setup that caused the cold open.

Step 8: Break-it lab, debug Copperline's platform setup

Why this exercise: the cold open was not bad luck. Four flaws caused it, each visible below if you read like an auditor.

Lab: This is the setup that caused the chapter's cold open, widened to the whole platform. This lab runs in your browser and needs JavaScript enabled.

Next: a field note and the mix-ups.

Field note, November 2026

In production practice, automated scanners commonly find leaked keys in public repos or images, so teams treat any exposure as a live compromise: rotate first, investigate second. Cross tenant leaks are worse for trust than a short outage. Test isolation in CI, not after a report.

Mix-ups to avoid

Chapter quiz

Five questions, 70% to pass.

Review this chapter in 5 minutes

Watch the whole chapter recapped: Keys in a secrets store, tenant isolation tested, egress allowlists, and gateway guardrails.

Decision rule: if a rule matters, enforce it in the platform, outside the model, and prove it with a test or a log.

Review

Glossary

Secrets store
Service holding credentials, handed to workloads at runtime. Example: the copilot fetching its key at startup.
Blast radius
How much breaks when one thing leaks. Example: one shared key, three workloads down.
Rotation
Replacing a credential on schedule or after exposure. Example: a fresh key issued, the old one revoked.
Tenant isolation
One customer's data never reaches another. Example: tenant A retrieval cannot return tenant B documents.
Canary test
A planted marker that detects leaks. Example: a unique document per tenant.
Egress
Outbound traffic from a workload. Example: a pod calling the provider endpoint.
Allowlist
Permitted targets; all else denied. Example: only the provider and two tool APIs.
Tool gateway
Checkpoint between agents and tools. Example: it rejects an off list tool call.
Per tenant quota
A cap on one tenant's calls or spend. Example: one tenant cannot drain the platform.
Audit log
Record of who called what, with which key. Example: tracing a leaked key's calls.

Next: "Air-gapped and regulated deployments: offline models and updates".