Skip to main content
← ALL DOMAINS
An end-to-end domain learning journey

Security &
Identity.

Application and infrastructure security establishes the cryptographic identity, transport integrity, delegated authorization, and policy enforcement invariants of distributed platforms. It spans TLS 1.3 and PKI, zero-trust mTLS service meshes, OAuth 2.0/OIDC federation, hardened JWT validation, phishing-resistant MFA, and decoupled RBAC/ABAC policy engines.
Start the journey7 chapters
Loading diagram…
Security & Identity architecture sketch diagram
LEAST PRIVILEGE. CRYPTOGRAPHIC INTEGRITY.
The idea to keep with you

Assume the internal network is already compromised. Eliminate ambient IP trust, enforce cryptographic identity (mTLS) and least privilege at every hop, validate token claims and algorithms strictly, and fail closed by default.

From patterns to decisions.

Learn to architect systems where cryptographic identity, bounded delegation, and least-privilege authorization hold even when perimeter firewalls fail or internal workloads are compromised.

  • Select appropriate cryptographic primitives (AES-GCM, ECDSA/Ed25519) and design envelope encryption with KMS.
  • Eliminate implicit network trust using mutual TLS (mTLS) and SPIFFE/SPIRE workload attestation.
  • Implement OAuth 2.1 Authorization Code + PKCE, Client Credentials, and RFC 8693 Token Exchange safely.
  • Separate authentication (OIDC ID Tokens) from authorization (OAuth Access Tokens) and automate JWKS rotation.
  • Harden JWT verification against algorithm confusion, missing claims, and token replay or leakage.
  • Replace phishable SMS/password flows with origin-bound FIDO2/WebAuthn passkeys and risk-based step-up auth.
  • Decouple authorization logic from application code using RBAC, ABAC, OPA, or Zanzibar-style relation graphs.
01
Security & Identity / Stage 01L4 · FUNDAMENTALS

Cryptographic Foundations & TLS / PKI Infrastructure.

Modern transport and data security combines asymmetric cryptography (ECDSA, Ed25519, RSA) for identity verification and ephemeral key exchange (ECDHE) with symmetric Authenticated Encryption with Associated Data (AES-256-GCM, ChaCha20-Poly1305) for wire-speed bulk encryption. TLS 1.3 removes legacy cipher suites, mandates forward secrecy via ephemeral Diffie-Hellman, encrypts the handshake after ServerHello, and reduces setup to 1-RTT (with optional 0-RTT resumption that requires strict replay protection). At rest, envelope encryption pairs per-record Data Encryption Keys (DEKs) with Key Management Service (KMS) Key Encryption Keys (KEKs) so root keys never leave hardware security modules.

ChoiceWhat it buysWhat it costs
Symmetric AEAD (AES-256-GCM / ChaCha20-Poly1305)Hardware-accelerated (AES-NI) throughput at tens of gigabits per second. Provides both confidentiality and tamper-detection via authentication tags.Requires a secure out-of-band mechanism to share or wrap keys. Nonce reuse under the same key catastrophically breaks confidentiality and integrity.
Asymmetric PKI (ECDSA P-256 / Ed25519 / RSA)Separates public verification keys from private signing keys. Enables verifiable X.509 certificate chains rooted in trusted CAs.Orders of magnitude slower than symmetric ciphers for bulk payloads. Requires automated certificate lifecycle management, revocation (OCSP stapling), and rotation.

TLS 1.3 1-RTT and 0-RTT Resumption

TLS 1.3 negotiates ECDHE key shares in the initial ClientHello/ServerHello round trip for forward secrecy. 0-RTT early data avoids a round trip on resumed sessions but is vulnerable to replay attacks, so it must be restricted to strictly idempotent requests.

Envelope Encryption with KMS

Generate a unique 256-bit DEK per tenant or object, encrypt the payload locally with AES-GCM, and wrap the DEK using a KMS-managed KEK. This bounds blast radius, avoids sending bulk data over the network to KMS, and supports instant key rotation.

Order platform / Eliminating 0-RTT Replay Risk on a Payment Gateway

Eliminating 0-RTT Replay Risk on a Payment Gateway.

After enabling TLS 1.3 0-RTT early data on edge load balancers to shave latency, a payment API observed occasional duplicate POST /v1/charges executions when mobile clients reconnected across cellular towers.

TLS 1.3 0-RTT packets are not protected against network-level replay because the server has not yet contributed fresh entropy. The team disabled 0-RTT for all non-GET methods at the Envoy edge proxy and enforced idempotency keys on state-mutating endpoints.

Lesson: Transport optimizations like 0-RTT must respect application-layer idempotency invariants; never allow replayable early data on mutating routes.
  • Never implement custom cryptographic primitives or use ECB mode; rely on audited libraries such as libsodium, BoringSSL, or WebCrypto.
  • Monitor certificate expiration continuously; an expired intermediate or leaf X.509 cert causes total service blackouts.
Pause & reason: where would you draw the boundary?▼
  • Which data paths require forward secrecy in transit versus envelope encryption at rest?
  • How are AES-GCM nonces generated to guarantee uniqueness across distributed writers?
  • What happens to mutating endpoints if TLS 1.3 0-RTT early data is enabled at the CDN or load balancer?
  • How quickly can an intermediate CA or KMS KEK be rotated if a private key is suspected compromised?
02
Security & Identity / Stage 02L4 · FUNDAMENTALS

Zero-Trust Architecture & Mutual TLS (mTLS).

Zero-Trust Architecture (ZTA) assumes the corporate or cloud VPC network is already compromised. Instead of trusting requests based on source IP or subnet, every service-to-service RPC must establish mutual TLS (mTLS), where both client and server present and verify X.509 certificates signed by an internal Certificate Authority. Frameworks such as SPIFFE and SPIRE attest workloads using kernel-level metadata (Kubernetes ServiceAccount tokens, AWS Nitro/TPM attestation, cgroup IDs) and issue short-lived X.509 SVIDs (1-hour to 24-hour TTLs) rotated automatically without restarts.

