IDOR in document viewing functionality
This lab demonstrates an IDOR vulnerability in a document management system. The application allows users to view any document by simply changing the doc_id parameter without proper authorization checks, including confidential documents.
Objective: Access confidential documents by manipulating the doc_id parameter to view sensitive information.
// Vulnerable: No authorization check
$doc_id = $_GET['doc_id'] ?? '1';
// Simulate document database
$documents = [
1 => ['id' => 1, 'title' => 'Project Alpha', 'owner_id' => 1, ...],
2 => ['id' => 2, 'title' => 'Financial Report', 'owner_id' => 2, 'confidential' => true, ...],
3 => ['id' => 3, 'title' => 'Company Strategy', 'owner_id' => 3, 'confidential' => true, ...]
];
// Direct access without checking if user is authorized
if (isset($documents[$doc_id])) {
$document_data = $documents[$doc_id];
// Display document data
}
// Example vulnerable usage:
// ?doc_id=1 (own document - allowed)
// ?doc_id=2 (other user's confidential document - unauthorized access)
// ?doc_id=3 (admin's confidential document - unauthorized access)
Title: HR Policies and Procedures
Owner: admin
Created Date: 2024-01-30
File Type: PDF
File Size: 4.1 MB
Confidential: Yes
This document contains HR policies and employee procedures...
doc_idTry these doc_id values:
1 - Project Alpha (Your Document)2 - Financial Report (Confidential)3 - Company Strategy (Admin Confidential)4 - HR Policies (Admin Confidential)Example URLs:
2.php?doc_id=22.php?doc_id=3Click these links to test the vulnerability: