IDOR in user profile viewing functionality
This lab demonstrates a basic IDOR vulnerability in a user profile system. The application allows users to view any user's profile by simply changing the user_id parameter without proper authorization checks.
Objective: Access other users' profiles by manipulating the user_id parameter to view sensitive information.
// Vulnerable: No authorization check
$user_id = $_GET['user_id'] ?? $_SESSION['user_id'];
// Simulate user database
$users = [
1 => ['id' => 1, 'username' => 'user1', ...],
2 => ['id' => 2, 'username' => 'user2', ...],
3 => ['id' => 3, 'username' => 'admin', ...]
];
// Direct access without checking if user is authorized
if (isset($users[$user_id])) {
$profile_data = $users[$user_id];
// Display profile data
}
// Example vulnerable usage:
// ?user_id=1 (own profile - allowed)
// ?user_id=2 (other user's profile - unauthorized access)
// ?user_id=3 (admin profile - unauthorized access)
SSN: 987-65-4321
Salary: $85,000
user_idTry these user_id values:
1 - User 1 profile2 - User 2 profile3 - Admin profile999 - Non-existent userExample URLs:
1.php?user_id=21.php?user_id=3Click these links to test the vulnerability: