Web App Auth
Pitfalls
Understand how authentication and authorization can go wrong in modern web applications: from broken sessions to privilege escalation.
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.
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.
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.
The Core Principle of Secure Auth
Every secure authentication system rests on three pillars. Failing any one of them opens the door to exploitation.
The Authentication 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
Pitfall 1: Credential Stuffing
Pitfall 2: Session Hijacking
Pitfall 3: Broken Access Control (IDOR)
Pitfall 4: Weak Password Storage
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:
JWT Token Pitfalls
JSON Web Tokens (JWTs) are popular for stateless authentication, but misconfigurations are common and dangerous.
Common Mistakes
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?