Summary
A SQL injection flaw in the Class and Exam Timetabling System 1.0 allows attackers to manipulate the ID parameter in /edit_room.php to interfere with database queries.
When user-supplied identifiers are embedded directly into SQL statements, remote attackers may extract, modify, or delete application data and potentially escalate their access.
Affected context
This vulnerability appears in the web interface of the SourceCodester Class and Exam Timetabling System, specifically in the code handling room editing via /edit_room.php.
It is likely triggered when the application builds SQL queries based on the ID parameter from HTTP requests without robust validation or parameterization.
Deployments where the application is exposed to untrusted users over a network and uses a shared database with sensitive scheduling or user information are at higher risk.
Exploit preconditions
- Attack surface: HTTP request handling for
/edit_room.php, including GET or POST parameters. - Required access: Network access to the web application; no prior authentication may be required depending on access controls for the room-edit feature.
- Trigger point: Submission of a crafted
IDparameter that is concatenated into SQL queries. - Why exploitation is possible: The application appears to treat the
IDvalue as trusted input, directly embedding it into SQL without parameter binding or adequate server-side validation, enabling arbitrary SQL fragments to be executed by the database.
Why this happens
The underlying bug aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') and is related to CWE-74: Improper Neutralization of Special Elements in Output.
Application logic responsible for editing room records likely constructs SQL statements by concatenating the ID parameter into query strings, rather than using prepared statements or stored procedures with bound parameters.
Because special characters and SQL control tokens in the ID value are not stripped, escaped, or otherwise neutralized, the database interprets user input as part of the query logic, allowing attackers to alter query behavior and access data beyond the intended scope.
Potential impact
- Attackers may read or enumerate timetable, room, and user records from the database.
- Malicious users could modify or delete scheduling data, disrupting class and exam timetables.
- SQL injection can allow bypass of authentication or authorization checks depending on query design.
- Under certain configurations, attackers could write arbitrary data or create new accounts with elevated privileges.
- If the database server has extended capabilities enabled, further system compromise could occur.
General mitigation guidance
Effective mitigation focuses on removing direct string concatenation from SQL construction and reducing trust in user-controlled parameters.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all database access, particularly for identifier parameters like
ID. - Applying strict server-side validation on input fields, enforcing expected formats (e.g., numeric IDs) before interacting with the database.
- Centralizing database access through a data-access layer that enforces safe query construction by default.
- Limiting database privileges of the application account so that even if a query is abused, the scope of damage is constrained.
- Implementing robust error handling that avoids exposing raw SQL errors or stack traces in HTTP responses.
How teams detect issues like this
High-level detection typically combines automated and manual review:
- Static analysis rules can flag dynamic SQL patterns where request parameters, such as
$_GET['ID']or$_POST['ID'], are concatenated into query strings. - Code review checklists should highlight any use of string-based SQL construction in PHP files like
/edit_room.phpand require prepared statements instead. - Runtime security testing and web vulnerability scanning can probe parameters like
IDfor injection behavior and unusual error responses. - Policy-based controls in CI/CD pipelines can block deployments containing known unsafe database APIs or unparameterized query constructs.

