A comprehensive security CTF challenge for learning cookie vulnerabilities through hands-on exploitation
Cookie Security Lab is an educational platform designed for security professionals and students to practice identifying, exploiting, and mitigating cookie-related vulnerabilities. This lab provides 6 realistic vulnerabilities with hashed CTF flags, step-by-step walkthroughs, and secure pattern examples.
Perfect for:
- ๐ Security training programs
- ๐ CTF competitions
- ๐ฌ Penetration testing practice
- ๐ OWASP ASVS learning
- ๐ก๏ธ Web application security courses
- โ Cookie tampering for authorization bypass
- โ XSS and session theft via missing HttpOnly
- โ Over-broad cookie scope exploitation
- โ Session fixation attacks
- โ CSRF (Cross-Site Request Forgery)
- โ Cookie value poisoning
- โ Secure cookie patterns (HttpOnly, Secure, SameSite)
- โ Server-side session management
| # | Vulnerability | Flag | Difficulty |
|---|---|---|---|
| 1 | Client-Controlled Role Cookie | FLAG{CLIENT_CONTROLLED_ROLE_59721BC5} | โญ Easy |
| 2 | XSS Cookie Theft | FLAG{XSS_COOKIE_THEFT_5C6EA866} | โญโญ Medium |
| 3 | Broad Scope Cookie | FLAG{BROAD_SCOPE_COOKIE_0DE7C8AB} | โญ Easy |
| 4 | Session Fixation | FLAG{SESSION_FIXATION_E3C79F1B} | โญโญ Medium |
| 5 | CSRF Role Change | FLAG{CSRF_ROLE_CHANGE_3051E639} | โญโญ Medium |
| 6 | Cookie Poisoning | FLAG{COOKIE_POISONING_252CD918} | โญโญ Medium |
- Node.js โฅ 18 (Install)
- npm (comes with Node.js)
- Firefox or Chrome browser (recommended)
- Burp Suite Community (optional, for advanced exercises)
git clone https://github.com/yourusername/cookie-security-lab.git
cd cookie-security-labnpm installnpm startNavigate to: http://localhost:3004
| Document | Purpose |
|---|---|
| CTF-Walkthrough.md | Start here! Step-by-step flag collection guide |
| cookie-lab-guide.md | Detailed vulnerability explanations & OWASP mappings |
| cookie-lab-server.js | Well-commented vulnerable server code |
- Risk: Authorization bypass via cookie tampering
- Method: DevTools or Burp Suite
- Learning: Never trust client-side authorization
- Risk: JavaScript can steal session cookies; transmission over HTTP
- Method: XSS simulation & console
- Learning: HttpOnly is mandatory for session cookies
- Risk: Cookies sent with every request (images, stylesheets, etc.)
- Method: DevTools Network tab
- Learning: Use specific paths and domain restrictions
- Risk: Attacker forces known session ID on victim
- Method: URL parameter manipulation
- Learning: Generate session IDs server-side only
- Risk: Malicious form can change user settings
- Method: Form submission demo
- Learning: Implement CSRF tokens and SameSite
- Risk: Server accepts arbitrary cookie values
- Method: Query parameter injection
- Learning: Never trust cookie inputs
Each vulnerability includes a comparison with the secure pattern:
/secure/loginโ Server-side session with opaque ID/secure/adminโ Authorization via server-side lookup- Proper flags:
HttpOnly,Secure,SameSite=Strict
- Backend: Express.js (Node.js)
- Cookie Parser: cookie-parser
- Crypto: Node.js built-in crypto module
- Frontend: HTML/CSS (educational landing page)
cookie-security-lab/
โโโ cookie-lab-server.js # Main vulnerable server
โโโ cookie-lab-guide.md # Comprehensive guide
โโโ CTF-Walkthrough.md # Step-by-step solutions
โโโ package.json # Dependencies
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ .gitignore # Git ignore rules
โโโ .github/
โโโ workflows/
โโโ verify.yml # CI/CD pipeline
โจ 6 Unique Vulnerabilities - Each teaches distinct security concepts ๐ฏ Hashed CTF Flags - Anti-guessing, cryptographically verified ๐ Detailed Walkthroughs - Step-by-step exploitation guides ๐ Secure Patterns - Compare vulnerable vs. secure implementations ๐ท๏ธ OWASP ASVS Mapped - Links to security standards ๐ฌ Code Comments - Educational explanations throughout ๐งช CI/CD Pipeline - Automated verification
- Follow the walkthrough: Open CTF-Walkthrough.md
- Exploit each vulnerability: Use provided methods (DevTools, Burp, etc.)
- Collect flags: Each exploit returns a unique hashed flag
- Document learning: Take notes on security lessons
- Compare secure patterns: Review
/secure/*endpoints
This project helps you learn:
- CTF (Capture The Flag)
- Cookie Security
- Web Vulnerabilities
- OWASP ASVS
- Session Management
- XSS (Cross-Site Scripting)
- CSRF (Cross-Site Request Forgery)
- Penetration Testing
- Security Training
- Vulnerable Code Examples
This lab intentionally contains security vulnerabilities for educational purposes.
- โ Do NOT deploy in production
- โ Do NOT use code patterns from this lab in real applications
- โ Study the vulnerabilities and security lessons
- โ
Always implement secure patterns from
/secure/*examples
When completing this lab, document:
- Vulnerability Name - What was exploited?
- Root Cause - Why was it vulnerable?
- Exploitation Method - How did you exploit it?
- Flag - What did you collect?
- Mitigation - How would you fix it?
- OWASP ID - Reference standard
- OWASP ASVS v4.0 โ Session Management (V3) & Access Control (V4)
- PortSwigger Web Academy โ Cookie & Session labs
- RFC 6265bis โ Cookie specification
- OWASP Testing Guide โ Session testing
- Use Developer Tools - F12 in Firefox/Chrome, especially Application tab
- Monitor Network Traffic - Watch cookie headers in real-time
- Use Burp Suite - Repeater tab is excellent for testing variations
- Read Console Logs - Server prints helpful debugging info
- Compare Secure Code -
/secure/*shows proper patterns - Document Everything - Take screenshots of each flag
Found an issue or have suggestions?
- Open an issue on GitHub
- Submit a pull request with improvements
- Suggest new vulnerabilities to demonstrate
This project is licensed under the MIT License - see LICENSE file for details.
- Built for security education and OWASP awareness
- Inspired by real-world cookie vulnerabilities
- References: PortSwigger, OWASP, RFC 6265bis
- ๐ Read CTF-Walkthrough.md for step-by-step help
- ๐ See cookie-lab-guide.md for detailed explanations
- ๐ง Check server logs for debugging info
- โ Review code comments for implementation details
Happy learning! ๐ Collect all 6 flags and master cookie security! ๐ฉ