Second-Order IDOR (Whitebox)
Code Review - Identifying the Vulnerability
Application Overview
Testing for First-Order IDOR
Source Code Analysis
get_data.php
<?php
session_start();
require_once ('db.php');
if(!$_SESSION['user']){
header("Location: index.php");
exit;
}
$_SESSION['id'] = $_GET['id']; // β ID set BEFORE access check!
if(check_access($_SESSION['id'], $_SESSION['user'])){
header("Location: display_data.php");
exit;
} else {
header("Location: error.php");
exit;
}
?>display_data.php
error.php
The Vulnerability
Running the Application Locally
Database Setup (db.sql)
Start MySQL Container
Start PHP Server
Exploitation
Step 1: Set Session Variable
Step 2: Access display_data.php Directly
Patching
Fixed get_data.php
Question Walkthrough
Step 1: Download and Analyze Source
Step 2: Understand the Flow
Step 3: Identify Vulnerability
Step 4: Exploit
Last updated