# Authentication Security
> Authentication flaws let an attacker get, or keep, a session as someone else. They usually come from a broken step in the identity flow (federation, second factor, recovery, session handling), not from guessing the password.
## How it works
Every authentication system ends in one artifact: a session (cookie, bearer token or refresh token) that the application trusts to mean "this is user X". Attacks target one of four places:
- **The proof**: the password, OTP, passkey assertion or federated assertion (ID token, SAML response) the application accepts. Typical failures are forgeable assertions, unvalidated claims and brute-forceable codes.
- **The flow**: the multi-step state machine around the proof, with skippable steps, unbound callbacks and race windows. OAuth is a delegation framework reused for login. Its spec is loose and most of its security controls are optional, so implementations get it wrong ([[raw/portswigger.net/portswigger-oauth-2-0-authentication-vulnerabilities-3899|PortSwigger]]).
- **The side doors**: password reset, account recovery, email change, account linking and fallback methods. Each must be as strong as primary login, and often isn't.
- **The resulting session**: theft, fixation, failure to rotate or revoke. A stolen token represents authentication that has already completed, so it bypasses MFA entirely ([[raw/blog.talosintelligence.com/cisco-talos-state-of-the-art-phishing-mfa-bypass-3877|Talos]]).
Track record by protocol ([[raw/guptadeepak.com/sso-protocol-security-critical-vulnerabilities-in-saml-oauth-oidc-jwt-4718|SSO protocol survey]]):
- **SAML** has the worst record by volume and severity, with XML signature wrapping recurring in 2012, 2018 and 2024.
- **OAuth** flaws are mostly logic bugs: redirects, missing `state`, code interception.
- **OIDC** inherits OAuth's flaws and adds ID-token validation failures.
Single-factor authentication for remote or administrative access is now on CISA's list of bad practices ([[raw/therecord.media/cisa-adds-single-factor-authentication-to-its-catalog-of-bad-practices-7036|The Record]]).
## Map of the topic
### Federation and SSO
- [[OAuth 2.0 Vulnerabilities]]: redirect_uri validation, `state`/PKCE binding, code and token leakage, client and scope confusion, dynamic client registration.
- [[OpenID Connect Security]]: ID-token validation, mutable claims and `email` as identifier, account linking, multi-IdP tenancy, cloud OIDC trust policies.
- [[SAML Attacks]]: XML signature wrapping, parser and canonicalization differentials, signature exclusion, audience and replay checks.
- Token formats are covered in [[JSON Web Tokens]] (owned by jwt).
### Factors
- [[MFA Bypass]]: skippable steps, unbound code checks, OTP brute force, non-MFA paths, SMS interception, downgrade.
- [[Passkeys and WebAuthn]]: the limits of origin binding, relying-party validation bugs, synced-passkey theft, fallback.
### Recovery and sessions
- [[Password Reset Vulnerabilities]]: reset poisoning, token leakage and predictability, identity taken from the request, unauthenticated reset paths.
- [[Session Management]]: fixation, hijacking, cookie attributes and prefix bypasses, forgeable stateless sessions, revocation.
### Identity-provider tradecraft
- [[Adversary-in-the-Middle Phishing]]: reverse-proxy kits that relay MFA and keep the session cookie.
- [[Device Code Phishing]]: the OAuth device authorization grant abused on the real IdP domain.
- [[OAuth Consent Phishing]]: malicious and second-party OAuth apps, and compromised integrations, used for persistence that survives password reset.
### Outcome
- [[Account Takeover]]: the end state, and the chains that reach it (anchor changes, normalization, signing oracles, client-side and cache bugs).
## Recent cases
Short pointers; mechanism detail lives on the linked pages.
- **Login SQLi (XBEN-029)**: the username was concatenated into SQL; three distinguishable failure responses (unknown user, wrong password, success) acted as a boolean oracle, and a `UNION` row was accepted as an administrator session. Fix: parameterized queries, real password-hash verification, uniform failure responses ([[raw/b52security.com/a-login-bypassed-by-sql-injection-b-52-on-xben-029-15839|B-52]]). See [[Union-Based SQL Injection]].
- **VMware vCenter (CVE-2026-123890, CVSS 9.8, CWE-288)**: authentication bypass via an alternate path in VMware Directory Service gave unauthenticated Administrator access; exploited in the wild by ARMORY CASTLE from September 2026, distinct from CVE-2026-59309, no workaround (VMSA-2026-0009) ([[raw/rapid7.com/cve-2026-123890-critical-authentication-bypass-in-vmware-vcenter-15978|Rapid7]]).
- **Hard-coded JWT secrets**: BISHENG <3.0.0 (CVE-2026-130840, CWE-321) used a default `jwt_secret`, so an offline-forged HS256 token for `user_id` 1 gave admin ([[raw/vulncheck.com/bisheng-auth-bypass-via-hard-coded-jwt-signing-secret-15965|VulnCheck]]); `@tensei/auth` ≤0.11.5 (CVE-2026-129552, CWE-1394) fell back to `auth-secret-key` when `JWT_SECRET` was unset ([[raw/vulncheck.com/tensei-auth-bypass-via-hard-coded-jwt-secret-15964|VulnCheck]]). See [[Hardcoded Secrets]], [[JWT Secret Cracking]].
- **JWT algorithm confusion**: RS256 verifiers that let the token's `alg` choose HMAC accept tokens signed with the public key from `/jwks.json` as the HMAC secret ([[raw/juangrate.cc/jwt-authentication-bypass-via-algorithm-confusion-15857|lab writeup]]); an unpinned API-gateway check paid $4,500 for guest-to-admin ([[raw/medium.com/how-a-jwt-algorithm-confusion-vulnerability-allowed-a-4-500-authentica-15888|writeup]]). Survey of `none`, key confusion, `kid` traversal/SQLi, `jwk`/`jku` injection and claim checks ([[raw/robinx0.github.io/jwt-algorithm-confusion-none-hs256-rs256-mix-ups-and-kid-injection-15974|robinx0]]). See [[JWT Algorithm Confusion]], [[JWT Header Injection]], [[JWT None Algorithm]].
- **Enumeration plus weak signing key**: login timing and reset-response differences, an HS256 secret cracked to `intel`, and sequential IDs chained to ATO ([[raw/infosecwriteups.com/intel-inside-how-a-cracked-jwt-key-led-to-full-account-takeover-15877|writeup]]). See [[Account Takeover]].
- **GraphQL alias brute force**: a rate limiter counting HTTP requests let one request carry 100 aliased `login` mutations, each returning `success` ([[raw/logicbreaker.sh/bypassing-graphql-brute-force-protections-15818|writeup]]). See [[GraphQL Batching Attacks]].
- **Federated linking**: Vikunja (CVE-2026-134284) and Better Auth (CVE-2026-134312) linked SSO logins to accounts via unverified emails ([[raw/github.com/vikunja-account-takeover-vulnerability-15982|Vikunja]], [[raw/github.com/better-auth-oauth-signature-issue-high-15981|Better Auth]]); Seamless Auth's signed `state` was not browser-bound ([[raw/seamlessauth.com/we-wrote-an-rfc-9700-matrix-and-it-found-a-bug-oauth-state-binding-15863|Seamless Auth]]).
- **Recovery**: a reset token stayed valid after use ([[raw/medium.com/p2-password-reset-token-not-invalidated-after-successful-password-chan-15885|writeup]]); passkey recovery needs its own threat model ([[raw/medium.com/passkey-enrollment-is-easy-to-celebrate-recovery-is-the-product-15980|Radar Makers]]).
- **Client side**: a `postMessage` XSS plus a no-old-password "set password" flow for Google/Apple accounts gave Chess.com ATO ([[raw/xenops.ae/the-last-writer-wins-chess-com-account-takeover-via-postmessage-xss-15815|XENOPS]]).
## Testing quick start
1. Map every path that issues a session: password login, each SSO/IdP, magic links, reset, MFA enrollment and recovery, mobile and legacy APIs, device flows, remember-me. The weakest path sets the security level.
2. For each multi-step flow, confirm that later steps verify earlier ones happened for *this* user in *this* browser.
3. For federated login, find which claim keys the account (`iss`+`sub` vs `email`), and how the app validates signature, audience and binding (`state`, `nonce`, `InResponseTo`).
4. Check rate limiting on every guessable secret (password, OTP, reset code, backup code) across concurrency, IP rotation, batching (including GraphQL aliases) and alternate endpoints. The limit must count authentication attempts, not HTTP requests ([[raw/logicbreaker.sh/bypassing-graphql-brute-force-protections-15818|writeup]]). Compare status, body and timing for unknown vs known accounts ([[raw/infosecwriteups.com/intel-inside-how-a-cracked-jwt-key-led-to-full-account-takeover-15877|Intel]]).
5. Check the session lifecycle: rotation at login and privilege change, and revocation on logout, password change and reset.
6. Check account-anchor changes (email, phone, MFA, linked identities): re-authentication, CSRF protection, notification.
## Defenses (cross-cutting)
- MFA is the primary control against credential stuffing and password spraying. Add risk-based triggers, throttling and breached-password checks ([[raw/cheatsheetseries.owasp.org/owasp-credential-stuffing-prevention-cheat-sheet-4079|OWASP Credential Stuffing]]).
- Require re-authentication for sensitive changes and after risk events such as recovery or a new device. Use generic responses on login, recovery and registration ([[raw/cheatsheetseries.owasp.org/owasp-authentication-cheat-sheet-3897|OWASP Authentication]]).
- Session IDs need at least 64 bits of entropy, rotation on every privilege change, and idle plus absolute timeouts ([[raw/cheatsheetseries.owasp.org/owasp-session-management-cheat-sheet-3896|OWASP Session Management]]).
- Prefer phishing-resistant, origin-bound credentials (FIDO2/passkeys), and remove weaker fallbacks for users who have them ([[raw/fidoalliance.org/fido-alliance-passkeys-overview-3880|FIDO Alliance]], [[raw/blog.talosintelligence.com/cisco-talos-state-of-the-art-phishing-mfa-bypass-3877|Talos]]).
- Pin the token verification algorithm and key per issuer or `kid`; never let the token's header choose them. Load signing secrets from configuration with no default fallback, and fail closed when unset ([[raw/robinx0.github.io/jwt-algorithm-confusion-none-hs256-rs256-mix-ups-and-kid-injection-15974|robinx0]], [[raw/vulncheck.com/tensei-auth-bypass-via-hard-coded-jwt-secret-15964|Tensei]]).
- Enforce the second factor server-side on every path ([[raw/portswigger.net/vulnerabilities-in-multi-factor-authentication-portswigger-4529|PortSwigger MFA]]).
## Related
- [[Authorization Security]]: what happens after identity is established.
- [[JSON Web Tokens]] · [[Cross-Site Request Forgery]] · [[Login CSRF]] · [[API Security]] · [[Vulnerability Chaining]] · [[Bug Bounty Hunting]]
## Sources
- [[raw/cheatsheetseries.owasp.org/owasp-authentication-cheat-sheet-3897|OWASP Authentication Cheat Sheet]]
- [[raw/cheatsheetseries.owasp.org/owasp-session-management-cheat-sheet-3896|OWASP Session Management Cheat Sheet]]
- [[raw/cheatsheetseries.owasp.org/owasp-credential-stuffing-prevention-cheat-sheet-4079|OWASP Credential Stuffing Prevention Cheat Sheet]]
- [[raw/guptadeepak.com/sso-protocol-security-critical-vulnerabilities-in-saml-oauth-oidc-jwt-4718|SSO Protocol Security: Critical Vulnerabilities in SAML, OAuth, OIDC, JWT (2025)]]
- [[raw/portswigger.net/portswigger-oauth-2-0-authentication-vulnerabilities-3899|PortSwigger: OAuth 2.0 authentication vulnerabilities]]
- [[raw/blog.talosintelligence.com/cisco-talos-state-of-the-art-phishing-mfa-bypass-3877|Cisco Talos: State-of-the-art phishing — MFA bypass]]
- [[raw/fidoalliance.org/fido-alliance-passkeys-overview-3880|FIDO Alliance: Passkeys overview]]
- [[raw/portswigger.net/vulnerabilities-in-multi-factor-authentication-portswigger-4529|Vulnerabilities in multi-factor authentication (PortSwigger)]]
- [[raw/therecord.media/cisa-adds-single-factor-authentication-to-its-catalog-of-bad-practices-7036|CISA adds single-factor authentication to its catalog of 'Bad Practices']]
- [[raw/b52security.com/a-login-bypassed-by-sql-injection-b-52-on-xben-029-15839|A login bypassed by SQL injection: B-52 on XBEN-029]]
- [[raw/rapid7.com/cve-2026-123890-critical-authentication-bypass-in-vmware-vcenter-15978|CVE-2026-123890: Critical Authentication Bypass in VMware vCenter]]
- [[raw/vulncheck.com/bisheng-auth-bypass-via-hard-coded-jwt-signing-secret-15965|BISHENG auth bypass via hard-coded JWT signing secret]]
- [[raw/vulncheck.com/tensei-auth-bypass-via-hard-coded-jwt-secret-15964|Tensei auth bypass via hard-coded JWT secret]]
- [[raw/juangrate.cc/jwt-authentication-bypass-via-algorithm-confusion-15857|JWT authentication bypass via algorithm confusion]]
- [[raw/medium.com/how-a-jwt-algorithm-confusion-vulnerability-allowed-a-4-500-authentica-15888|How a JWT Algorithm Confusion Vulnerability Allowed a $4,500 Authentication Bypass]]
- [[raw/robinx0.github.io/jwt-algorithm-confusion-none-hs256-rs256-mix-ups-and-kid-injection-15974|JWT algorithm confusion: none, HS256/RS256 mix-ups, and kid injection]]
- [[raw/infosecwriteups.com/intel-inside-how-a-cracked-jwt-key-led-to-full-account-takeover-15877|Intel Inside: How a Cracked JWT Key led to Full Account Takeover]]
- [[raw/logicbreaker.sh/bypassing-graphql-brute-force-protections-15818|Bypassing GraphQL brute force protections]]
- [[raw/github.com/vikunja-account-takeover-vulnerability-15982|Vikunja account takeover vulnerability]]
- [[raw/github.com/better-auth-oauth-signature-issue-high-15981|Better Auth OAuth signature issue (high)]]
- [[raw/seamlessauth.com/we-wrote-an-rfc-9700-matrix-and-it-found-a-bug-oauth-state-binding-15863|We wrote an RFC 9700 matrix and it found a bug (OAuth state binding)]]
- [[raw/medium.com/p2-password-reset-token-not-invalidated-after-successful-password-chan-15885|P2 Password Reset Token Not Invalidated After Successful Password Change]]
- [[raw/medium.com/passkey-enrollment-is-easy-to-celebrate-recovery-is-the-product-15980|Passkey Enrollment Is Easy to Celebrate. Recovery Is the Product.]]
- [[raw/xenops.ae/the-last-writer-wins-chess-com-account-takeover-via-postmessage-xss-15815|The Last Writer Wins: Chess.com account takeover via postMessage XSS]]