01 / 20

Web App Auth
Pitfalls

Understand how authentication and authorization can go wrong in modern web applications: from broken sessions to privilege escalation.

Cyber Security

What is Authentication?

Authentication is the process of verifying who you are. When you log in with a username and password, the server checks your credentials against stored records to confirm your identity.

User Credentials Server Verify Database

What is Authorization?

Authorization determines what you can do after your identity is confirmed. It checks permissions, roles, and access levels to decide which resources you may access.

✓ Authenticated Authorization Policy Allowed Denied

Why Auth Pitfalls Matter

Broken authentication and authorization are consistently ranked among the top web application vulnerabilities by OWASP. Real-world breaches cost billions of dollars annually.

Data Breaches
Attackers access private user data: emails, passwords, financial records.
Account Takeover
Hijacked sessions let attackers impersonate legitimate users.
Privilege Escalation
A normal user gains admin powers through authorization flaws.

The Core Principle of Secure Auth

Every secure authentication system rests on three pillars. Failing any one of them opens the door to exploitation.

Secure Auth Verify Identity (Authentication) Enforce Access (Authorization) Protect Session

The Authentication Flow

1. User Sends Credentials 2. Server Validates 3. Issue Session Token 4. Token Sent With Each Request 5. Verify Token + Authorize Serve Resource Pitfalls lurk at every step of this flow

Authentication vs Authorization

Authentication Authorization
Question Who are you? What can you do?
Happens Before authorization After authentication
Mechanism Passwords, tokens, biometrics Roles, policies, ACLs
Failure Result 401 Unauthorized 403 Forbidden
Pitfall Example Weak passwords accepted User accesses admin panel

How to Secure Your Auth

1
Hash passwords with bcrypt or Argon2. Never store plaintext or reversible encryption.
2
Enforce strong session tokens. Use cryptographically random, long tokens. Set HttpOnly, Secure, and SameSite flags on cookies.
3
Validate permissions server-side. Never rely on client-side checks or hidden form fields for access control.
4
Implement rate limiting. Prevent brute-force attacks by limiting login attempts per IP and per account.
5
Require multi-factor authentication (MFA). A second factor dramatically reduces the risk of stolen credentials.

Pitfall 1: Credential Stuffing

✕ Attacker Leaked DB Thousands of attempts Login Page 1 match! Account Compromised No Rate Limiting!

Pitfall 2: Session Hijacking

U User SessionID=abc123 Server ✕ Attacker Intercepts cookie (HTTP) Replays stolen token Server thinks it is the User!

Pitfall 3: Broken Access Control (IDOR)

A User A /profile?id=101 Server Returns A's Data A Same User A /profile?id=102 Server Returns User B's Data! No ownership check on server

Pitfall 4: Weak Password Storage

✕ Plaintext password123 qwerty456 ✕ Unsalted MD5 482c811da5d5b... d8578edf8458c... ✓ bcrypt + Salt $2b$12$Rz8kL... $2b$12$Xs9pQ... Instantly readable Cracked in seconds Computationally hard ★★★ Maximum Risk ★★ High Risk ★ Low Risk

Pitfall 5: Privilege Escalation

Privilege escalation occurs when a user gains access to functionality or data beyond their intended permission level. There are two types:

Vertical
A regular user gains admin-level access. Example: changing role=user to role=admin in a cookie or request body.
Horizontal
A user accesses another user's resources at the same privilege level. Example: IDOR (changing user IDs in API calls).

JWT Token Pitfalls

JSON Web Tokens (JWTs) are popular for stateless authentication, but misconfigurations are common and dangerous.

1
Algorithm "none" attack: The server accepts tokens with alg: "none", allowing forged tokens with no signature.
2
Weak signing secrets: Short or guessable secrets (e.g., "secret123") can be brute-forced offline.
3
No expiration: Tokens without an exp claim remain valid forever if stolen.
4
Sensitive data in payload: JWTs are Base64-encoded (not encrypted). Storing passwords or PII in the payload exposes them.

Common Mistakes

✕ Client-Side Auth Checks
Hiding admin buttons with JavaScript does not prevent access. Attackers can call API endpoints directly.
✕ Predictable Session IDs
Sequential or timestamp-based tokens let attackers guess valid sessions. Use CSPRNG-generated tokens.
✕ No Session Invalidation
If you never expire sessions or allow logout to destroy tokens, stolen sessions persist indefinitely.

Auth Pitfalls Summary

Pitfall Risk Defense
Credential Stuffing Account takeover Rate limiting + MFA
Session Hijacking Impersonation HTTPS + Secure cookies
IDOR Data leakage Server-side ownership checks
Weak Password Storage Mass credential exposure bcrypt/Argon2 + salts
Privilege Escalation Unauthorized admin access Server-side RBAC
JWT Misconfig Token forgery Strong secrets + expiry

Question 1 of 5

A web app returns a 401 Unauthorized error. Which process has most likely failed?

Question 2 of 5

An attacker changes /api/orders?userId=42 to /api/orders?userId=43 and sees another user's orders. What vulnerability is this?

Question 3 of 5

Which cookie flag prevents JavaScript from accessing a session cookie, helping to mitigate XSS-based session theft?

Question 4 of 5

A developer stores user roles in a JWT payload and checks them only in the front-end JavaScript. Why is this insecure?

Question 5 of 5

Which password storage method provides the strongest protection against brute-force attacks after a database breach?