$ whoami && id && curl -I https://api.internal

Identity, Access & Web Security

// end-to-end trust boundaries & attack surface

System overview

Identity, access control, and web/LLM attack boundariesFour stages across the top: Client/Browser, Identity Provider and Secrets, Zero Trust Policy Enforcement, and Application/DB/LLM. Numbered arrows show authentication, token presentation, authorized execution, and secret delivery. Below, a dashed attack-surface box maps XSS, CSRF, CORS, JWT/Session flaws, IDOR, SQLi, SSRF, and Prompt Injection directly onto the boundary each attack targets.1. CLIENT2. IDENTITY & SECRETS3. ZERO TRUST PEP/PDP4. APP, DATA & LLMBrowser / ClientCookie vs Bearer JWTSame-Origin PolicyCORS enforcementIdP & SecretsAuthN · KDF+Salt+PepperMFA (FIDO2) · SSOOAuth2 / OIDC · KMSPolicy / GatewayVerify every requestRBAC / ABAC · Least PrivCloud IAM STS tokensApp, DB & LLMServer Session StoreSQL DB · Internal VPCLLM + Tool CallingAuthN1Request + Cookie / Bearer JWT2AuthZ3JWKS4STS + rotated secretsXSSJS runssame-originCSRFrides ambientcookieCORSweak ACAOleaks bodyJWT / Sessionalg confusionfixationIDORmissingobject AuthZSQLidata breaksSQL grammarSSRFhits IMDS/ internalPrompt Inj.data hijacksLLM toolsATTACK BOUNDARIES — EACH EXPLOITS A SPECIFIC TRUST ASSUMPTION ABOVESolid arrows = intended trust flow (1 AuthN → 2 Token/Cookie → 3 AuthZ → 4 Keys/Secrets). Dashed = attack vector.Client / UntrustedIdentity / CryptoPolicy / AuthZSecrets / KeysProtected ResourceDirect BreakCross-Boundary Abuse

// who are you, and how do you prove it?

Authentication, Passwords & MFA

Authentication (AuthN)

Verifies who the principal is (password, FIDO2, mTLS, OIDC id_token). Failure returns HTTP 401 Unauthorized.

Authorization (AuthZ)

Verifies what an authenticated principal may do on a specific resource (RBAC/ABAC, OAuth2 access_token). Failure returns HTTP 403 Forbidden.

Password storage pipeline: salt, memory-hard KDF, and pepperFive stages: plaintext password normalized as UTF-8, combined with a per-user 128-bit random salt stored in the DB, stretched with Argon2id, keyed with a secret pepper from KMS/HSM via HMAC or AEAD, and stored for constant-time verification.1. PlaintextUTF-8 bytescheck min len ≥8–15no silent truncation2. + Saltper-user CSPRNG≥128-bit randomstored in DB3. Argon2idm=19MiB, t=2, p=1RAM + CPU hardblocks GPU/ASIC4. + PepperHMAC / AES-GCMkey in HSM/KMSnever in DB5. Stored HashPHC string + keyIdconstant-time eqrehash on logindefeats rainbow tablesslows offline brute forcedefeats DB-only SQLi dumpstops timing side-channel
Sources: Cloudflare AuthN vs AuthZ, OWASP Password Storage, Cloudflare MFA.
PrimitiveMechanicStopsGotcha / Limit
SaltPer-user random ≥128-bit value, stored in plaintext alongside the hashPrecomputed rainbow tables and detecting identical passwords across usersDoes NOT slow offline cracking of a single dumped hash
PepperApp-wide secret key (HMAC-SHA256 or AEAD) stored in HSM/KMS, never in the DBOffline cracking after a DB-only leak (SQLi dump, stolen backup)Compromised if attacker gets both DB and app/KMS secret; rotation requires key versioning
Argon2id (preferred)Memory-hard KDF (OWASP min: m=19 MiB, t=2, p=1)GPU/ASIC brute force by requiring RAM bandwidth + side-channel resistance (hybrid Argon2i/d)Tune memory/iterations per hardware budget; verify with constant-time compare
bcrypt / PBKDF2Legacy KDFs (bcrypt cost ≥10; PBKDF2-HMAC-SHA256 ≥600k iters)CPU brute force (bcrypt) or FIPS compliance (PBKDF2)bcrypt silently truncates at 72 bytes and stops at NUL; PBKDF2 is weak against GPUs
MFA FactorMechanismPhishingHard Reality
FIDO2 / WebAuthn (Passkeys)Hardware/platform public-key signature bound to TLS origin (rpId)Phishing-resistantBrowser enforces origin match; AitM reverse-proxy phishing fails cryptographically
TOTP / HOTP (Authenticator)Shared secret + time step (30s) or counter → 6-digit HMAC-SHA1Phishable (AitM)Real-time phishing proxy relays the code; DB leak exposes shared seeds unless encrypted
Push notificationOut-of-band approve tap on enrolled mobile deviceMFA fatigueRequires number matching + geo/app context to resist prompt bombing
SMS / Voice OTPCode sent over PSTN/SS7 cellular networkWeakestVulnerable to SIM swap, SS7 interception, and social engineering of carriers

