| عنوان | SourceCodester Learning Management System 1.0 Open Redirect |
|---|
| الوصف | # Open Redirect Through the Referer Header
link: (https://www.sourcecodester.com/php/18739/syllabus-aligned-learning-management-examination-system.html)
**Affected file:** cictportal/approve_enrollment.php, lines 10–19
**Category:** Open Redirect (CWE-601)
**Precondition:** A valid instructor, clerk, or super-admin session and a test enrollment ID.
## Description
After updating an enrollment, the handler redirects to the request's Referer without checking that it points to this application. A caller can supply an external Referer and make the authenticated application redirect there.
## Vulnerable source
~~~php
if (!isset($_SESSION['role']) || !in_array($_SESSION['role'], ['instructor', 'clerk', 'super_admin'])) {
die("UNAUTHORIZED_ACCESS");
}
if (isset($_GET['id'])) {
$enrollment_id = $_GET['id'];
$new_status = $_GET['status'] ?? 'approved';
$stmt = $pdo->prepare("UPDATE enrollments SET status = ? WHERE id = ?");
if ($stmt->execute([$new_status, $enrollment_id])) {
$referrer = $_SERVER['HTTP_REFERER'] ?? 'dashboard.php';
header("Location: " . $referrer . "&msg=status_updated");
exit();
}
}
~~~
Prepared SQL statements prevent SQL injection here, but do not constrain the redirect destination. This GET request also changes enrollment state; the CSRF implication is documented separately.
## Reproduction
Use a local disposable database and test enrollment. Replace the cookie with a valid test session:
~~~sh
curl -i \
-b 'PHPSESSID=replace_with_test_session' \
-H 'Referer: https://attacker.example/landing' \
'http://127.0.0.1:8080/approve_enrollment.php?id=1&status=approved'
~~~
The response should contain a Location header pointing to the external attacker.example URL. Use a disposable enrollment because the request changes its status.
## Impact
An attacker can use a trusted application URL to redirect a user to an attacker-controlled site, enabling phishing. This is an open redirect, not evidence of HTTP response splitting; PHP rejects CR/LF in response headers.
## Remediation
Use a fixed local destination or validate a relative path against an allowlist. Do not derive redirect destinations from HTTP_REFERER.
|
|---|
| المصدر | ⚠️ https://gist.github.com/Ka7arotto/a5c64fd59740958df9b2657bf38db129 |
|---|
| المستخدم | Goku (UID 80486) |
|---|
| ارسال | 28/10/2026 01:57 PM (29 أيام منذ) |
|---|
| الاعتدال | 26/11/2026 09:37 AM (29 days later) |
|---|
| الحالة | تمت الموافقة |
|---|
| إدخال VulDB | 444236 [SourceCodester Syllabus-Aligned Learning Management & Examination System approve_enrollment.php Redirect] |
|---|
| النقاط | 20 |
|---|