15.1 · The threat model stance
The right mental model
"Assume breach." Design so the blast radius of a stolen credential, a compromised dependency, or a leaked
key is small. Defence in depth + least privilege + observable everything.
15.2 · OWASP Top-10 (2021, refresh 2025) — what each one is and the fix
| # | Risk | Primary defence |
|---|---|---|
| A01 | Broken Access Control | Deny by default; tested authz; row-level security. |
| A02 | Cryptographic Failures | TLS 1.3 everywhere; AES-GCM; KMS-managed keys. |
| A03 | Injection (SQL, NoSQL, command, LDAP) | Parameterised queries; never interpolate. |
| A04 | Insecure Design | Threat model; security reqs in story acceptance. |
| A05 | Security Misconfiguration | CIS Benchmarks; IaC; admission control. |
| A06 | Vulnerable / Outdated Components | SBOM + Renovate + scanning gate in CI. |
| A07 | Identification & AuthN Failures | OAuth/OIDC; passkeys; MFA; rate-limit login. |
| A08 | Software & Data Integrity Failures | Sigstore / Cosign; verify in admission. |
| A09 | Security Logging & Monitoring Failures | Tamper-evident logs; alerting; SIEM. |
| A10 | SSRF | Outbound allow-list; metadata-service block; egress proxy. |
15.3 · Authentication
- OAuth 2.1 + OIDC for federated identity. Use Auth0, WorkOS, Clerk, Cognito, Keycloak, Ory.
- Passkeys (WebAuthn) — phishing-resistant, biometric, default by 2026.
- MFA at minimum (TOTP, push, hardware key). SMS is last resort.
- JWTs — short-lived access + rotated refresh + revocation list. Never store in localStorage if you can avoid it; use HttpOnly Secure cookies.
- Session-based auth still fine for first-party apps; simpler than JWT.
15.4 · Authorization
| Model | Definition | Use when |
|---|---|---|
| RBAC | Roles → permissions. "Admin can delete." | Small surface; few roles. |
| ABAC | Attributes (user, resource, context) → policy. | Complex rules ("doctors can read patients in their hospital"). |
| ReBAC | Relationships (Google Zanzibar). "X is owner of Y". | Sharing, multi-tenant, graphs of permissions. |
| Policy-as-code | Rego (OPA), Cedar (AWS), Topaz, Oso. | Decisions outside the app; auditable. |
15.5 · Encryption & key management
- In transit: TLS 1.3, HSTS, secure ciphers, OCSP stapling.
- At rest: envelope encryption with cloud KMS (AWS / GCP / Azure) or HashiCorp Vault Transit.
- Field-level: for very sensitive columns (SSNs, card data) — pgcrypto or a tokenisation service.
- Never invent crypto. Use libsodium / WebCrypto / cloud KMS.
15.6 · Network — mTLS, Zero Trust
- mTLS between services (service mesh handles it).
- Zero Trust — verify every request; never trust the network. BeyondCorp / Cloudflare Access / Tailscale / Twingate.
- Egress control — squid proxy, NetworkPolicy, allow-list outbound.
- WAF — Cloudflare, AWS WAF, Fastly Next-Gen.
- DDoS — cloud-provider native; layer-7 rules.
15.7 · Supply chain
See Ch 13 (Supply chain). Add: signed commits (Sigstore Gitsign); two-person review on prod-touching infra; org-level allow-list of npm/pip/Maven sources.
15.8 · Secrets management
- Vault, AWS Secrets Manager, GCP Secret Manager, Doppler, SOPS.
- Rotation policy in code; rotate quarterly minimum.
- Pre-commit scanning (gitleaks, trufflehog) plus org-wide push-protection.
- Alert on retrieval anomalies; audit every fetch.
15.9 · Compliance frameworks — the alphabet soup
| Framework | What it gives buyers |
|---|---|
| SOC 2 Type II | Trust Service Criteria audit; required to sell into mid-market US. |
| ISO/IEC 27001 | Information Security Management System; widely required outside US. |
| ISO/IEC 42001 | AI Management System (the "ISO 27001 for AI"). |
| HIPAA | US healthcare data. |
| PCI-DSS | Card data handling. |
| GDPR / UK GDPR | EU/UK personal-data rights & obligations. |
| CCPA / CPRA | California privacy rights. |
| EU AI Act / NIST AI RMF | AI-specific (see AI Codex Ch 16). |
| FedRAMP / IL5 | US federal cloud authorisation. |
| EU CRA (Cyber Resilience Act) | Mandatory vulnerability disclosure + SBOM for products in EU. |
Tools that make this less painful: Vanta, Drata, Sprinto, Secureframe.
15.10 · Privacy by design
- Collect less data.
- Pseudonymise / tokenise where possible.
- Field-level encryption for PII.
- Retention policy enforced by jobs, not hope.
- Right-to-be-forgotten runbook + tested delete API.
- Data residency: pick region per tenant; pin storage and processing.
15.11 · Self-check
Q1 · A vendor proposes "we trust the internal network so no mTLS between services". Right response?
Sure, less ops overhead
No — mTLS via mesh; Zero Trust posture
Use a VPN instead
Trust on first use