Start the machine, hack the system, and find the hidden flags to complete this challenge and earn points!
This walkthrough explains how to hack the lab and capture the flags. For help with Learning Mode questions, use the Request Hint button next to each question.
This API implements a simple authentication system with a critical logic flaw. Let's understand how it works:
GET /api/status/api/profile requires authentication and /api/admin requires admin privilegesThe API uses a multi-layered authentication approach:
session_id cookieAuthorization: Bearer <token> headeruser_id parameter in GET/POST requestsKey Insight: The authentication checks are performed in sequence, and if any method succeeds, the user is considered authenticated. This creates a logic flaw.
The vulnerability exists in the isAuthenticated() function. Here's the problematic logic:
// LOGIC FLAW: Check for user_id parameter in GET/POST
if (isset($_GET['user_id']) || isset($_POST['user_id'])) {
$userId = $_GET['user_id'] ?? $_POST['user_id'];
// Find user by user_id
foreach ($users as $username => $userData) {
if ($userData['user_id'] == $userId) {
return [/* user data */];
}
}
}The Problem: This code allows direct authentication by simply providing a user_id parameter, bypassing all other security checks.
POST /api/login with {"username": "test", "password": "test"}user_iduser_id: 23User Mapping:
admin → user_id: 1 (admin role)test → user_id: 23 (user role)Now that we understand the vulnerability, we can exploit it:
GET /api/admin?user_id=1GET /api/profile?user_id=23POST /api/admin with body {"user_id": 1}Why This Works: The API checks for the user_id parameter first, and if found, it directly authenticates the user without checking session tokens or other security measures.
GET /api/admin?user_id=1 will return:{"message": "Admin panel accessed successfully", "admin_data": {"system_status": "operational", "active_users": 42, "server_uptime": "7 days", "flag": "2915b155-bfde-4532-897f-ebdf8ed52d82"}}2915b155-bfde-4532-897f-ebdf8ed52d82This vulnerability exists because:
When testing APIs for similar vulnerabilities:
Choose how you want to get started
Choose a username to get started
We've sent a 9-character code to your email