Zero trust drops the idea that being inside the network makes you trustworthy. Every request, from a person or a workload, is authenticated, authorised for that specific resource, and evaluated in context (who, from which device, how risky, for what), every time, with the least access that does the job. NIST SP 800-207 describes it as policy decision and enforcement points in front of every resource. This lesson follows one engineer and one service reaching a production database, and shows the two failures zero trust exists to stop: a VPN that let a stolen laptop reach everything, and a flat network where one compromised service could talk to all the others.
Difficulty: Master · Know this first: Lesson 162, Lesson 152
By the end of this lesson you can work at four levels:
This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.
This bar adds up minutes from an access request to access, including approval. It is a worked example, not a measurement. The policy decision and service-to-service hops are where implicit trust does its damage.
Pick how people get remote access, how services trust each other, and how admin rights are held. The readouts show what one stolen laptop or one compromised service can reach.
Three questions. No score is saved anywhere — this is just you against the material.
Zero trust grows in four levels: reading access decisions, removing implicit trust for people, then for workloads, and running it as a programme.
At the basic level you can explain why a request was allowed or denied.
Where it breaks: "it is on the internal network, so it is fine".
Try it: Basic
An admin console allows any request from an internal IP. Is that zero trust?
Now do it: Find one internal service that trusts by IP.
At the intermediate level people reach applications, not networks.
Try it: Intermediate
Which MFA resists phishing?
Now do it: Register a passkey for your work account.
At the advanced level services trust identities and policies, not networks.
Try it: Advanced
How do you roll out default-deny authorization in a busy mesh without an outage?
Now do it: Export one namespace's call graph.
At the master level zero trust is a measured programme across people, devices, workloads, networks, and data.
Trade-off: more checks add friction and dependencies (the IdP, the proxy, the mesh) that need their own reliability and break-glass paths.
Try it: Master
The identity provider is down. What keeps critical operations possible?
Now do it: Review your break-glass procedure.
Default-deny with one allowed call path in Istio: only the checkout service account may call payments' charge endpoint. Run new policies in a test namespace first (and check the Istio version's API).
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: {name: default, namespace: payments}
spec: {mtls: {mode: STRICT}} # only mTLS traffic is accepted
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: {name: allow-nothing, namespace: payments}
spec: {} # an empty policy in a namespace denies everything
---
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata: {name: checkout-can-charge, namespace: payments}
spec:
selector: {matchLabels: {app: payments-api}}
action: ALLOW
rules:
- from: [{source: {principals: ["cluster.local/ns/checkout/sa/checkout"]}}]
to: [{operation: {methods: ["POST"], paths: ["/charge"]}}]
The building blocks on each cloud:
This is a composite of a failure pattern that keeps repeating; the details are illustrative. The laptop that was trusted for where it connected.
Remote access moved to an identity-aware proxy with device checks and passkeys, admin consoles require their own authentication and just-in-time roles, database access uses identity-mapped roles, and the VPN remains only for a few legacy systems behind the proxy.
Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.
Before you start: Linux with OpenSSL (installed on most distributions) and Python 3. Everything runs on your machine.
Type each one, read what it prints, and compare it with the note above it.
Make a tiny certificate authority and certificates for two services, the way a mesh does for every workload.
mkdir -p ~/labs/zt && cd ~/labs/zt openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout ca.key -out ca.crt -days 1 -subj "/CN=lab-ca" 2>/dev/null for svc in payments checkout; do openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout $svc.key -out $svc.csr -subj "/CN=$svc" 2>/dev/null openssl x509 -req -in $svc.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out $svc.crt -days 1 2>/dev/null done ls *.crt
Start payments as a server that requires a client certificate from the lab CA.
openssl s_server -accept 8443 -cert payments.crt -key payments.key -CAfile ca.crt -Verify 1 -www >server.log 2>&1 & sleep 1
Call it without a certificate (refused), then as checkout (accepted).
echo | openssl s_client -connect localhost:8443 -CAfile ca.crt 2>&1 | grep -E "alert|Verify return code" | head -2 echo "GET / HTTP/1.0 " | openssl s_client -connect localhost:8443 -CAfile ca.crt -cert checkout.crt -key checkout.key -quiet 2>/dev/null | grep -m1 "Client certificate" kill %1
pdp.pyThis program is a small policy decision point. It decides people's requests on identity, MFA strength, device posture, and an approved just-in-time grant, never on network location, and decides service calls on the caller's workload identity against default-deny allow rules. The same requests are also judged the old way, by network location, for comparison. Save it as pdp.py, then run it.
# pdp.py
GRANTS = {("asha", "orders-db:read"): "until 15:00"} # just-in-time, approved
SERVICE_ALLOW = {("spiffe://prod/ns/checkout/sa/checkout", "payments", "POST /charge")}
def decide_user(user, mfa, device_ok, resource, from_internal_ip):
old = "ALLOW" if from_internal_ip else "DENY"
if mfa != "passkey":
new = "DENY: phishing-resistant MFA required"
elif not device_ok:
new = "DENY: device not compliant"
elif (user, resource) not in GRANTS:
new = "DENY: no just-in-time grant"
else:
new = f"ALLOW {GRANTS[(user, resource)]}"
return old, new
def decide_service(caller, service, call, same_cluster):
old = "ALLOW" if same_cluster else "DENY"
new = "ALLOW" if (caller, service, call) in SERVICE_ALLOW else "DENY: no policy allows it"
return old, new
people = [
("asha, on call, managed laptop", "asha", "passkey", True, "orders-db:read", False),
("stolen laptop on the VPN", "ravi", "push", True, "orders-db:read", True),
("asha, personal tablet", "asha", "passkey", False, "orders-db:read", False),
]
print(f"{'request':<38} {'by network location':<22} zero trust")
for label, *args in people:
old, new = decide_user(*args)
print(f"{label:<38} {old:<22} {new}")
services = [
("checkout -> payments POST /charge", "spiffe://prod/ns/checkout/sa/checkout", "payments", "POST /charge"),
("image-resize -> payments POST /charge", "spiffe://prod/ns/media/sa/image-resize", "payments", "POST /charge"),
("image-resize -> users GET /sessions", "spiffe://prod/ns/media/sa/image-resize", "users", "GET /sessions"),
]
for label, caller, service, call in services:
old, new = decide_service(caller, service, call, True)
print(f"{label:<38} {old:<22} {new}")
Run it, and you should see this output:
$ python3 pdp.py request by network location zero trust asha, on call, managed laptop DENY ALLOW until 15:00 stolen laptop on the VPN ALLOW DENY: phishing-resistant MFA required asha, personal tablet DENY DENY: device not compliant checkout -> payments POST /charge ALLOW ALLOW image-resize -> payments POST /charge ALLOW DENY: no policy allows it image-resize -> users GET /sessions ALLOW DENY: no policy allows it
The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/zero-trust-cloud-architecture && cd ~/labs/zero-trust-cloud-architecture) and save this as lab.sh.
#!/usr/bin/env bash
# The Linux steps of "Zero-Trust Cloud Architecture: Identity, Device, and Every Request Verified", as one script (save it as lab.sh).
#
# ./lab.sh run every step, in order
# ./lab.sh 2 4 run only steps 2 and 4
# ./lab.sh --list list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.
STEPS=(
'Make a tiny certificate authority and certificates for two services, the way a mesh does for every workload.'
'Start payments as a server that requires a client certificate from the lab CA.'
'Call it without a certificate (refused), then as checkout (accepted).'
)
step_1() {
mkdir -p ~/labs/zt && cd ~/labs/zt
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout ca.key -out ca.crt -days 1 -subj "/CN=lab-ca" 2>/dev/null
for svc in payments checkout; do
openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout $svc.key -out $svc.csr -subj "/CN=$svc" 2>/dev/null
openssl x509 -req -in $svc.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out $svc.crt -days 1 2>/dev/null
done
ls *.crt
}
step_2() {
openssl s_server -accept 8443 -cert payments.crt -key payments.key -CAfile ca.crt -Verify 1 -www >server.log 2>&1 &
sleep 1
}
step_3() {
echo | openssl s_client -connect localhost:8443 -CAfile ca.crt 2>&1 | grep -E "alert|Verify return code" | head -2
echo "GET / HTTP/1.0
" | openssl s_client -connect localhost:8443 -CAfile ca.crt -cert checkout.crt -key checkout.key -quiet 2>/dev/null | grep -m1 "Client certificate"
kill %1
}
# print a step that has to be run by hand, instead of running it
by_hand() {
echo " (run this one yourself: $1)"
sed 's/^/ /'
}
RESULTS=()
run_step() {
local n=$1 start=$SECONDS code
printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
"step_$n"
code=$?
RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}
summary() {
echo
echo "== summary"
local r
for r in "${RESULTS[@]}"; do echo " $r"; done
}
case "${1:-}" in
-h|--help) sed -n '2,6p' "$0"; exit 0 ;;
--list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac
[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
echo "there is no step '$n'; try --list" >&2
exit 2
fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done
Then make it executable and run it:
chmod +x lab.sh ./lab.sh --list # the steps ./lab.sh # every step, then a summary of exit codes and times ./lab.sh 2 3 # only steps 2 and 3
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
grep, head, kill, mkdir, echo, ls, cd, Pipes, Redirection, Loops, If...Else, Variables.A company runs 120 services on Kubernetes in two clouds, with a VPN for all staff access and shared database passwords. Design its move to zero trust.
How do people reach applications and infrastructure? How are devices checked? How do services authenticate and authorise each other? How do services and people reach data? What is monitored, and how fast can access be revoked? In what order, without breaking production?
Say 1,500 staff, 120 services, 2 clouds, 30 databases, 40 people with admin rights today, and 6 months.
Passkeys for all staff and device compliance from the MDM; an identity-aware proxy (or the clouds' equivalents) for internal apps and Teleport-style access for infrastructure, with just-in-time admin approved and recorded; SPIFFE identities through the mesh in both clouds, strict mTLS, and default-deny authorization rolled out namespace by namespace from observed call graphs; workload identity to databases and cloud APIs, shared passwords removed; default-deny network policies as backstop; sign-in risk, new call paths, and data volume alerts; the VPN kept only for legacy systems; progress tracked against the CISA maturity model.
More checks add friction and new critical dependencies (IdP, proxy, mesh) that need their own SLOs and break-glass; default-deny can break undocumented calls, so observe first; device checks exclude personal devices from sensitive apps by design.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| VPN = trusted | Hop 3: Policy decision | Breaks | Access is a VPN: a valid VPN login puts the device on the internal network, and internal systems trust internal addresses. A laptop is stolen from a car with the VPN credentials saved. |
| Flat service network | Hop 6: Service to service | Breaks | mTLS is on in permissive mode and no authorization policies exist, so any pod may call any service. An image-resize service with a vulnerable library is compromised through an uploaded file. |
Review the design in this lesson, or your own, against these ten areas. Tick an area when you can answer its question with evidence: a number, a test, a document, or an owner. Your ticks stay in this browser.
The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.
Last updated . Next review due by November 2027. Found something out of date? Tell me.