PAITS Cheat Sheet Cybersecurity Intermediate Updated 2026-10-23

Zero-Trust Web Security: OAuth 2.1, OIDC, JWT & Nonce CSP Hardening

Authorization Code + PKCE flow, JWT signature verification, Strict-Dynamic CSP nonces, and CSRF/XSS mitigation.

Executive Summary: Enterprise application security reference covering OAuth 2.1 PKCE flows, Firebase/OIDC session cookies, cryptographic per-request Content Security Policy (CSP) nonces, and SSRF defenses.

Key Equations & Invariants

OAuth 2.1 PKCE S256 Code Challenge
\text{code\_challenge} = \text{BASE64URL}\bigl(\text{SHA256}(\text{code\_verifier})\bigr)

Binds the authorization code to the initiating client to prevent authorization code interception.

1. Token Storage & Session Architecture Comparison

Prefer `HttpOnly; Secure; SameSite=Lax` session cookies paired with short-lived in-memory bearer tokens to defend against both XSS token exfiltration and cross-site request forgery.

Storage MechanismXSS Token Theft RiskCSRF RiskRecommended Mitigation
localStorage / sessionStorageHigh (readable by any JS)NoneNever store long-lived refresh tokens here
HttpOnly + Secure CookieLow (invisible to document.cookie)MediumPair with SameSite=Lax/Strict + Origin check
In-Memory JS Closure + HttpOnly RefreshMinimalLowGold-standard SPA + SSR hybrid pattern

Common Production & Interview Pitfalls

Frequently Asked Questions

Q: What is the difference between OAuth 2.0 and OpenID Connect (OIDC)?

OAuth 2.0 is a delegated authorization framework (granting an Access Token for APIs), whereas OIDC is an identity layer built on top of OAuth 2.0 that issues a signed JWT ID Token proving who the user is.