// tokens, delegation & single sign-on

Sessions, OAuth 2.0, OIDC, JWT & SSO

OAuth 2.0 Authorization Code + PKCE + OIDC + SSO workflowSix steps across four actors (Browser, Client App, IdP/Auth Server, Resource API): 1 Browser sends code_challenge, state, and nonce to /authorize; 2 IdP checks SSO session and MFA and redirects back with an authorization code; 3 Browser delivers code to Client; 4 Client exchanges code plus code_verifier at /token over back-channel; 5 IdP returns id_token JWT, access_token, and refresh_token; 6 Client calls Resource API with Bearer access_token verified against JWKS.BrowserUser-AgentClient AppRelying Party (RP)IdP / AuthZSSO + OIDC + OAuth2Resource APIverifies JWT via JWKSGET /authorize?code_challenge=S256(verifier)&state&nonce1SSO cookie / MFA OK → 302 redirect ?code=XYZ&state2deliver code + verify state (anti-CSRF)3POST /token (code + code_verifier + secret)4id_token (AuthN) + access_token + refresh5Authorization: Bearer <access_token> (check sig, aud, iss, exp)6
PKCE binds step 1 to step 4 so a stolen code is useless without code_verifier. OAuth 2.0 delegates API access (access_token); OIDC adds AuthN on top (id_token JWT + nonce); SSO is the shared IdP session in step 2. Implicit grant is deprecated. Sources: OAuth 2.0, OIDC, JWT, SSO, OWASP Session Management.
AxisServer-side Session (Cookie)JWT (Stateless Token)
State & RevocationOpaque ≥128-bit CSPRNG ID; server store (Redis/DB) → instant logout & revocationStateless signed token (JWS) → cannot revoke before exp without a denylist (which re-adds state)
ConfidentialityID reveals nothing; payload stays server-sideJWS is Base64url-encoded plaintext (anyone can decode); encrypt with JWE if claims are sensitive
Key PitfallsSession fixation (must regenerate ID on login/privilege change); missing idle + absolute timeoutsalg: none, RS256→HS256 key confusion, kid path/SQL injection, skipping aud/iss/exp/nbf checks
Browser StorageCookie with Secure; HttpOnly; SameSite=Lax (or Strict) + __Host- prefixlocalStorage is readable by any XSS; prefer BFF pattern (HttpOnly cookie) + short-lived access tokens + refresh rotation with reuse detection

// least privilege & zero standing secrets

Access Control, Zero Trust, Cloud IAM & Secrets

