18.1 · The stance — assume breach
The right mental model
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.
18.2 · Threat modeling — STRIDE
| Letter | Threat | Mitigation |
|---|---|---|
| S | Spoofing identity | Strong auth, mTLS, signed requests. |
| T | Tampering | HMAC, signatures, integrity checks. |
| R | Repudiation | Audit logs (append-only, signed). |
| I | Information disclosure | Encryption, least-privilege, masking. |
| D | Denial of service | Rate limits, autoscale, WAF. |
| E | Elevation of privilege | Authz checks at every layer; principle of least authority. |
18.3 · OWASP Top-10 (2021, refreshed 2025)
| # | Risk | Defence |
|---|---|---|
| A01 | Broken Access Control | Deny by default; tested authz; RLS. |
| A02 | Cryptographic Failures | TLS 1.3, AES-GCM, KMS keys. |
| A03 | Injection (SQL, NoSQL, command, LDAP) | Parameterised queries; never interpolate. |
| A04 | Insecure Design | Threat model; security reqs in stories. |
| A05 | Security Misconfiguration | CIS Benchmarks; IaC; admission control. |
| A06 | Vulnerable / Outdated Components | SBOM + Renovate + CI scan gate. |
| A07 | AuthN Failures | OAuth/OIDC, passkeys, MFA, rate-limit login. |
| A08 | Software & Data Integrity Failures | Sigstore / Cosign verify. |
| A09 | Logging & Monitoring Failures | Tamper-evident logs; SIEM; alerting. |
| A10 | SSRF | Egress allow-list; block metadata service; egress proxy. |
18.4 · SAST · DAST · IAST · SCA
| Type | What | Tools |
|---|---|---|
| SAST | Static analysis of source. | Semgrep, CodeQL, SonarQube, Snyk Code. |
| DAST | Dynamic test against running app. | ZAP, Burp, Nuclei. |
| IAST | Instrumented runtime analysis. | Contrast, Seeker. |
| SCA | Software Composition Analysis — known CVEs in deps. | Snyk, Dependabot, OSV-Scanner, Trivy. |
| Container scanning | Image CVEs at build/registry. | Trivy, Grype, Clair. |
| IaC scanning | Misconfig in Terraform / K8s. | Checkov, tfsec, Kics, Kubescape. |
18.5 · Crypto & key management
- In transit: TLS 1.3, HSTS, OCSP stapling. Post-quantum (Kyber+X25519) shipping in 2026.
- At rest: envelope encryption with KMS (AWS / GCP / Azure) or HashiCorp Vault Transit.
- Field-level: pgcrypto, app-side AES-GCM, tokenisation services.
- HSMs: CloudHSM, YubiHSM for FIPS 140-2/3 needs.
- Never invent crypto. Use libsodium, WebCrypto, cloud KMS.
18.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-native; layer-7 rules; rate limit.
18.7 · Supply chain
- SBOM (Syft / CycloneDX / SPDX) on every build.
- SLSA levels for build provenance.
- Sigstore / Cosign signatures; verify in admission control (Kyverno, Gatekeeper).
- Org-level allow-list of npm/PyPI/Maven sources.
- Reproducible builds where feasible.
18.8 · Secrets
- Vault, AWS Secrets Manager, GCP Secret Manager, Doppler, SOPS, age.
- Rotation policy in code; rotate quarterly minimum.
- Pre-commit scanning (gitleaks, trufflehog) + push-protection on repo.
- Alert on retrieval anomalies; audit every fetch.
- OIDC federation from CI → cloud (no long-lived keys in pipelines).
18.9 · Runtime & container security
| Tool | Notes |
|---|---|
| Falco | Runtime detection via eBPF / kernel. |
| Tetragon | Cilium-based runtime security. |
| Kyverno / OPA Gatekeeper | K8s admission control (policy-as-code). |
| seccomp / AppArmor / SELinux | Constrain syscalls per container. |
| gVisor / Kata Containers / Firecracker | Stronger isolation than vanilla containers. |
18.10 · Cloud security posture (CSPM / CIEM / CNAPP)
- CSPM: cloud config drift detection (Prisma, Wiz, Orca, Defender for Cloud).
- CIEM: entitlements / IAM analysis.
- CNAPP: combined (Wiz, Prisma, Orca, Aqua).
- IAM hygiene: no
*:*; deny-list specific high-risk actions; SCPs / Org Policies.
18.11 · Privacy
- Collect less data.
- Pseudonymise / tokenise where possible.
- Field-level encryption for PII.
- Retention policy enforced by jobs.
- Right-to-be-forgotten runbook + tested delete API.
- Data residency: pick region per tenant; pin storage and processing.
18.12 · Standards & frameworks
| Framework | Notes |
|---|---|
| SOC 2 Type II | US Trust Services audit; B2B table-stakes. |
| ISO/IEC 27001 | Information Security Management System; global default. |
| ISO/IEC 27017 / 27018 | Cloud / PII extensions. |
| ISO/IEC 42001 | AI Management System. |
| NIST CSF 2.0 | Cybersecurity Framework — Govern · Identify · Protect · Detect · Respond · Recover. |
| NIST 800-53 / 800-171 | US federal controls; CMMC for defense supply chain. |
| HIPAA / PCI-DSS | Healthcare / card data. |
| GDPR / UK GDPR / CCPA / CPRA | EU / UK / California privacy. |
| EU AI Act / NIST AI RMF | AI-specific (see AI Codex Ch 16). |
| EU CRA (Cyber Resilience Act) | Vulnerability disclosure + SBOM required for products in EU. |
| OWASP ASVS | App Security Verification Standard — testable requirements. |
| CIS Benchmarks | OS / K8s / cloud hardening baselines. |
| FedRAMP / IL5 | US federal cloud authorisations. |
18.13 · Red-team / pen-test cadence
- Internal pen-test annually; external every 1–2 years for B2B.
- Bug bounty (HackerOne, Bugcrowd, Intigriti) for continuous attention.
- Tabletop exercises quarterly — practice the incident playbook.
- Purple team — defenders + attackers in the same room.
18.14 · Self-check
Q1 · Most important defence against SSRF (A10)?
TLS everywhere
Egress allow-list + block metadata service
CSP headers
HTTPS-only cookies