2023 Cyber Apocalypse: Didactic Octo Paddle
Challenge Information
| Attribute | Details |
|---|---|
| Event | 2023 Cyber Apocalypse |
| Category | Web |
| Challenge | Didactic Octo Paddle |
Summary
This challenge features a shopping application with JWT-based authentication and several vulnerabilities: IDOR (Insecure Direct Object Reference), weak JWT secrets, and improper access controls. The goal is to exploit these to access admin resources.
Analysis
Application endpoints:
GET /- Home page with product listGET/POST /register- User registrationGET/POST /login- User authentication with JWTGET /cart- View shopping cartPOST /add-to-cart/:item- Add itemPOST /remove-from-cart/:item- Remove itemGET /admin- Admin page (requires admin role)
JWT Structure:
Header: {"alg":"HS256","typ":"JWT"}Payload: {"id":2,"iat":1679241150,"exp":1679244750}Signature: 9oI6U-J09Nlq2c5G2raESd-8Ska1j7wH9SNjJFE-8I4Vulnerabilities:
- JWT is signed with a potentially weak or default secret
- User IDs are predictable and exposed in JWT payload
- No proper authorization checks on user-specific endpoints
- Admin status may be modifiable in JWT
Solution
Approach 1: JWT Manipulation
-
Register a user and obtain a JWT token
-
Decode the JWT payload:
eyJpZCI6MiwiaWF0IjoxNjc5MjQxMTUwLCJleHAiOjE2NzkyNDQ3NTB9Decodes to: {"id":2,"iat":1679241150,"exp":1679244750} -
Modify the payload to include
"is_admin":1or changeidto1 -
Re-sign if the secret is known/weak
Approach 2: IDOR Exploitation
Make requests with different user IDs:
GET /api/user/1 # Admin userGET /api/user/2 # Current userGET /api/user/3 # Another userIf authorization isn’t checked properly, you can access other users’ data.
Approach 3: ID Enumeration
If the application stores passwords or sensitive data, enumerate user IDs:
for i in {1..100}; do curl -H "Cookie: session=$JWT" http://target/api/user/$idoneKey Takeaways
- IDOR occurs when applications don’t verify user authorization
- JWT secrets must be sufficiently random and secure
- JWT payload should not contain sensitive information
- User IDs should not be predictable or sequential
- Always validate that users can only access their own resources
- Admin status should never be in user-modifiable tokens
- Proper authorization checks are essential on every endpoint