Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Advanced / Securing AI infrastructure

Securing AI infrastructure cheat sheet

Set up the lab (lesson 0)

TaskCommand or code
Make the environment and switch it onpython3 -m venv .venv, source .venv/bin/activate
Install the pinned librariespip install -r requirements.txt
Train a model as plain JSONpython train.py v1
Check the labpython labcheck.py
Find what uses a portss -ltnp

Draw the architecture (lesson 1)

TaskCommand or code
Check the architecture filepython arch_check.py architecture.json
Show each connection and whether it crosses a boundarypython arch_check.py architecture.json --table
Read the exit code of the last commandecho "exit code $?"
Replace text on each linesed 's/old/new/' file > copy

Serve a model (lesson 2)

TaskCommand or code
Run the table of good and bad requestspython test_service.py
Start the service in the backgroundKR_GATEWAY_TOKEN=... python service.py 8421 &, echo $! > service.pid
Send a request with a header and a bodycurl -s -w ' %{http_code}\n' -X POST -H 'Header: value' -d '{...}' URL
Stop itkill $(cat service.pid)
Compare the hash of the model filehashlib.sha256(text.encode()).hexdigest()

Gateway (lesson 3)

TaskCommand or code
Make a key for a clientpython keystore.py add alpha predict
Send a key-H "Authorization: Bearer $KEY"
Run the gateway testspython test_gateway.py
Print only the status codes of many callscurl -s -o /dev/null -w '%{http_code} '
See the headers of an answercurl -s -i URL
Read the audit loghead -2 audit.log

Keys and secrets (lesson 4)

TaskCommand or code
Rotate a key with an overlap (0 after a leak)python rotate.py alpha --overlap 7
Scan a folder for keys and open secret filespython scan_secrets.py folder
Make a file that only you can readchmod 600 secrets/alpha.key
Make new files private (in a subshell)( umask 077; command )
Show the environment of a processtr '\0' '\n' < /proc/PID/environ (a secret in use is in clear; the file is mode 400)

Isolation (lesson 5)

TaskCommand or code
Set limits for a program( ulimit -n 64 -v 2097152 -f 10240; exec python service.py )
Make a file read-only, a folder privatechmod 444 file, chmod 700 folder
Audit a running processpython audit_isolation.py PID MODEL WORK SECRETS
Audit written settingspython audit_isolation.py --settings settings.json
Run in a sandbox with no network (optional)bwrap --ro-bind / / --dev /dev --proc /proc --bind "$PWD/work" "$PWD/work" --unshare-all python probe.py
Run as a separate user (needs administrator rights)sudo --preserve-env=KR_GATEWAY_TOKEN -u krmodel python3 service.py

Release (lesson 6)

TaskCommand or code
Run the gates and promotepython release.py v2
Judge a recorded resultpython release.py check results.json
Go back one versionpython release.py rollback
Train a version with a lost columnpython train.py v2 1 failed
Swap a file in one stepos.replace(temp, path)

Drift (lesson 7)

TaskCommand or code
Make the fixed samplespython make_samples.py
Compare a live sample with the referencepython drift.py samples/reference.json samples/live-b.json
Save the report--out report.json --today 2026-11-21
Choose an actiondrift.advise(status, promoted_recently, accuracy_fell)

Cost and capacity (lesson 8)

TaskCommand or code
Start the gateway with extra stagesKR_EXTRA=budget python gateway.py
Estimate capacitycapacity.capacity(service_ms, workers, 0.7)
Replay a burst through a queuecapacity.replay(arrivals_ms, service_ms, workers, queue_max)
Send many calls at onceseq 60 | xargs -P 30 -I{} curl ...

Policy (lesson 9)

TaskCommand or code
Report the decisions on a table of requestspython policy.py policy.json policy-cases.json
Enforce policy and budget in the gatewayKR_EXTRA=policy,budget python gateway.py
Send a data class-H "X-Data-Class: internal"
Protect data in useA TEE with attestation (confidential computing), homomorphic encryption, or secure multi-party computation: ask for one when secret data runs on a host that someone else operates

Readiness (lesson 10)

TaskCommand or code
Check a systempython readiness.py --root DIR --today 2026-11-30
Read the verdictreadiness: 10 of 10 pass, exit code 0

Safety habits