![]() |
| Ethical Hacking |
🛡️ Ethical Hacking — Day 22
Authentication Testing & Session Security Lab
⚠️ LEARNING PURPOSE ONLY: This tutorial is strictly for educational and defensive cybersecurity learning. Perform all practical exercises only against your local OWASP Juice Shop lab, applications you own, or systems for which you have explicit authorization. Never test credentials, sessions, or authentication mechanisms on public websites or accounts without permission.
Welcome to Day 22.
Yesterday we learned the fundamentals of authentication, password hashing, cookies, sessions, MFA, rate limiting, and password-reset security.
Today we'll turn that knowledge into a structured authentication-security assessment.
🎯 Today's Objectives
By the end of Day 22, you should understand how to:
Analyze a login request
Identify authentication parameters
Inspect authentication responses
Analyze session cookies
Understand session lifecycle
Test logout behavior safely
Understand session fixation
Identify authentication errors
Observe rate limiting without attacking accounts
Analyze password-reset design
Understand MFA security
Review authentication code
Use Burp Suite
Perform the same practical work on Linux, Windows and macOS
Write an authentication-security finding
1. Authentication Testing Methodology
Use this workflow:
Permission
↓
Scope
↓
Login Page
↓
Capture Request
↓
Analyze Response
↓
Session Creation
↓
Authenticated Request
↓
Logout
↓
Session Invalidation
↓
Security Review
↓
ReportThe objective is not to break into an account.
The objective is to determine whether the authentication system is implemented securely.
2. Start Your Lab
Linux
docker psWindows PowerShell
docker psmacOS
docker psIf Juice Shop isn't running:
docker start <container-id>Verify:
Linux/macOS
curl -I http://127.0.0.1:3000Windows
curl.exe -I http://127.0.0.1:30003. Start Burp Suite
Open:
Burp Suite
↓
Proxy
↓
Open BrowserNavigate to:
http://127.0.0.1:3000Set the Burp target scope to:
127.0.0.1:3000This prevents accidentally mixing your lab traffic with unrelated websites.
4. Create a Test Account
If your local Juice Shop setup allows registration, create a dedicated lab account.
Use something like:
Email:
day22-test@example.test
Password:
Lab-Only-Password-2026!Do not use your real password.
Keep the credentials only inside your local lab.
5. Capture the Login Request
Log in with your test account.
Then open:
Proxy
↓
HTTP historyFind the login request.
It may look conceptually like:
POST /rest/user/login HTTP/1.1
Host: 127.0.0.1:3000
Content-Type: application/jsonwith a body containing authentication information.
Your application may use a different endpoint, so always analyze the request generated by your installation.
6. Record the Login Request
Create this table:
| Property | Value |
|---|---|
| Method | ___ |
| Endpoint | ___ |
| Content-Type | ___ |
| Authentication fields | ___ |
| HTTPS | Yes/No |
| Response status | ___ |
Never put a real password into a public report.
Use:
<REDACTED>7. Analyze the Response
After successful authentication, inspect:
HTTP responseLook for:
Set-Cookie
Authorization
Token
Session
RedirectFor example:
HTTP/1.1 200 OK
Set-Cookie: ...or:
{
"authentication": {
"token": "..."
}
}Do not copy actual tokens into your notes.
8. Why Tokens Matter
A session token is effectively a temporary credential.
Think:
Password
↓
Authentication
↓
Session Token
↓
Authenticated RequestsTherefore:
A session token should be treated as sensitive as a password.
9. Session Cookie Inspection
Open browser Developer Tools.
For Chromium-based browsers:
Developer Tools
↓
Application
↓
Storage
↓
CookiesInspect your local application's cookies.
Record only:
Cookie name:
Secure:
HttpOnly:
SameSite:
Path:
Domain:
Expiration:Do not record the cookie value.
10. Cookie Security
A sensitive session cookie should generally use:
Secure
HttpOnly
SameSiteSecure
Cookie
↓
HTTPS onlyHttpOnly
Cookie
↓
Not directly readable by normal JavaScriptSameSite
Cookie
↓
Controls certain cross-site request behaviorThese protections are complementary.
11. Capture an Authenticated Request
After login, visit a page that requires authentication.
For example:
Profile
Account
OrdersCapture the request in Burp.
You might see:
GET /some/protected/resource HTTP/1.1
Host: 127.0.0.1:3000
Cookie: ...or a token-based authorization header.
12. Compare Before and After Login
This is a useful authentication test.
Before authentication
GET /protected-resource
↓
401 / 403 / redirectAfter authentication
GET /protected-resource
↓
200 OKThis demonstrates:
Authentication State
↓
Access Decision13. Send the Authenticated Request to Repeater
Right-click:
Send to RepeaterThen send the request.
Record:
Status:
Response length:
Authentication mechanism:Don't modify the token yet.
This is your baseline.
14. Logout Testing
Now log out normally.
Then repeat the previously captured authenticated request.
Observe:
Before logout:
200 OK
After logout:
?A secure application should invalidate the session appropriately.
If the same authenticated session continues to work after logout, investigate further.
15. Logout Security Flow
Secure design:
LOGIN
↓
SESSION CREATED
↓
AUTHENTICATED REQUESTS
↓
LOGOUT
↓
SESSION INVALIDATED
↓
OLD SESSION
↓
REJECTEDThe exact behavior depends on the application's session architecture.
16. Session Invalidation
A common mistake is:
Logout
↓
Delete cookie in browserwhile the server-side session remains valid.
A stronger design is:
Logout
↓
Invalidate server session
↓
Expire/remove client cookieThis reduces the chance that an old session remains usable.
17. Session Fixation
Session fixation is a session-management problem.
Conceptually:
Attacker
↓
Known/controlled session identifier
↓
Victim authenticates
↓
Same session remains authenticatedThe important defense is:
Before authentication
↓
Session ID A
After authentication
↓
Session ID BThe identifier should be regenerated when the user's authentication state changes.
18. Testing Session Regeneration
In your local lab, record the session identifier only as a redacted fingerprint, not the actual value.
For example:
Before login:
Session = [REDACTED-A]
After login:
Session = [REDACTED-B]If the application uses a session cookie and you can safely inspect it:
Before:
A
After:
BA change after authentication is generally desirable.
Don't expose actual session tokens.
19. Authentication Errors
Try an invalid login using your local test account.
For example:
Email:
day22-test@example.test
Password:
Definitely-Wrong-Lab-PasswordObserve the response.
Does it reveal:
User existsversus:
User doesn't exist?
20. Account Enumeration
Consider:
Existing account:
"Incorrect password"
Non-existing account:
"User not found"This can allow someone to determine which accounts exist.
A more consistent response might be:
"Invalid email or password."The exact implementation should balance security, usability, and operational needs.
21. Timing Differences
Applications should also consider whether authentication failures produce substantially different processing behavior depending on whether an account exists.
For example:
Existing user:
200 ms
Non-existing user:
20 msA consistent error message alone doesn't necessarily eliminate all enumeration channels.
However, timing measurements can be noisy and should be interpreted carefully.
For your lab:
Focus on understanding the concept rather than trying to build a large-scale enumeration tool.
22. Rate Limiting
Authentication endpoints should resist excessive automated attempts.
A secure system may implement:
Attempt
↓
Attempt
↓
Attempt
↓
Too many attempts
↓
Slow down / temporary restrictionYou don't need to perform hundreds of attempts.
23. Safe Rate-Limit Test
Use your own local test account.
Make only a small number of intentionally incorrect attempts manually.
For example:
Attempt 1 → wrong password
Attempt 2 → wrong password
Attempt 3 → wrong passwordObserve whether the application:
Returns an error
Slows down
Temporarily restricts attempts
Shows a CAPTCHA
Provides another security responseStop there.
The objective is to understand the control, not to brute-force the account.
24. Why Rate Limiting Matters
Without rate limiting:
Login
↓
Password guess
↓
Password guess
↓
Password guess
↓
Thousands of guessesWith protection:
Login
↓
Few attempts
↓
Rate limit
↓
Attack becomes expensive25. Password Reset Testing
Find the application's:
Forgot Passwordfeature.
Use only your own local test account.
Capture the request.
Record:
Method:
Endpoint:
Response:
Token mechanism:
Expiration:Don't send the reset token anywhere outside your local lab.
26. Secure Password Reset
A secure reset token should be:
Random
Unpredictable
Short-lived
Single-use
Bound to the reset requestConceptually:
Forgot Password
↓
Random Reset Token
↓
Email / Recovery Channel
↓
Reset Password
↓
Token Invalidated27. Password Reset Enumeration
Be careful with responses such as:
"Email sent because this account exists."versus:
"No account exists."A more privacy-preserving response can be:
"If an account exists, reset instructions will be sent."This reduces account enumeration.
28. MFA Security
If your lab application supports MFA, understand:
Password
+
Second Factor
↓
AuthenticatedThe second factor could be:
Authenticator app
Security key
OTP
BiometricMFA makes stolen passwords less useful by requiring another authentication factor.
29. MFA Verification Should Also Be Protected
Don't protect only:
Password loginwhile leaving:
OTP verificationunprotected.
MFA endpoints should also have appropriate:
Rate limiting
Attempt limits
Expiration
Replay protection
Secure recovery30. Authentication Architecture
A secure high-level design:
USER
│
▼
HTTPS LOGIN
│
▼
┌──────────────────┐
│ Authentication │
│ Service │
└────────┬─────────┘
│
Password Verifier
│
▼
User Database
│
▼
MFA / Risk
│
▼
New Session
│
▼
Secure Cookie
│
▼
Authorization Layer
│
┌─────┴─────┐
▼ ▼
ALLOW DENY31. Linux Practical Session
Check Docker
docker psCheck the application
curl -I http://127.0.0.1:3000Verbose headers
curl -v http://127.0.0.1:3000/Through Burp
curl -x http://127.0.0.1:8080 \
http://127.0.0.1:3000/32. Linux — Inspect Response Cookies
For your local application:
curl -i http://127.0.0.1:3000/Look for:
Set-CookieDon't copy session values into your report.
You can redact them:
Set-Cookie: session=[REDACTED]33. Windows Practical Session
Docker
docker psHeaders
curl.exe -I http://127.0.0.1:3000Verbose
curl.exe -v http://127.0.0.1:3000/Through Burp
curl.exe -x http://127.0.0.1:8080 `
http://127.0.0.1:3000/34. Windows — Cookie Header
curl.exe -i http://127.0.0.1:3000/Look for:
Set-CookieRecord only attributes.
Never publish:
session=actual-secret-value35. macOS Practical Session
docker psCheck headers:
curl -I http://127.0.0.1:3000Verbose:
curl -v http://127.0.0.1:3000/Through Burp:
curl -x http://127.0.0.1:8080 \
http://127.0.0.1:3000/36. macOS — Cookie Analysis
curl -i http://127.0.0.1:3000/Look for:
Set-CookieDocument:
Secure:
HttpOnly:
SameSite:
Path:Keep the actual value redacted.
37. Burp Repeater Workflow
Your authentication-testing workflow should be:
Login
↓
Capture
↓
Send to Repeater
↓
Record baseline
↓
Logout
↓
Replay
↓
CompareThis is much safer than automated attack tooling.
38. Burp HTTP History
Review:
Proxy
↓
HTTP historyLook for:
Login
Logout
Profile
Account
Password reset
MFA
Protected APICreate a small map:
/login
↓
/profile
↓
/account
↓
/logoutThis helps you understand the authentication lifecycle.
39. Authentication Request Map
Create:
┌─────────────┐
│ Login │
└──────┬──────┘
↓
┌─────────────┐
│ Session │
└──────┬──────┘
↓
┌─────────────┐
│ Protected │
│ Resource │
└──────┬──────┘
↓
┌─────────────┐
│ Logout │
└──────┬──────┘
↓
┌─────────────┐
│ Session │
│ Invalidated │
└─────────────┘40. Authentication Code Review
When reviewing your own application, search for:
login
authenticate
password
session
cookie
logout
reset
token
MFAThen ask:
Is the password hashed?
Is the session regenerated?
Are cookies protected?
Is rate limiting present?
Does logout invalidate the session?
Are reset tokens random?
Are reset tokens single-use?
Is MFA protected?41. Laravel Review
Laravel's authentication ecosystem provides mature mechanisms.
For passwords:
Hash::make($password);Verification:
Hash::check($password, $hash);Don't manually implement:
md5()
sha1()
sha256()for password storage.
42. Laravel Session
After authentication, use Laravel's built-in authentication/session mechanisms rather than creating your own session-token system.
For sensitive authentication changes, ensure session regeneration is handled appropriately.
Example:
$request->session()->regenerate();The exact implementation should follow the authentication flow and current Laravel guidance.
43. Spring Security
For Spring Boot applications, prefer Spring Security rather than manually building:
Login
Password verification
Session handling
CSRF
Authentication filtersSpring Security provides established security components.
Use:
PasswordEncoderfor password verification/storage.
44. Secure Authentication Code Principle
Avoid:
Custom crypto
Custom session IDs
Custom password hashing
Custom authentication protocolPrefer:
Framework
↓
Mature security library
↓
Secure defaults
↓
Configuration45. Common Authentication Vulnerabilities
During a security review, watch for:
☐ Plaintext passwords
☐ Weak password hashing
☐ No rate limiting
☐ Account enumeration
☐ Weak session IDs
☐ Session fixation
☐ Session not invalidated on logout
☐ Missing Secure flag
☐ Missing HttpOnly
☐ Weak SameSite configuration
☐ Session IDs in URLs
☐ Weak password reset
☐ Missing MFA for sensitive accounts
☐ Poor authorization checks46. Authentication Testing vs Credential Attacking
These are not the same.
Authentication testing
Inspect
Analyze
Review
Capture
Compare
DocumentCredential attack
Thousands of guesses
Password spraying
Credential stuffing
Automated login attemptsToday's training focuses on the first category.
47. Day 22 Main Practical Challenge
Perform a complete authentication review of your local Juice Shop account.
Step 1
Login.
Step 2
Capture the login request.
Step 3
Record:
Method
Endpoint
Content-Type
ResponseStep 4
Inspect the authentication response.
Step 5
Inspect the session cookie/token.
Step 6
Access a protected page.
Step 7
Capture the authenticated request.
Step 8
Logout.
Step 9
Replay the old authenticated request.
Step 10
Observe whether the session remains valid.
Step 11
Perform a small number of invalid login attempts.
Step 12
Observe the application's rate-limit behavior.
Step 13
Inspect the password-reset workflow if available.
📊 Day 22 Lab Report
╔══════════════════════════════════════╗
║ DAY 22 — AUTHENTICATION REVIEW ║
╚══════════════════════════════════════╝
Target:
127.0.0.1:3000
Login Endpoint:
________________________
HTTP Method:
________________________
Content-Type:
________________________
Successful Status:
________________________
Session Mechanism:
Cookie / Token / Other
Cookie Name:
________________________
Secure:
Yes / No / Unknown
HttpOnly:
Yes / No / Unknown
SameSite:
________________________
Protected Resource:
________________________
Before Login:
________________________
After Login:
________________________
Session Regenerated:
Yes / No / Unknown
Logout Performed:
Yes / No
Old Session After Logout:
Valid / Invalid / Unknown
Rate Limiting:
Observed / Not Observed / Unknown
Password Reset:
________________________
MFA:
________________________
Potential Finding:
________________________
Risk:
Low / Medium / High / Critical / Informational
Recommendation:
________________________📝 Day 22 Assignment
Answer these:
What is authentication testing?
Why should authentication requests be captured?
What information should you record from a login request?
Why are session tokens sensitive?
What are
Secure,HttpOnly, andSameSite?What is session fixation?
Why should sessions be regenerated after authentication?
Why should logout invalidate the server-side session?
What is account enumeration?
Why should authentication responses be carefully designed?
What is rate limiting?
Why should MFA verification also be protected?
What makes a password-reset token secure?
Why shouldn't session IDs appear in URLs?
Why should you avoid custom authentication implementations?
Why shouldn't you perform large numbers of password guesses during a normal security review?
What is the difference between authentication and authorization?
Why should authenticated requests be tested after logout?
Why should session values be redacted from security reports?
What should a professional authentication-security report contain?
🏆 Day 22 Challenge
Create this complete security diagram:
USER
│
▼
┌─────────────┐
│ LOGIN │
└──────┬──────┘
│
▼
PASSWORD HASHING
│
▼
MFA / RISK
│
▼
SESSION CREATED
│
▼
SECURE COOKIE
│
▼
┌──────────────────┐
│ AUTHENTICATED │
│ REQUEST │
└────────┬─────────┘
│
▼
AUTHORIZATION
│
┌─────┴─────┐
▼ ▼
ALLOW DENY
│
▼
RESOURCE
│
▼
LOGOUT
│
▼
SESSION INVALIDATEDAdd:
Rate Limiting
Password Reset
Audit Logging
Session Timeout🔐 Day 22 Golden Rules
Rule 1
Treat session tokens as credentials.
Rule 2
Authentication is only one part of application security.
Rule 3
A secure logout must invalidate the authenticated state.
Rule 4
Use established authentication frameworks instead of inventing your own.
Rule 5
Test safely with your own local account. Don't turn a security review into a credential attack.
📚 Day 22 Summary
Today you practiced:
Login request analysis
Authentication response analysis
Session cookies
Cookie security attributes
Authenticated requests
Logout testing
Session invalidation
Session fixation
Account enumeration
Rate limiting
Password reset
MFA
Burp Suite
Browser Developer Tools
Laravel authentication concepts
Spring Security concepts
Linux commands
Windows PowerShell commands
macOS commands
Authentication reporting
🔑 Most Important Lesson
LOGIN
↓
AUTHENTICATE
↓
CREATE SECURE SESSION
↓
AUTHORIZE EVERY REQUEST
↓
LOGOUT
↓
INVALIDATE SESSIONAuthentication security is not just about protecting the password.
It is about protecting the entire identity and session lifecycle.
🔐 LEARN → PRACTICE IN YOUR LAB → ANALYZE → DOCUMENT → SECURE
🔜 Day 23 — Broken Access Control & IDOR
Tomorrow we'll move to another critical web-security category:
Authentication vs authorization
Access-control models
Horizontal privilege escalation
Vertical privilege escalation
IDOR / BOLA
Object-level authorization
API authorization
Safe Burp Repeater testing
Laravel authorization
Spring Security authorization
Linux, Windows & macOS practical exercises
Writing an access-control security report
⚠️ LEARNING PURPOSE ONLY: All practical exercises will remain inside your local/authorized lab environment.

No comments:
Post a Comment