How to use these
Do them in a throwaway GitHub repo and a local kind cluster unless the assignment says otherwise. Never point scanners that attack (ZAP active scans, fuzzers) at anything you do not own. For each assignment, keep a short NOTES.md with the commands you ran, what the tool reported and what you decided; that file is what turns a lab into an interview story. Hints are collapsed so you can try first.
Most assignments build on the hands-on lab. The cheatsheet has the commands.
๐ข Beginner
Assignment 1. Threat model a three-tier app with STRIDE ๐ข
Objective: Practise the design-time activity that decides which controls the pipeline needs.
Tasks
- Pick a simple system: a React frontend, a Flask API, a PostgreSQL database, an S3 bucket for uploads, deployed on Kubernetes.
- Draw a data-flow diagram as a Mermaid flowchart. Mark every trust boundary (internet to ingress, pod to database, pod to cloud API, CI to cluster).
- For each boundary, list at least one threat per STRIDE category that applies.
- For each threat, write a mitigation and the tool or control that implements it (for example "Tampering of image in registry โ Cosign signing + Kyverno verifyImages").
- Rank the top five threats by likelihood times impact.
Expected outcome: A threat-model.md with a diagram, a table of at least 15 threats with mitigations, and a ranked top five.
Hints
STRIDE: Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, Elevation of privilege. Ask four questions: what are we building, what can go wrong, what are we going to do about it, did we do a good job. Repudiation threats are usually answered by audit logs (CloudTrail, Kubernetes audit log). OWASP Threat Dragon is a free tool if you prefer drawing.
Bonus: Map each mitigation to the SDLC phase where it runs (plan, code, build, test, release, deploy, operate).
Assignment 2. Stop secrets before they leave the laptop ๐ข
Objective: Catch secrets at the cheapest possible point and scan existing history.
Tasks
- Clone any repo you own with real history, and run
gitleaks git -vover it. Record what it finds. - Install gitleaks as a pre-commit hook with the
pre-commitframework. - Try to commit a fake AWS secret access key pattern and a fake GitHub token. Confirm both are blocked.
- Write a
.gitleaks.tomlthat extends the default rules and adds one custom rule for an internal token format, for exampleacme_[a-z0-9]{32}. - Turn on GitHub secret scanning and push protection in the repo settings, then explain in two sentences how it differs from gitleaks.
Expected outcome: The hook blocks commits with secrets, the custom rule fires on a test string, and you have a written finding list for the existing repo.
Hints
.pre-commit-config.yaml with repo: https://github.com/gitleaks/gitleaks, hooks: [{id: gitleaks}], then pre-commit install. A custom rule needs id, regex and ideally keywords so gitleaks only runs the regex on lines containing the keyword. [extend] useDefault = true keeps the built-in rules. Push protection is server-side and validates some token types with the provider; gitleaks is client-side and pattern-based.
Bonus: Run TruffleHog with --only-verified on the same repo and compare: which tool had more false positives, and why?
Assignment 3. Read a Trivy image report like an owner ๐ข
Objective: Understand what an image scanner reports and how base image choice changes it.
Tasks
- Scan
python:3.13,python:3.13-slim,python:3.13-alpineandgcr.io/distroless/python3-debian12withtrivy image --severity HIGH,CRITICAL. - Record total findings and fixable findings (
--ignore-unfixed) for each in a table. - For one finding, explain every column: library, vulnerability, severity, status, installed version, fixed version.
- Explain why the full image has so many more findings than slim, and what you lose with distroless.
Expected outcome: A comparison table and a recommendation for which base you would use for a Python API, with one paragraph of reasoning.
Hints
trivy image --format json plus jq '[.Results[].Vulnerabilities[]?] | length' counts findings. --ignore-unfixed hides CVEs with no fixed version. Distroless has no shell or package manager, which helps security but makes kubectl exec debugging harder; ephemeral debug containers (kubectl debug) solve that.
Bonus: Repeat the scan with Grype and explain any difference in counts (different databases, different matching for OS vs language packages).
Assignment 4. Harden a Dockerfile until the scanners are quiet ๐ข
Objective: Apply container image best practices and prove them with tools.
Tasks
- Start from a naive Dockerfile: single stage,
FROM node:latest,COPY . .,npm install, running as root, no health check. - Run
checkov -f Dockerfileandtrivy config ., and record every failed check. - Rewrite it: multi-stage, pinned base by digest,
npm ci --omit=dev, non-rootUSERwith a UID of 10000 or above,HEALTHCHECK, a.dockerignore. - Re-run both scanners until they pass, and compare image size before and after with
docker images.
Expected outcome: Both scanners pass, the image runs as non-root (docker run --rm img id), and the final image is noticeably smaller.
Hints
Get a digest with docker buildx imagetools inspect node:22-slim. Common checks: CKV_DOCKER_2 (HEALTHCHECK), CKV_DOCKER_3 (USER), CKV_DOCKER_7 (latest tag). The official Node images already contain a node user with UID 1000; Checkov's Kubernetes check for high UIDs is why many teams create their own user at 10001.
Bonus: Add hadolint and fix its findings too. Explain one rule where hadolint and Checkov disagree.
Assignment 5. Semgrep: fix, suppress and write your own rule ๐ข
Objective: Use SAST without drowning in noise.
Tasks
- Clone a deliberately vulnerable app such as OWASP's PyGoat or a Flask app you write with an SQL injection and a
yaml.loadcall. - Run
semgrep scan --config p/python --config p/owasp-top-ten --metrics=off. - Fix two true positives in code.
- Suppress one finding you judge to be a false positive with an inline
nosemgrepcomment that includes the rule ID and a reason. - Write a custom rule in
.semgrep/no-print-secrets.ymlthat flagsprint()orloggingcalls whose argument contains a variable named likepassword,tokenorsecret. Add a test file and runsemgrep --test.
Expected outcome: Fewer findings, one documented suppression, and a custom rule with passing tests.
Hints
A rule needs id, message, severity, languages and a pattern, patterns or pattern-either. Use metavariables with metavariable-regex to match variable names, for example $X where regex: (?i).*(password|token|secret).*. Test files use # ruleid: <id> and # ok: <id> comments above the lines.
Bonus: Run Semgrep with --baseline-commit origin/main so only new findings appear, and explain why that matters for adoption.
Assignment 6. Checkov on Terraform: fix five, skip one ๐ข
Objective: Find and fix infrastructure misconfigurations before terraform apply.
Tasks
- Write Terraform for an S3 bucket, a security group allowing
0.0.0.0/0on port 22, and an RDS instance withpublicly_accessible = trueand no encryption. - Run
checkov -d .and note the check IDs. - Fix at least five findings in code (public access block, encryption, versioning, restricted SSH, private RDS).
- Skip one remaining check inline with
#checkov:skip=<ID>:<reason>and justify it. - Run
trivy config .on the same code and compare findings.
Expected outcome: A clean run except for one documented skip, and a short comparison of Checkov and Trivy config results.
Hints
Useful IDs: CKV_AWS_24 (SSH from 0.0.0.0/0), CKV_AWS_17 (RDS publicly accessible), CKV_AWS_16 (RDS encryption), CKV2_AWS_6 (S3 public access block), CKV_AWS_21 (S3 versioning). The skip comment goes inside the resource block. No AWS account is needed: Checkov scans code, not cloud state.
Bonus: Generate a plan JSON (terraform show -json tfplan > plan.json) and scan that instead. Find a misconfiguration that only appears in the plan because it comes from a variable default.
Assignment 7. SBOMs in two formats ๐ข
Objective: Generate, inspect and reuse SBOMs.
Tasks
- Build any image and generate SBOMs with Syft in SPDX JSON and CycloneDX JSON.
- Use
jqto answer: how many packages, which version of OpenSSL, which licenses appear. - Scan the SBOM file (not the image) with Grype.
- Generate an SBOM for a source directory (
syft dir:.) and compare it with the image SBOM. Explain why they differ.
Expected outcome: Two SBOM files, a NOTES.md with the answers, and a Grype report produced from the SBOM alone.
Hints
syft IMAGE -o spdx-json=sbom.spdx.json -o cyclonedx-json=sbom.cdx.json. SPDX lists packages in .packages[] with versionInfo; CycloneDX uses .components[] with version. grype sbom:./sbom.spdx.json. A source SBOM sees only declared dependencies; an image SBOM also sees OS packages and anything installed at build time.
Bonus: Run trivy image --format cyclonedx and diff the package list with Syft's.
Assignment 8. OWASP Top 10 on OWASP Juice Shop ๐ข
Objective: Turn the OWASP list from vocabulary into things you have seen.
Tasks
- Run Juice Shop locally:
docker run -d -p 3000:3000 bkimminich/juice-shop. - Find and document one example for at least six OWASP Top 10 categories (for example a SQL injection login bypass, an exposed admin page, a weak password reset).
- For each, write which pipeline control could have caught it (SAST, SCA, DAST, IaC, code review, threat modeling) and which could not.
- Run a ZAP baseline scan against it and match ZAP alerts to your categories.
Expected outcome: A table of six or more categories with an exploited example, the detecting control, and the matching ZAP alert where there is one.
Hints
Juice Shop has a built-in score board that lists challenges by category. Broken access control and insecure design are mostly invisible to scanners, which is a good interview point. ZAP baseline: docker run --rm --network host ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t http://localhost:3000.
Bonus: Write which categories changed between the 2017 and 2021 editions and why SSRF got its own entry.
Assignment 9. Automated dependency updates ๐ข
Objective: Make patching continuous instead of a quarterly project.
Tasks
- In a repo with a Dockerfile, a
requirements.txtand a workflow, add.github/dependabot.ymlcoveringpip,dockerandgithub-actions, weekly. - Enable Dependabot alerts and security updates in the repo settings.
- Pin one old vulnerable dependency on purpose and confirm Dependabot opens a security pull request.
- Group minor and patch updates into one weekly pull request per ecosystem.
- Make sure your secure pipeline runs on Dependabot pull requests and explain what permissions those runs have.
Expected outcome: Dependabot opens grouped update pull requests and a security pull request, and the pipeline runs on them.
Hints
version: 2, then updates: entries with package-ecosystem, directory, schedule.interval, and groups: with update-types: ["minor", "patch"]. Workflows triggered by Dependabot get a read-only GITHUB_TOKEN and only Dependabot secrets, which is why signing and pushing should only happen on main.
Bonus: Configure the same thing with Renovate and compare: digest pinning of base images, automerge rules, dashboard issue.
Assignment 10. Pod Security Admission in a namespace ๐ข
Objective: Use the built-in Kubernetes control before reaching for a policy engine.
Tasks
- In kind, create namespaces
psa-baselineandpsa-restrictedwithenforcelabels for each level. - Try to run: a plain
nginxpod, a pod withprivileged: true, a pod withhostNetwork: true, and the hardened deployment from the lab. - Record which pods each namespace accepts and the exact error text for the rejections.
- Make a plain
nginxpod passrestrictedby changing only its spec and image. - Preview what would break if you enforced
baselineon every namespace, without changing anything.
Expected outcome: A table of pod versus namespace with accept or reject, and a restricted-compliant nginx manifest.
Hints
Labels: pod-security.kubernetes.io/enforce=restricted plus optional warn and audit. Restricted needs runAsNonRoot, allowPrivilegeEscalation: false, capabilities.drop: ["ALL"] and seccompProfile.type: RuntimeDefault. nginxinc/nginx-unprivileged listens on 8080 and runs as non-root. Preview: kubectl label --dry-run=server --overwrite ns --all pod-security.kubernetes.io/enforce=baseline.
Bonus: Explain what PSA cannot do that Kyverno or Gatekeeper can (image verification, registry allow-lists, mutation, custom fields).
๐ก Intermediate
Assignment 11. Build and break the full secure pipeline ๐ก
Objective: Complete the hands-on lab and make its results visible to developers.
Tasks
- Build the ten-stage pipeline from the lab in your own repo.
- Break each of stages 1 to 5 and stage 10 on purpose in separate pull requests, and save a screenshot or log excerpt of each failure.
- Make sure gitleaks, Semgrep and Trivy all upload SARIF so findings show under Security, Code scanning.
- Add a job summary (
$GITHUB_STEP_SUMMARY) that prints a one-line count of findings per scanner. - Make the required status checks enforce on
main.
Expected outcome: Six failing pull requests with clear failure reasons, a green main, and findings visible in code scanning.
Hints
Trivy SARIF: format: sarif, output: trivy.sarif, and set exit-code: "0" in a second, reporting-only invocation so the upload still happens when the gate fails. Upload with github/codeql-action/upload-sarif@v3 and a distinct category per tool. Branch protection: gh api -X PUT repos/OWNER/REPO/branches/main/protection.
Bonus: Measure total pipeline time and get the security stages under three minutes with caching and parallel jobs.
Assignment 12. Key-based versus keyless signing ๐ก
Objective: Understand what keyless signing removes and what key-based signing still offers.
Tasks
- Generate a key pair with
cosign generate-key-pair, sign an image by digest with the private key, and verify with the public key. - Sign the same image keylessly from a GitHub Actions workflow and verify with identity and issuer.
- Store the private key in a cloud KMS (AWS KMS, GCP KMS or Azure Key Vault) and sign with the KMS reference.
- Write a table comparing the three: where the trust root is, what an attacker must steal, how rotation works, what is published publicly.
Expected outcome: Three verified signatures on one image (cosign tree shows them) and the comparison table.
Hints
cosign sign --key cosign.key IMAGE@DIGEST, cosign verify --key cosign.pub IMAGE@DIGEST. KMS: cosign generate-key-pair --kms awskms:///alias/cosign-lab, then cosign sign --key awskms:///alias/cosign-lab. Keyless publishes the signer identity to the public Rekor log, which matters for private repositories.
Bonus: Configure Kyverno to accept either the keyless identity or the KMS key, using two attestor entries with count: 1.
Assignment 13. A tested Kyverno policy set ๐ก
Objective: Treat cluster policy like application code: written, tested, rolled out safely.
Tasks
- Write Kyverno policies that: require
runAsNonRoot, require CPU and memory limits, disallow thelatesttag, restrict images toghcr.io/<you>/andregistry.k8s.io/, and add a defaultseccompProfilevia mutation. - Write a
kyverno-test.yamlwith passing and failing resources for each policy and runkyverno test .. - Deploy them in
Auditmode, read the PolicyReports, fix workloads, then switch toEnforce. - Add a
PolicyExceptionfor one workload with a written reason. - Run the tests in CI on every pull request that touches
policies/.
Expected outcome: Five policies, a passing test suite, and evidence of the audit-to-enforce rollout in PolicyReports.
Hints
The test file uses apiVersion: cli.kyverno.io/v1alpha1, kind: Test, with policies, resources and results listing policy, rule, resources and result: pass|fail|skip. kubectl get policyreport -A -o wide shows pass and fail counts. PolicyExceptions must be enabled in the Kyverno Helm values and are namespaced.
Bonus: Write the same five rules as Kubernetes ValidatingAdmissionPolicy objects with CEL and compare readability.
Assignment 14. Rego for Terraform plans with Conftest ๐ก
Objective: Enforce organisation-specific rules that off-the-shelf scanners do not know about.
Tasks
- Write Rego policies that deny: any
aws_s3_bucketwithout aCostCentertag, anyaws_instancetype outside an allowed list, and anyaws_security_group_ruleopening port 22 to0.0.0.0/0. - Run them against
terraform show -jsonoutput withconftest test. - Write unit tests for each rule and run
conftest verify. - Add a CI job that fails the pull request when Conftest denies the plan.
Expected outcome: Three Rego rules with unit tests, failing on a bad plan and passing on a good one.
Hints
Iterate input.resource_changes[], filter on .type and on .change.actions containing create or update, then inspect .change.after. Current Conftest uses OPA 1.x, so write deny contains msg if { ... } (Rego v1 syntax). Tests are rules named test_... that call deny with a mocked input using with input as {...}.
Bonus: Return structured results with a severity field, and only fail CI on high while printing the rest as warnings.
Assignment 15. External Secrets with no static credentials ๐ก
Objective: Sync secrets into Kubernetes using workload identity, not a token in a Secret.
Tasks
- Run Vault (dev mode is fine) and enable the Kubernetes auth method pointing at your kind cluster.
- Create a Vault policy that can read only
secret/data/secure-appand a role bound to thesecure-appservice account in thesecure-appnamespace. - Configure an ESO
SecretStorethat uses Kubernetes auth with that role, and anExternalSecretthat createsapp-secret. - Prove that another service account in the same namespace cannot read the secret through the store.
- Rotate the value in Vault and measure how long until the pod sees it.
Expected outcome: A synced Secret with no Vault token stored anywhere in the cluster, and a failed read from the wrong service account.
Hints
vault auth enable kubernetes, then vault write auth/kubernetes/config kubernetes_host=https://kubernetes.default.svc from inside the cluster. Role: vault write auth/kubernetes/role/secure-app bound_service_account_names=secure-app bound_service_account_namespaces=secure-app policies=secure-app ttl=15m. ESO store: auth.kubernetes.mountPath: kubernetes, role: secure-app, serviceAccountRef.name: secure-app. A mounted Secret volume updates in place; environment variables do not.
Bonus: Do the same against AWS Secrets Manager on EKS with IRSA or EKS Pod Identity.
Assignment 16. Remove static cloud keys from CI ๐ก
Objective: Replace long-lived CI credentials with GitHub OIDC federation.
Tasks
- Create an IAM OIDC identity provider for
token.actions.githubusercontent.comin a sandbox AWS account. - Create a role whose trust policy only allows your repo's
mainbranch, withsts.amazonaws.comas audience. - Use
aws-actions/configure-aws-credentialswithrole-to-assumein a workflow and runaws sts get-caller-identity. - Show that a run from another branch or a pull request is denied.
- Delete any
AWS_ACCESS_KEY_IDsecrets from the repo.
Expected outcome: CI authenticates to AWS with a one-hour session, only from main, with no stored keys.
Hints
The job needs permissions: id-token: write. Trust policy conditions: StringEquals on token.actions.githubusercontent.com:aud = sts.amazonaws.com and on token.actions.githubusercontent.com:sub = repo:OWNER/REPO:ref:refs/heads/main. Using StringLike with repo:OWNER/* is the classic overly broad mistake. Pull request runs have a sub of repo:OWNER/REPO:pull_request.
Bonus: Use GitHub environments and make the sub claim repo:OWNER/REPO:environment:prod, with a required reviewer on that environment.
Assignment 17. Deeper DAST: API scan and authenticated scan ๐ก
Objective: Go beyond the baseline scan safely.
Tasks
- Run a ZAP API scan against Juice Shop or your own app using an OpenAPI definition.
- Configure an authenticated scan: a context with a login, a logged-in indicator and one test user.
- Compare findings from baseline, API and authenticated scans in a table.
- Write a
rules.tsvthat fails the build on high-risk alerts and ignores two documented false positives. - Schedule the full scan nightly against a disposable environment, not on every pull request, and explain why.
Expected outcome: Three reports, a comparison table, and a tuned rules file with justifications.
Hints
zap-api-scan.py -t <openapi-url> -f openapi -r api.html. Authenticated scans are easiest with the ZAP Automation Framework (zap.sh -cmd -autorun plan.yaml) using an authentication block in the context. Use on: schedule with a cron in GitHub Actions for the nightly run.
Bonus: Feed the ZAP JSON report into DefectDojo and deduplicate findings across runs.
Assignment 18. Runtime detection with Falco ๐ก
Objective: Detect what slipped past every static control.
Tasks
- Install Falco with the modern eBPF driver and Falcosidekick in kind.
- Trigger at least three default rules: a shell in a container, reading
/etc/shadow, and writing below/etc. - Write a custom rule that alerts when any process other than
gunicornorpythonstarts in thesecure-appnamespace. - Route alerts to a Slack webhook or the Falcosidekick UI.
- Tune one noisy rule with an exception rather than disabling it.
Expected outcome: Alerts for the triggered events, a working custom rule, and one documented tuning change.
Hints
helm install falco falcosecurity/falco -n falco --create-namespace --set driver.kind=modern_ebpf --set falcosidekick.enabled=true --set falcosidekick.webui.enabled=true. Custom rules go in customRules in the Helm values. Use k8s.ns.name and proc.name in the condition, and spawned_process and container macros. Watch with kubectl -n falco logs -l app.kubernetes.io/name=falco -f.
Bonus: Compare Falco with Tetragon: detection versus in-kernel enforcement, and when you would kill a process instead of alerting.
Assignment 19. Vulnerability triage with exceptions and VEX ๐ก
Objective: Run vulnerability management like an owner, not a ticket generator.
Tasks
- Scan three images you use and export results to JSON.
- Triage every CRITICAL and HIGH: fix now, fix with SLA, or not affected.
- For one not-affected finding, write an OpenVEX document with a justification and show that
trivy image --vexhides it. - For one finding you must accept temporarily, add it to
.trivyignorewith anexp:date and an owner comment. - Produce a one-page summary: counts by severity before and after, decisions, and the next review date.
Expected outcome: A VEX file, an expiring ignore entry, and a triage summary a manager could read.
Hints
vexctl create --product="pkg:oci/..." --vuln="CVE-..." --status="not_affected" --justification="vulnerable_code_not_in_execute_path". Trivy: trivy image --vex openvex.json IMAGE. Typical SLAs: critical 7 days, high 30, medium 90. Reachability (is the vulnerable function called?) is the strongest argument for not affected.
Bonus: Make the pipeline fail when a .trivyignore entry has expired, so exceptions cannot be forgotten.
Assignment 20. Dynamic database credentials with Vault ๐ก
Objective: Replace a shared database password with per-pod, short-lived credentials.
Tasks
- Run PostgreSQL and Vault in kind.
- Enable the database secrets engine and configure a role that creates a user with
SELECTon one schema and a one-hour TTL. - Read credentials twice and show that each read creates a different user in PostgreSQL.
- Revoke a lease and show the user is dropped.
- Deliver the credentials to a pod with the Vault Agent Injector or the Vault CSI provider.
Expected outcome: Pods connect with unique, expiring database users, and revocation is demonstrated.
Hints
vault secrets enable database, vault write database/config/app plugin_name=postgresql-database-plugin connection_url="postgresql://{{username}}:{{password}}@postgres:5432/app?sslmode=disable" allowed_roles=app username=vault password=..., then a role with creation_statements and default_ttl=1h. vault read database/creds/app, vault lease revoke <lease_id>. In PostgreSQL, \du lists the generated users.
Bonus: Rotate the root credential with vault write -f database/rotate-root/app and explain why after this nobody, including you, knows it.
๐ด Advanced
Assignment 21. SLSA provenance verified at admission ๐ด
Objective: Prove not just who built an image, but how, and enforce it in the cluster.
Tasks
- Add build provenance to the lab pipeline with
actions/attest-build-provenance(or the SLSA GitHub generator for containers). - Verify it from your laptop with
gh attestation verify(orslsa-verifier verify-image), pinning the source repo and branch. - Extend the Kyverno
verify-signed-imagespolicy with anattestationsblock that requires provenance and checks a condition on it, such as the source repository or the builder ID. - Show that an image signed by your workflow but missing provenance is rejected.
- Write half a page mapping your setup to SLSA Build levels, stating honestly which level you reach and what is missing for the next.
Expected outcome: Provenance attached to every main image, verified locally and at admission, with a written SLSA assessment.
Hints
attest-build-provenance needs id-token: write and attestations: write, with subject-name, subject-digest and push-to-registry: true. Verify: gh attestation verify oci://IMAGE@DIGEST --repo OWNER/REPO. Check the predicate type your tool emits (https://slsa.dev/provenance/v1 for GitHub attestations) and use it as the type in the Kyverno attestation. Build L3 requires that user-defined build steps cannot influence the provenance, which is why the generator runs in a separate reusable workflow.
Bonus: Also require the SPDX SBOM attestation and deny images whose SBOM contains a package on a deny list.
Assignment 22. Admission policy tests inside CI ๐ด
Objective: Catch broken policies and non-compliant manifests in the pull request, not at deploy time.
Tasks
- Add a job to the lab workflow that creates a kind cluster with
helm/kind-action, installs Kyverno, and applies the policies from the repo. - Deploy the freshly signed image and assert the rollout succeeds.
- Apply
tests/policy/*.yamland assert each is rejected, failing the job if any is admitted. - Run
kyverno applyagainst every manifest ink8s/before the cluster step, as a fast pre-check. - Keep the whole job under five minutes.
Expected outcome: A CI job that fails if a policy stops blocking what it should, or starts blocking a legitimate workload.
Hints
if kubectl apply -f tests/policy/privileged-pod.yaml; then echo "should have been denied"; exit 1; fi. Use helm install ... --wait and kubectl wait --for=condition=Ready clusterpolicy --all. This job can only verify signatures for images produced on main, so on pull requests either test the privileged rule only or sign PR images with a separate identity that a PR-only policy trusts.
Bonus: Run the same assertions against Gatekeeper with equivalent Rego constraints and compare the developer experience.
Assignment 23. Design a vulnerability management program ๐ด
Objective: Show you can own security outcomes across many teams, not just run tools.
Tasks
- Write a policy document: severity definitions, remediation SLAs, who owns a finding, how exceptions are requested, approved and expired.
- Choose a central place for findings (DefectDojo, GitHub code scanning, a SIEM) and send results from at least three scanners to it.
- Define five metrics, such as mean time to remediate by severity, open criticals per service, percentage of images signed, SLA breach rate and exception count, and build a dashboard for them.
- Describe how you would roll the program out to 30 teams without a revolt: audit first, phased gates, office hours.
- Present it as a one-page summary for an engineering director.
Expected outcome: A policy document, a working central findings view with real data, and a metrics dashboard.
Hints
DefectDojo has importers for Trivy, Semgrep, gitleaks, ZAP and Checkov, and deduplicates across runs. Count only what an engineer can act on in the headline metrics. Tie SLAs to exposure: an internet-facing service with a critical gets a shorter clock than an internal batch job.
Bonus: Add EPSS scores or the CISA KEV catalogue to prioritisation and show how it reorders your top ten.
Assignment 24. CIS audit and cluster posture ๐ด
Objective: Audit a cluster against the CIS Kubernetes Benchmark and fix what matters.
Tasks
- Run kube-bench as a Job in kind and save the results.
- Pick five failed checks and remediate them on the control plane or node (kind lets you edit static pod manifests with
docker exec). - Run
trivy k8s --report summaryand fix the top three workload misconfigurations. - Enable Kubernetes audit logging in kind with a policy that records
Metadatafor Secrets andRequestResponsefor RBAC changes. - Write which checks do not apply to managed Kubernetes (EKS, GKE, AKS) and which benchmark variant you would use there.
Expected outcome: Before-and-after kube-bench and Trivy results, an audit log with real entries, and a short note on managed clusters.
Hints
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml, then kubectl logs job/kube-bench. kind cluster config supports kubeadmConfigPatches and extraMounts to pass an audit policy file to the API server. On managed services the control plane is not yours to audit; there are CIS benchmarks for EKS, GKE and AKS, and kube-bench has targets for them.
Bonus: Schedule kube-bench as a CronJob and alert when the failed-check count goes up.
Assignment 25. Incident drill: compromised dependency and leaked key ๐ด
Objective: Practise the response, not just the prevention.
Tasks
- Scenario A: a popular package you depend on published a malicious version yesterday. Use your SBOM store to find every image containing it within ten minutes, and write the exact commands.
- Block that version from being deployed with a Kyverno policy or a Grype or Trivy gate, and roll back affected services to the last good digest.
- Scenario B: a cloud access key was pushed to a public repo. Write a timed runbook: revoke, check CloudTrail for use, rotate dependants, scope the blast radius, communicate.
- Run scenario B for real in a sandbox: create a key with no permissions, push it to a test repo, and measure detection time from GitHub secret scanning, gitleaks and your provider.
- Write a blameless post-incident review with a timeline, root cause and three preventive actions.
Expected outcome: Two runbooks, measured detection times, and a post-incident review.
Hints
With SBOMs stored as attestations you can loop over images with cosign verify-attestation --type spdxjson ... | jq and search for the package and version. CloudTrail: aws cloudtrail lookup-events --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIA.... AWS often attaches a quarantine policy to keys found in public GitHub repos within minutes; note when that happened.
Bonus: Turn scenario A into a scheduled job that checks every stored SBOM against newly published advisories and opens an issue automatically.