| タイトル | SourceCodester Student Grading System latest Authorization Bypass |
|---|
| 説明 | SourceCodester Student Grading System is a PHP/MySQL web app. Any authenticated
account can read the full report card of any student — grades, weighted average,
GWA, pass/fail remarks — by changing the student_id parameter in report_card.php.
No check ties the requesting user to the requested student.
Affected file: report_card.php, lines 3-9.
require_once __DIR__ . '/includes/auth.php';
require_login();
$pdo = db();
$sid = (int)($_GET['student_id'] ?? 0);
$stmt = $pdo->prepare('SELECT * FROM students WHERE id = ?');
$stmt->execute([$sid]);
$student = $stmt->fetch();
if (!$student) exit('Student not found.');
require_login() checks only that a session exists. $sid is read from the query
string and used to pull the student row, then the whole grade set. No call to
can_manage_class(), no is_admin(), no enrollment check. The prepared statement
blocks SQL injection but does nothing about authorization — the record fetched
is whatever id was asked for.
The app has the correct control and uses it elsewhere. grades.php line 12:
if (!can_manage_class($class)) {
http_response_code(403);
exit('You can only open your own classes.');
}
So the gap is specific to report_card.php. Same session, same data, one
endpoint gates it, the other does not.
Confirmed on a local deployment (PHP 7.4 Apache, MySQL 5.7, schema from the
shipped database.sql). Logged in as seeded teacher mreyes. Sent:
GET /report_card.php?student_id=3
Response 200, full report card for student id 3 (Carla Lim) rendered — subjects,
prelim/midterm/finals, average, GWA 2.59, remarks. Same cookie jar:
GET /grades.php?class_id=2
Response 403, "You can only open your own classes." — class 2 belongs to
teacher jdelacruz. The teacher is correctly locked out of the class grade sheet
but still reads a student in it through the report card. That is the whole bug.
student_id is a sequential integer with no rate limit and no CSRF on the GET.
A loop over student_id=1..N walks the entire student body:
for i in $(seq 1 500); do
curl -s -b cj.txt "http://localhost:8080/report_card.php?student_id=$i" \
| grep -q 'Report Card' && echo "leaked student_id=$i"
done
Impact: full academic records for every student, readable by any logged-in
account at the lowest privilege level. Names, subjects, term grades, averages,
GWA, pass/fail. Regulated personal data (FERPA/PDPA/GDPR class). Because ids
are sequential and the endpoint is a GET, this is a straight enumeration, not a
targeted leak.
Fix applied in the writeup: after fetching $student, if not admin, check the
student is enrolled in a class the current user teaches (join enrollments to
classes on teacher_id), otherwise 403 — the same model grades.php already uses.
Code is in the Gist linked as reference.
CWE-639 (Authorization Bypass Through User-Controlled Key).
CVSS v3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N (6.5).
Tested build downloaded 2026-11-09 from the SourceCodester product page; no
version string in the archive (README.txt has none). Gist has the source
snippet, the three screenshots (login state, the IDOR read, the 403 contrast),
and the patch diff. |
|---|
| ソース | ⚠️ https://gist.github.com/anandhu-in/605d46505d08a36e20d9a6f2a99b2949 |
|---|
| ユーザー | barryallen (UID 102843) |
|---|
| 送信 | 2026年11月09日 00:43 (22 日 ago) |
|---|
| モデレーション | 2026年11月30日 16:17 (22 days later) |
|---|
| ステータス | 承諾済み |
|---|
| VulDBエントリ | 445703 [SourceCodester Student Grading System 1.0 Report Card report_card.php student_id 特権昇格] |
|---|
| ポイント | 20 |
|---|