SE·114
Security Engineering Projects
Eight build-it-yourself projects that secure the tiffin centre end to end: a least-privilege baseline, cryptography done right, a web app hardened against the OWASP Top 10, an identity and authorisation layer, a defended public API, a hardened container platform, a trusted software supply chain, and a living threat model, each with milestones, measurable definitions of done and stretch goals.
How to approach the projects
One system, secured layer by layer
The labs in this volume checked one defence at a time. These projects apply them all to one system you own: the tiffin centre's services (orders, kitchen, payments, delivery) from earlier volumes, or a service of your own. Everything runs on a laptop or a small cluster: Docker or Podman, k3s or kind, nginx or Envoy as a gateway, Keycloak (or another OIDC provider) for identity, OpenFGA or OPA for authorisation, Syft, Grype or Trivy, cosign and a local registry for the supply chain, and pytm or a diagram tool for threat models.
Only test systems you own or are explicitly authorised to test. Every project here works on your own code and infrastructure; that is also where the learning is, because you see both sides of each control.
| # | Project | Main chapters | Roughly |
|---|---|---|---|
| 1 | A least-privilege baseline | Start Here, 106 | a weekend |
| 2 | Cryptography done right | 107 | 1 week |
| 3 | A web app hardened against the Top 10 | 108 | 1–2 weeks |
| 4 | Identity and fine-grained authorisation | 109 | 1–2 weeks |
| 5 | A defended public API | 110 | 1 week |
| 6 | A hardened container platform | 111 | 1–2 weeks |
| 7 | A trusted software supply chain | 112 | 1–2 weeks |
| 8 | A living threat model | 113 (and all) | ongoing |
New to the topic? Do them in order. Experienced? Start with project 8 to decide where your system is weakest, then treat the stretch goals as the assignment.
The working method
- Security as code: policies, pod specs, gateway configs, lockfiles, signing steps and the threat model live in Git and ship through CI.
- Write the definition of done as a test first: a unit test that a forged token is rejected, a
kubectl auth can-iassertion, a curl check for a header, a failing install with a wrong hash. - Prove each control fires. The chapter 110 lab's rate limit that never ran is the norm, not the exception; a control without a test is a hope.
- Measure the cost: added latency, build time, developer friction, false positives per week.
- Write a README per project with decisions, alternatives and residual risks.
The eight projects
Project 1: a least-privilege baseline
Goal. Every process, user and credential in the system has only the access it needs, and you can show it.
Milestones. Inventory every service, its OS user, capabilities, file and network access, and the credentials it holds → run each service as a dedicated non-root user with no capabilities (or exactly one, documented) → separate database users per service with grants limited to their tables → remove shared admin accounts; personal accounts with MFA for humans → secrets out of code and images into a secret store.
Done when. A script prints, for each service, its uid, its effective capabilities (all zero but documented exceptions) and its database grants; a test proves the orders service's database user cannot read the payments tables; git log -p | grep -i for common secret patterns (or gitleaks) finds nothing.
Stretch. systemd sandboxing (ProtectSystem=strict, NoNewPrivileges, SystemCallFilter) for one service, with systemd-analyze security scored before and after.
Project 2: cryptography done right
Goal. Passwords, secrets at rest and data in transit are protected with standard constructions and managed keys.
Milestones. Argon2id password hashing with parameters stored in the hash and transparent rehash on login → field-level AES-GCM encryption for customer phone numbers with associated data binding the row ID → envelope encryption with a KMS (cloud KMS, Vault Transit or a local emulator) → TLS 1.3 everywhere internal, from a private CA, with automated renewal → key rotation that re-wraps data keys without downtime.
Done when. Tests show a tampered ciphertext and a ciphertext moved to another row both fail to decrypt; a password-hash upgrade from bcrypt to Argon2id happens on next login with no reset; a rotation script runs while load tests pass; openssl s_client checks fail for a wrong hostname on every internal endpoint.
Stretch. Hybrid post-quantum TLS (X25519MLKEM768) between two services where your TLS library supports it, with handshake size and latency measured.
Project 3: a web app hardened against the Top 10
Goal. The customer web app has no findings from its own tests in the main OWASP categories, and new ones are caught in CI.
Milestones. Parameterised queries everywhere, enforced by a Semgrep or CodeQL rule → an auto-escaping template engine and a strict CSP with nonces, rolled out through Report-Only → CSRF tokens plus SameSite cookies on every state-changing form → server-side fetches (avatars, previews) through an allow-listing egress proxy → security headers set once at the edge and checked by a CI curl test → a DAST scan (OWASP ZAP baseline) of your staging environment in CI.
Done when. Unit tests for injection, encoding, path handling and CSRF pass; the Playwright CSP test from the chapter 108 lab passes on every page; the ZAP baseline scan has no high findings; a deliberately reintroduced string-built query fails CI.
Stretch. Trusted Types enforced in the browser for one page, with every DOM sink migrated.
Project 4: identity and fine-grained authorisation
Goal. Users and services authenticate through one identity provider, and every request is authorised per object.
Milestones. Keycloak (or another OIDC provider) with authorisation code + PKCE for the web app and passkeys as a login option → access tokens validated in every service with fixed algorithms, issuer and audience → refresh-token rotation and logout that revokes sessions → service-to-service identity with client credentials or workload identity → kitchen and customer permissions in OpenFGA (ReBAC) or OPA, called from each service.
Done when. The chapter 109 validation matrix runs as tests against every service; a two-user BOLA test exists for every endpoint that takes an ID; moving an order to another kitchen changes who can update it with no code change; a stolen refresh token stops working after one use by the legitimate client.
Stretch. Sender-constrained tokens with DPoP, measured against bearer tokens for latency and complexity.
Project 5: a defended public API
Goal. The public orders API withstands misuse, overload and replay, and you can see abuse when it happens.
Milestones. OpenAPI spec with strict schemas enforced at the gateway and in the service → per-identity rate limits and quotas with Retry-After → signed partner webhooks with timestamp and nonce, and key rotation → idempotency keys for payments → audit logs of who did what to which object → an API inventory that flags undocumented routes.
Done when. Tests cover unknown fields, wrong types, out-of-range values and oversized bodies; a load test above the limit gets 429s while a second key is unaffected; the four webhook cases from the chapter 110 lab pass; a retried payment never double-charges, including two concurrent retries; a route missing from the spec fails CI.
Stretch. Anomaly alerts on the audit log (one identity reading 100× its usual number of distinct orders) wired into the Volume 9 alerting stack.
Project 6: a hardened container platform
Goal. Every workload runs with restricted privileges on a cluster that refuses unsafe workloads and limits lateral movement.
Milestones. Distroless or minimal images, non-root, pinned by digest → restricted Pod Security on every application namespace, rolled out via warn and audit first → default-deny ingress and egress NetworkPolicies with explicit allows (DNS included) → least-privilege RBAC with no wildcards, tokens disabled where unused → secrets from an external store, encrypted etcd → runtime detection with Falco or Tetragon for shells in containers and unexpected outbound connections.
Done when. A script asserts each pod's securityContext and every service account's auth can-i --list; a connectivity matrix test shows exactly the intended flows; starting a shell in a production pod raises a Falco alert within a minute; kube-bench (CIS benchmark) high findings are fixed or documented.
Stretch. User namespaces (hostUsers: false) for one workload, with a demonstration that uid 0 in the pod is unprivileged on the node.
Project 7: a trusted software supply chain
Goal. Only artefacts built by your pipeline, from reviewed source, with known contents, can run in production.
Milestones. Hash-pinned lockfiles for every ecosystem; CI actions pinned by commit SHA → dependency scanning and SBOM generation on every build → Renovate or Dependabot with automerge for low-risk updates → keyless cosign signing and SLSA provenance from CI → a Kubernetes admission policy that rejects unsigned images or images signed by any other identity → reproducible builds for the Go or Java services.
Done when. An image built on a laptop and pushed to the registry is refused by the cluster; a dependency with a known high-severity, fixable advisory fails CI; rebuilding a release tag on a different machine gives the same digest; every running image's SBOM can be found from its digest in under a minute.
Stretch. Reach SLSA Build L3 with an isolated, ephemeral builder, and write down which attacks from chapter 112 each step now blocks.
Project 8: a living threat model
Goal. The system's threat model is current, owned and drives work, rather than sitting in a document.
Milestones. A DFD as code (pytm, Threat Dragon or a diagram in the repo) for the whole system → STRIDE per element and per boundary-crossing flow, with LINDDUN for customer data → every threat with a response, an owner and a link to its test or ticket → a threat-model review step in the design-review template → a separate model for any LLM feature (prompt injection, tool permissions, output handling).
Done when. Every "mitigated" threat links to a passing test from projects 1–7; every "accepted" threat has an owner and a review date; a new data flow added in a pull request shows up as a diff in the model and triggers review; a teammate who didn't write it can run a 45-minute session from it.
Stretch. Run a tabletop exercise for one high-impact threat (stolen CI token, leaked customer data) with your Volume 9 incident process, and update the model from what you learn.
Tracking your progress
Portfolio checklist
Keep the policies, configs, tests, SBOMs, signatures, threat model and READMEs in Git. Security evidence is tests that fail when a control is removed: "0 services running as root; orders DB user denied on payments tables; 7-case token matrix passing in 5 services; BOLA test on 34 of 34 ID endpoints; 429 above 5 r/s per key with a second key untouched; restricted PSA on all namespaces; unsigned image refused at admission; identical digests from two builders; 41 threats, each with a response and owner" is what makes the portfolio credible.
Mapping to mastery levels
Completing projects 1–3 with their checks puts you at L2 across the volume. Doing their stretch goals and explaining every mechanism is L3–L4. Designing and defending projects 4–8 (identity architecture, API security platform, cluster guardrails, trusted build pipeline, and an organisation-wide threat-modelling practice) is L5 work, the level security-minded senior and staff interviews probe.