Summary
A SQL injection vulnerability in the Class and Exam Timetabling System allows untrusted input in the ID parameter of /edit_subjecta.php to be embedded directly into database queries.
When an attacker sends crafted requests over the network, this flaw can be used to manipulate or disclose data, and potentially compromise the underlying application database.
Affected context
The issue arises in deployments of the SourceCodester Class and Exam Timetabling System where the /edit_subjecta.php endpoint accepts an ID parameter and uses it in backend SQL statements.
The vulnerability typically exists when request parameters are concatenated into query strings without parameterization or output encoding.
It is most relevant in environments where the application is exposed over a network and the database account used by the application has broad privileges.
Exploit preconditions
- Attack surface: HTTP or web interface exposing
/edit_subjecta.php - Required access: Ability to send requests to the application (often unauthenticated or low-privilege)
- Trigger point: Supplying crafted values in the
IDargument that are incorporated into SQL queries - Why exploitation is possible: The input is not properly validated or parameterized, allowing attacker-controlled content to alter the structure of the SQL statement
Why this happens
This vulnerability stems from building SQL statements by directly concatenating user-supplied data, rather than using parameterized queries or prepared statements.
Because the ID parameter is treated as code rather than data, the database interpreter processes injected tokens as part of the query logic.
This pattern aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), and is closely related to CWE-74, where external input is improperly neutralized before being included in downstream interpreters.
Potential impact
- Unauthorized reading of database records, including potentially sensitive student or exam information
- Modification or deletion of timetable, subject, or account data
- Creation of new accounts or escalation of privileges within the application data model
- Potential execution of database-specific operations that could impact application availability or integrity
General mitigation guidance
Effective mitigation focuses on treating all external input as untrusted and isolating it from query logic.
Pattern-based approaches include:
- Using parameterized queries or prepared statements for all database operations
- Applying strict server-side validation and type enforcement on identifier and numeric parameters
- Centralizing database access in a data-access layer that forbids dynamic query construction based on raw input
- Reducing database account privileges so that the application can perform only the minimum required operations
- Applying contextual output encoding when data is re-used in other interpreters or query-like contexts
How teams detect issues like this
Detection generally combines code-level and behavioral techniques:
- Static analysis rules that flag string-concatenated SQL statements involving request parameters such as
$_GET,$_POST, or equivalent - Code review checklists that specifically examine database access functions for proper parameter binding and validation
- Logging and monitoring for anomalous query patterns, including unexpected operators, comments, or concatenation in
ID-related queries - Use of automated security testing tools or scanners configured to probe input parameters for SQL injection indicators