Zero Trust, Cloud IAM STS, and Secrets Management flowsThree lanes: Zero Trust evaluates principal and device posture at PEP and PDP with Explicit Deny over Allow; Cloud IAM exchanges workload OIDC identity via STS AssumeRole for short-lived scoped credentials; Secrets Management derives dynamic rotated secrets from a KMS/HSM root and injects them into app memory only.Zero Trustper-request verifyPrincipal + Deviceuser/workload IDdevice posturePEP (Proxy / API)terminates mTLSpauses requestPDP (Policy Engine)RBAC / ABAC rulescontext & riskDecisionExplicit Deny > Allowleast-priv scopeCloud IAMno static keysOIDC / Pod Identitysigned workload JWTno stored access keySTS AssumeRolevalidates trust policychecks boundariesShort-lived Creds15m–1h TTLauto-rotatedScoped Cloud APIexact ARN + actionCloudTrail auditedSecretsdynamic & rotatedKMS / HSM Rootenvelope key (KEK)hardware-backedSecrets Managerencrypted at restaudit + lease TTLPolicy-Gated Leasedual-key rotationzero downtimeApp Memory Onlyinjected at runtimenever in Git / logs
Sources: RBAC, Least Privilege, Zero Trust, AWS IAM Best Practices, OWASP Secrets Management.
ConceptCore RuleHard Detail
RBACPermissions bound to roles (`admin`, `auditor`), users assigned to rolesSimple to audit, but suffers role explosion for fine-grained/tenant-scoped rules
ABAC / ReBACDecisions from attributes (owner, env, risk) or object relationship graphs (Zanzibar)Solves object-level checks (IDOR) without role explosion; harder to audit statically
Least PrivilegeGrant exact actions on exact resource ARNs/IDs for minimal duration (JIT)AWS evaluation order: Explicit Deny > SCP/Boundary > Identity/Resource Allow > Implicit Deny
Zero TrustNever trust network location (LAN/VPN ≠ trusted); verify identity + device + context per requestEnforce at PEP/PDP with mTLS, micro-segmentation, and short-lived credentials
Cloud IAM & SecretsZero long-lived keys: use OIDC federation / Pod Identity / STS; dynamic secrets from KMS/VaultNever bake secrets into Git, images, or env dumps; support zero-downtime dual-key rotation

// where boundaries break

Web & LLM Attack Primitives

Browser security boundary: CSRF vs CORS vs XSSLeft: evil.com tab. Middle: Browser Same-Origin Policy wall. Right: bank.com origin and server. CSRF sends a cross-site request with ambient cookies but cannot read the response. Misconfigured CORS lets evil.com read the response. XSS runs JavaScript inside bank.com itself, bypassing SOP, CORS, and CSRF tokens.evil.comattacker pageruns attacker JSSOP blocks readingbank.com responsesBROWSER SAME-ORIGIN POLICY (scheme + host + port)bank.comvictim origin + serverholds Cookie / DOMXSS runs HERE(bypasses SOP + CSRF)CSRF: cross-site POST + ambient Cookie (write-only, blind)CORS bug: ACAO: evil.com + ACAC: true → leaks responseXSS: injects <script> into bank.com → full same-origin takeover
Sources: SQLi, XSS, CSRF, CORS, SSRF, IDOR, OWASP LLM01 Prompt Injection.
AttackBroken BoundaryHard Edge CasesReal Fix
SQL InjectionData crosses into SQL grammarSecond-order SQLi (stored payload runs later); ORDER BY/table identifiers cannot be bound; blind boolean/time extractionParameterized queries (prepared statements) everywhere + strict static allowlist for dynamic identifiers
XSSUntrusted data parsed as DOM/JSReflected, Stored, DOM-based (innerHTML, eval), and mXSS (browser parser mutates sanitized HTML into executable JS)Context-aware output encoding + Trusted Types + strict nonce-based CSP + HttpOnly cookies (limits theft, not actions)
CSRFCross-site request rides ambient cookiesSameSite=Lax still sends cookies on top-level GETs (never mutate on GET) and does not block same-site subdomains; text/plain skips CORS preflightPer-session synchronizer token (or signed double-submit) + SameSite + Origin/Sec-Fetch-Site validation
CORS MisconfigServer relaxes Same-Origin Policy read blockACAO: * cannot pair with ACAC: true, so buggy servers reflect Origin, trust null (sandboxed iframe), or fail regex (evil-bank.com)Exact static allowlist of trusted origins; never reflect Origin or allow null with Access-Control-Allow-Credentials: true
SSRFServer coerced to make internal requestsCloud metadata 169.254.169.254, DNS rebinding (TOCTOU between check and connect), HTTP 302 to 127.0.0.1, IPv6-mapped ::ffff:127.0.0.1IMDSv2 (PUT + hop-limit=1), network-layer egress allowlist, resolve-and-pin IP before connect, disable redirects
IDOR (BOLA)Missing object-level authorizationSwapping /api/orders/1042 → /api/orders/1043; UUIDs slow guessing but are NOT authorizationBind every data query to the authenticated principal (WHERE id = $1 AND owner_id = $subject)
Prompt InjectionUntrusted data shares LLM instruction streamDirect (user override) and Indirect (poisoned web page, PDF, or email ingested by RAG/agent triggers unintended tool calls or exfiltration)No 100% prompt-only fix: enforce least-privilege tools, isolate data vs control planes, require human approval for state-changing actions