Workload Attestation (SPIRE Agent)Verifies pod/process identity via kubelet, cgroups, or cloud instance identity documents.
Short-Lived X.509 SVID IssuanceMints a SPIFFE ID certificate (e.g., spiffe://prod.internal/ns/payments/sa/ledger) with automated rotation.
mTLS Sidecar / Proxy HandshakeBoth caller and callee Envoy proxies validate SAN SPIFFE IDs and encrypt wire traffic.
L7 Authorization Policy EnforcementEvaluates whether the verified source SPIFFE ID is permitted to invoke the target HTTP/gRPC method.

Short-Lived Certificates Over Static CRLs

Issuing 1-hour X.509 SVIDs via SPIRE or Istio Citadel reduces the window of a stolen key without relying on brittle, high-latency Certificate Revocation Lists.

Defense-in-Depth: L3/L4 Network Policy + L7 mTLS

Pair eBPF/Cilium L3/L4 deny-all network policies with L7 mTLS identity checks so compromised pods cannot even open TCP sockets to unrelated namespaces.

Order platform / Containing Lateral Movement in a Multi-Tenant Kubernetes Cluster

Containing Lateral Movement in a Multi-Tenant Kubernetes Cluster.

A vulnerability in a public-facing image-thumbnailing pod allowed remote code execution, and the attacker immediately scanned internal 10.0.0.0/8 IPs to reach the billing database and internal admin APIs.

The platform replaced flat VPC trust with Cilium default-deny L4 policies and Istio strict mTLS using SPIFFE identities. Even with shell access inside the thumbnailer pod, TCP connections to the billing namespace were dropped at the kernel eBPF layer and unauthenticated HTTP calls were rejected by Envoy.

Lesson: IP addresses are ephemeral and spoofable; cryptographic workload identity paired with default-deny network policies stops lateral movement.
  • Enforce STRICT mTLS only after migrating all legacy health checks and cron jobs; PERMISSIVE mode leaves plaintext downgrade paths open.
  • Account for ~1-2ms sidecar proxy latency and CPU overhead on high-fanout East-West gRPC paths.
Pause & reason: where would you draw the boundary?▼
  • Which internal services currently trust callers solely by VPC CIDR or Kubernetes namespace?
  • How are workload identities attested at boot without embedding static bootstrap secrets in container images?
  • What happens to East-West traffic if the internal CA or SPIRE server becomes temporarily unreachable?
  • Are L7 policies restricting specific HTTP verbs/paths per caller identity, or merely validating that a certificate is signed by the cluster CA?
03
Security & Identity / Stage 03L5 · APPLIED DESIGN

OAuth 2.0 Authorization & Token Exchange.

OAuth 2.0 separates the Resource Owner, Client, Authorization Server, and Resource Server so applications can obtain scoped, time-bounded access tokens without ever handling user credentials. Modern OAuth 2.1 deprecates the Implicit and Resource Owner Password Credentials flows in favor of Authorization Code Flow with Proof Key for Code Exchange (PKCE, RFC 7636), which binds the token exchange to a dynamic SHA-256 code_challenge so intercepted authorization codes cannot be redeemed. For machine-to-machine (M2M) workloads, Client Credentials with private_key_jwt or mTLS client authentication replaces shared static secrets, while RFC 8693 Token Exchange enables downstream services to downscope or swap tokens across trust boundaries.

PatternUse whenDesign for
Authorization Code + PKCEA human user delegates access to a web, SPA, or native mobile client.Cryptographic code_verifier/code_challenge binding., Exact redirect_uri matching (no wildcards)., CSRF protection via state parameter.
Client Credentials (M2M)A backend daemon or service calls an API on its own behalf without a user.Asymmetric private_key_jwt or mTLS client auth., Narrow least-privilege scopes., Short access token TTLs (5-15 minutes).
RFC 8693 Token ExchangeAn internal microservice needs a downscoped token to call a downstream service on the user's behalf.Explicit audience (aud) narrowing., Actor (act) claim auditability., Preventing confused-deputy token forwarding.

Refresh Token Rotation with Reuse Detection

Issue single-use refresh tokens that rotate on every redemption. If an already-consumed refresh token is replayed, the Authorization Server immediately revokes the entire token family to contain theft.

Sender-Constrained Tokens (DPoP / mTLS)

Standard bearer tokens grant access to anyone who possesses them. Binding tokens to a client's TLS certificate (RFC 8705) or DPoP proof key prevents stolen tokens from being replayed from another host.

Order platform / Stopping Authorization Code Interception in Native Mobile Apps

Stopping Authorization Code Interception in Native Mobile Apps.

A mobile banking app used a custom URL scheme (myapp://callback) without PKCE. Malicious apps installed on the same device registered the identical scheme and intercepted the OAuth authorization code.

The team migrated to OAuth 2.1 Authorization Code + PKCE (S256) and OS-verified Universal Links / App Links. Even if an attacker intercepted the authorization code, the Authorization Server rejected the /token request because the attacker lacked the ephemeral code_verifier.

Lesson: Public clients cannot keep a client_secret confidential; PKCE and exact OS-verified redirect URIs are mandatory to bind authorization codes to the legitimate client instance.
Pause & reason: where would you draw the boundary?▼
  • Are any legacy SPAs or mobile clients still using the deprecated OAuth Implicit flow instead of Authorization Code + PKCE?
  • How does the Authorization Server detect and respond if a rotated refresh token is replayed?
  • When Service A calls Service B on behalf of a user, is the raw user token forwarded blindly or downscoped via RFC 8693?
  • Are redirect_uri checks exact string matches, or do open-redirect wildcards allow token exfiltration?
04
Security & Identity / Stage 04L5 · APPLIED DESIGN

OpenID Connect (OIDC) & Federated Identity.

OAuth 2.0 is an authorization protocol and intentionally says nothing about who the user is. OpenID Connect (OIDC) layers authentication on top of OAuth 2.0 by introducing the signed ID Token (a JWT containing sub, iss, aud, exp, iat, and nonce claims), the /userinfo endpoint, and standardized /.well-known/openid-configuration discovery. Resource servers must never accept an ID Token as an API access token, and clients must never treat an opaque OAuth Access Token as proof of user identity. For enterprise B2B SaaS, OIDC and SAML 2.0 enable federated Single Sign-On (SSO) where the customer's Identity Provider (Okta, Entra ID) remains the source of truth for user lifecycle and offboarding.

ChoiceWhat it buysWhat it costs
OIDC ID TokenCryptographically signed assertion of who authenticated, when, and against which issuer. Bound to the requesting client via aud and protected from replay via nonce.Intended solely for the client application; must never be sent to backend resource servers as a bearer API credential.
OAuth 2.0 Access TokenCarries scoped permissions (scope) and target resource audience (aud) for API authorization. Can be short-lived and independently refreshed or introspected.Does not guarantee the user is currently present or authenticated in the client session.

Dynamic Key Rotation via JWKS and kid

Publish public signing keys at the discovery jwks_uri with a Key ID (kid). Relying parties cache JWKS with a bounded TTL and refresh on an unknown kid, enabling zero-downtime key rotation.

Federated Identity Linking and Account Takeover Prevention

Never auto-link a federated OIDC login to an existing local account solely by an unverified email claim; require email_verified=true and explicit user confirmation or immutable (iss, sub) pair matching.

Order platform / Preventing Cross-Tenant Account Takeover via Unverified Email Linking

Preventing Cross-Tenant Account Takeover via Unverified Email Linking.

A B2B SaaS platform linked incoming OIDC logins to existing user accounts by matching the email claim. An attacker created an account on an external OIDC provider with a victim's corporate email and gained access to the victim's workspace.

Engineering changed the identity store to key federated identities strictly on the immutable composite (iss, sub) tuple, enforced email_verified=true, and required an authenticated step-up session before linking a new IdP to an existing local account.

Lesson: Email addresses are mutable and not universally verified across IdPs; always key federated identity on (iss, sub).
Pause & reason: where would you draw the boundary?▼
  • Does your backend API reject OIDC ID Tokens when presented in Authorization: Bearer headers?
  • How are user accounts keyed in the database—by mutable email or by immutable (iss, sub) pairs?
  • If an IdP rotates its signing key unexpectedly, does your JWKS cache fetch the new kid safely without triggering a thundering herd?
  • When an enterprise employee is offboarded in Okta or Entra ID, how quickly are their active application sessions terminated?
05
Security & Identity / Stage 05L6 · SCALE & TRADE-OFFS

JSON Web Tokens (JWT) Architecture & Hardening.

JSON Web Tokens (JWS for signed tokens, JWE for encrypted tokens) allow distributed services to verify claims locally without a central session database lookup. However, trusting untrusted headers or skipping claim checks leads to catastrophic bypasses: accepting "alg": "none" disables signature verification entirely, while RS256-to-HS256 key confusion tricks a server into verifying an HMAC signature using its publicly known RSA public key. Hardened JWT verification pins an explicit algorithm allowlist on the server, validates iss, aud, exp, and nbf with bounded clock skew, stores tokens in HttpOnly/Secure/SameSite cookies rather than localStorage (to resist XSS exfiltration), and pairs short 5-15 minute access TTLs with a Redis jti revocation blocklist for emergency logouts.

Explicit Server-Side Algorithm Pinning

Configure JWT verifiers with an explicit allowlist (e.g., ["RS256", "ES256"]). Never derive the verification algorithm from the untrusted JWT header's alg field.

Short TTLs + Bounded JTI Revocation Blocklist

Keep access token lifetimes to 5-15 minutes so a Redis revocation set keyed by jti only needs to store revoked IDs until their natural exp timestamp, bounding memory growth.

Order platform / Closing an RS256/HS256 Key Confusion Bypass in an API Gateway

Closing an RS256/HS256 Key Confusion Bypass in an API Gateway.

A penetration test forged an admin JWT accepted by a Node.js API gateway by signing an admin payload with HS256 using the gateway's publicly downloadable RSA public key as the HMAC secret.

The gateway's verification middleware passed the JWKS RSA public key directly to jwt.verify() without specifying algorithms: ["RS256"]. Pinning algorithms: ["RS256"] and enforcing strict iss and aud validation eliminated the forgery vector immediately.

Lesson: A JWT header is attacker-controlled input; always pin expected algorithms and validate every standard claim server-side.
  • Signed JWS payloads are Base64URL-encoded, not encrypted; never put PII, secrets, or internal database IDs in a JWS without JWE encryption.
  • If the Redis jti blocklist is unreachable during an emergency revocation check, fail closed on high-privilege endpoints.
Pause & reason: where would you draw the boundary?▼
  • Does every JWT verification call in your codebase explicitly pin allowed signing algorithms?
  • Are both iss and aud validated so tokens issued for one microservice cannot be replayed against another?
  • Where are tokens stored in the browser—and if in localStorage, what prevents an XSS payload from exfiltrating them?
  • How long can a compromised user's access token remain valid after password reset or account suspension?
06
Security & Identity / Stage 06L6 · SCALE & TRADE-OFFS

Multi-Factor Authentication (MFA) & Risk-Based Security.

Multi-Factor Authentication combines independent evidence across knowledge (passwords), possession (hardware keys, authenticator apps), and inherence (biometrics). SMS and voice OTPs are vulnerable to SIM swapping, SS7 interception, and real-time adversary-in-the-middle (AiTM) phishing proxies. TOTP (RFC 6238) improves on SMS by computing HMAC-SHA1/256 over 30-second time steps with a ±1 window for clock skew and strict single-use replay tracking, though it remains phishable on lookalike domains. FIDO2/WebAuthn passkeys eliminate phishing entirely by using asymmetric device keys where the browser cryptographically binds the signed challenge to the exact TLS origin (rpId).

ChoiceWhat it buysWhat it costs
SMS / Voice OTPZero app installation required; broad reach.Vulnerable to SIM swapping, carrier social engineering, and SS7 interception. Easily captured by AiTM phishing proxies.
TOTP (RFC 6238)Works offline without telecom carrier dependencies. Simple server-side verification with ±1 step drift tolerance.Shared secret can still be phished by real-time reverse-proxy phishing kits. Requires single-use code tracking to prevent replay within the 30s window.
FIDO2 / WebAuthn PasskeysCryptographically bound to the exact origin (rpId), defeating AiTM phishing. Private key never leaves the hardware enclave or synced platform keychain.Requires account recovery workflows when a user loses all registered devices.

Single-Use TOTP Replay Prevention

Record the last accepted TOTP time-step counter per user in Redis or the auth database and reject any subsequent attempt using the same or older time step.

Adaptive Risk-Based Step-Up Authentication

Evaluate device posture, impossible travel, IP reputation, and action sensitivity (e.g., wire transfer, API key creation) to trigger WebAuthn step-up challenges without adding friction to routine reads.

Order platform / Defeating AiTM Phishing Proxies with FIDO2 Origin Binding

Defeating AiTM Phishing Proxies with FIDO2 Origin Binding.

Employees using passwords and TOTP codes fell victim to a reverse-proxy phishing site (login-corp-sso.com) that relayed credentials and valid 6-digit TOTP codes in real time to the real IdP.

The security team mandated hardware-backed FIDO2 WebAuthn passkeys for all corporate SSO logins. When an employee visited the phishing domain, the browser signed the WebAuthn challenge with the phishing rpId, which the real IdP rejected because it did not match the canonical origin.

Lesson: Only cryptographic origin-bound factors like FIDO2/WebAuthn stop real-time adversary-in-the-middle phishing proxies.
Pause & reason: where would you draw the boundary?▼
  • Which high-risk user or admin actions still rely on SMS OTP or allow password-only access?
  • Does your TOTP verifier prevent the same 6-digit code from being replayed within its 30-second validity window?
  • How does your WebAuthn recovery flow verify identity without reintroducing a weaker fallback factor that bypasses passkey security?
  • What risk signals trigger step-up authentication mid-session (e.g., ASN change, new device, privilege escalation)?
07
Security & Identity / Stage 07L7 · STAFF / PRINCIPAL

Authorization Models: RBAC, ABAC & Policy as Code.

Authentication proves who the caller is; authorization decides what they may do on a specific resource. Role-Based Access Control (RBAC) maps users to static roles (admin, editor, viewer) and works well for coarse-grained permissions, but suffers role explosion in multi-tenant B2B apps where access depends on ownership, department, time, or data classification. Attribute-Based Access Control (ABAC) evaluates dynamic subject, resource, action, and environment attributes using externalized Policy-as-Code engines like Open Policy Agent (OPA/Rego) or AWS Cedar. For deeply nested hierarchical sharing (folders, teams, documents), Relationship-Based Access Control (ReBAC / Google Zanzibar) evaluates transitive permission graphs with bounded latency.

Object-Level Authorization to Prevent IDOR

Never check only that a user has a role like 'member'; always enforce resource ownership or tenant scoping (e.g., WHERE doc_id = :id AND tenant_id = :token_tenant) at the data-access boundary.

Decoupled Policy-as-Code (OPA / Cedar)

Externalize authorization rules from application code into versioned, unit-tested Rego or Cedar policies evaluated via an embedded library or local sidecar with <1ms p99 latency.

Order platform / Eliminating Role Explosion and IDOR in a Multi-Tenant SaaS

Eliminating Role Explosion and IDOR in a Multi-Tenant SaaS.

A B2B analytics platform had accumulated 140 custom RBAC roles per customer to model workspace, folder, and dashboard permissions, while an un-scoped /api/reports/:id endpoint leaked cross-tenant reports (IDOR).

The team replaced ad-hoc role checks with a unified Policy-as-Code layer (OPA) paired with a Zanzibar-style relation graph (user -> team -> folder -> report). Every API handler queried the policy engine with (subject, action, resource_id, tenant_id), eliminating both role explosion and IDOR.

Lesson: Coarse RBAC cannot express resource-level ownership cleanly; pair RBAC with ABAC or ReBAC at every object access boundary.
  • Avoid caching authorization decisions with long TTLs on high-sensitivity resources; use Zanzibar-style Zookies or short-lived cache invalidation events.
  • Ensure every policy engine defaults to deny (fail closed) when input attributes are missing or the sidecar is unreachable.
Pause & reason: where would you draw the boundary?▼
  • Can a logged-in user access another tenant's record simply by incrementing an ID in a URL or request body (IDOR)?
  • Where is authorization logic currently implemented—scattered across controllers, SQL queries, or a testable policy engine?
  • At what point does your RBAC role count require transitioning to ABAC attributes or ReBAC relationship tuples?
  • How do you test authorization policy changes in CI before deploying them to production?

Theory & Tips and Tricks

Practical heuristics & interview traps

  • 01Domain principle: Assume the internal network is already compromised. Eliminate ambient IP trust, enforce cryptographic identity (mTLS) and least privilege at every hop, validate token claims and algorithms strictly, and fail closed by default.
  • 02End-to-end lesson: Transport security, authentication, and authorization are distinct layers; weakness in any single layer compromises the whole chain.
  • 03Failure check — JWT Key Confusion + Compromised Internal Pod: An attacker exploits an SSRF or dependency vulnerability in a non-critical reporting pod and attempts to both forge an admin JWT via alg:none/HS256 confusion and connect directly to the ledger database. Recovery: Pinned algorithm allowlists reject the forged JWT at the gateway, Cilium L4 policies drop direct TCP packets from the reporting pod to the ledger DB, and strict mTLS + OPA deny any unauthorized RPCs while alerting SOC telemetry.
End-to-End Architecture · Security & Identity

Secure a Zero-Trust Multi-Tenant Banking API

Edge Gateway (TLS 1.Token Hardening & SeService Mesh (SPIFFEPolicy Engine & Enve
Synthesis / One connected design

Secure a Zero-Trust Multi-Tenant Banking API

A fintech platform exposes web, mobile, and partner APIs that handle account balances, money transfers, and multi-tenant enterprise reporting across 15 internal microservices.

A candidate architecture, not a universal answer

Secure a Zero-Trust Multi-Tenant Banking API

Edge Gateway (TLS 1.3 + OAuth 2.1)Terminates TLS 1.3 (0-RTT disabled on mutations), enforces rate limits, and validates OIDC/OAuth2 PKCE-issued access tokens.
Token Hardening & Session LayerVerifies pinned ES256/RS256 signatures via cached JWKS, checks iss/aud/exp, and consults a Redis jti revocation blocklist.
Service Mesh (SPIFFE + mTLS)Authenticates every East-West gRPC call via short-lived SPIRE X.509 SVIDs and exchanges user tokens via RFC 8693 downscoping.
Policy Engine & Envelope KMSEvaluates tenant-scoped ABAC/ReBAC policies in OPA before database access, and encrypts sensitive PII using KMS-wrapped DEKs.
  1. Enforce TLS 1.3 at the edge and disable 0-RTT on mutating endpoints to eliminate transport-level replay.
  2. Require Authorization Code + PKCE for user apps, FIDO2 WebAuthn step-up for wire transfers, and private_key_jwt for B2B partner clients.
  3. Pin JWT verification algorithms server-side, validate iss/aud/exp, and bound token lifetime to 10 minutes with a Redis jti revocation set.
  4. Attest internal microservices with SPIFFE/SPIRE and enforce strict mTLS plus Cilium L4 network policies so compromised pods cannot pivot.
  5. Use RFC 8693 Token Exchange for downstream calls so services only receive the minimal scopes and audience they need.
  6. Externalize tenant and object-level authorization into unit-tested OPA policies so IDOR is prevented uniformly at the data boundary.
Transport security, authentication, and authorization are distinct layers; weakness in any single layer compromises the whole chain.
JWT Key Confusion + Compromised Internal Pod

An attacker exploits an SSRF or dependency vulnerability in a non-critical reporting pod and attempts to both forge an admin JWT via alg:none/HS256 confusion and connect directly to the ledger database.

Pinned algorithm allowlists reject the forged JWT at the gateway, Cilium L4 policies drop direct TCP packets from the reporting pod to the ledger DB, and strict mTLS + OPA deny any unauthorized RPCs while alerting SOC telemetry.

The decision framework

01

What is the trust boundary and who is the adversary?

Define whether threats come from public clients, phishing proxies, or compromised internal workloads before selecting controls.

02

How is cryptographic identity established and rotated?

Prefer short-lived asymmetric credentials (SPIFFE SVIDs, JWKS-rotated keys, KMS DEKs) over static long-lived secrets.

03

Are authentication and authorization cleanly separated?

Never accept OIDC ID Tokens as API bearer credentials or confuse coarse RBAC roles with object-level ownership checks.

04

How are tokens constrained against theft and replay?

Combine PKCE, pinned JWT algorithms, strict iss/aud/exp checks, HttpOnly cookies, and bounded jti revocation.

05

What happens when the identity provider or policy engine fails?

Guarantee fail-closed behavior on sensitive mutations while bounding JWKS/policy cache staleness and observability.

Practice / Explain the consequences

Make the trade-off yourself.

A mobile banking app uses OAuth 2.0 Authorization Code flow without PKCE and verifies incoming JWTs at the API gateway without pinning allowed algorithms. Which combined vulnerability posture does this create?

Exercise 01 / oauth-jwt-hardening

Harden an OAuth 2.1 + JWT Boundary.

Design the token issuance, browser/mobile storage, JWKS rotation, and API gateway validation rules for a multi-tenant SaaS platform.

Check your reasoning
  • How does PKCE prevent authorization code interception on mobile and SPA clients?
  • Which JWT claims and algorithms are enforced at the gateway?
  • How do you revoke a compromised user's tokens within 60 seconds without a database lookup on every request?
Exercise 02 / zero-trust-mesh

Eliminate Implicit VPC Trust.

Map out how an internal payment service authenticates callers using SPIFFE/SPIRE mTLS, Cilium L4 policies, and RFC 8693 Token Exchange.

Check your reasoning
  • How is a pod's identity attested before it receives an X.509 SVID?
  • What prevents a compromised frontend pod from calling the ledger service directly?
  • How does RFC 8693 prevent confused-deputy privilege escalation across hops?
Exercise 03 / authz-idor-audit

Migrate from Ad-Hoc RBAC to Policy-as-Code.

Design an OPA or Zanzibar-style authorization model for nested workspaces, folders, and shared documents that prevents IDOR.

Check your reasoning
  • How is tenant and object ownership enforced on every read and write?
  • What happens if the OPA sidecar or relation store is unavailable?
  • How are policy regressions caught in CI before deployment?
The idea to keep with you

Security & Identity

Effective security engineering assumes an active adversary both outside and inside the network. By pairing TLS 1.3 and envelope encryption with SPIFFE mTLS, OAuth 2.1 + PKCE, pinned JWT verification, phishing-resistant WebAuthn, and decoupled RBAC/ABAC policies, systems fail closed and contain every breach.