Summary
SourceCodester Class and Exam Timetabling System 1.0 contains a SQL injection flaw in the /edit_course.php endpoint via the ID parameter.
An attacker who can send crafted HTTP requests to this function may manipulate backend queries, potentially exposing or altering course and exam data on the server.
Affected context
The vulnerability occurs in the web-based Class and Exam Timetabling System when the /edit_course.php script builds SQL queries using the ID parameter without adequate sanitization or parameterization.
It typically manifests in deployments where user-supplied request parameters are directly concatenated into SQL statements, and where database accounts used by the application hold broad read/write permissions over timetabling and course-related data.
Exploit preconditions
- Attack surface: HTTP interface to /edit_course.php
- Required access: Ability to send requests to the application (usually remote, unauthenticated or low-privilege user)
- Trigger point: Submission of a specially crafted ID parameter during course edit operations
- Why exploitation is possible: The ID value is incorporated into SQL queries without proper escaping or prepared statements, allowing the attacker's input to change query structure rather than being treated as data.
Why this happens
This issue stems from building SQL queries by concatenating raw user input, a pattern aligned with CWE-89: Improper Neutralization of Special Elements used in an SQL Command.
Instead of treating the ID parameter strictly as data bound through prepared statements, the application mixes it directly into query text, enabling injection of additional SQL syntax.
The lack of central input validation or encoding logic and the reliance on ad hoc query construction make the endpoint susceptible to crafted inputs that manipulate the database layer.
Potential impact
- May allow unauthorized reading of course, exam, and timetabling records
- Could enable modification or deletion of database entries related to classes and schedules
- Can facilitate creation of fake or misleading timetables and course information
- May be leveraged to escalate impact by extracting authentication data or other sensitive tables if accessible
- Could act as a stepping stone for broader system compromise if the database user has elevated privileges
General mitigation guidance
Effective mitigation revolves around ensuring that user input cannot alter SQL query structure.
Common patterns include:
- Using parameterized queries or prepared statements for all database operations involving user-supplied values
- Centralizing query construction in data access layers that enforce strict binding of parameters
- Validating and normalizing identifiers such as ID to expected formats (e.g., numeric ranges) before use
- Restricting database accounts to least-privilege so that compromised queries have limited reach
- Applying consistent server-side input neutralization for any value used in dynamic query contexts
How teams detect issues like this
Detection typically involves:
- Static analysis rules that flag string-concatenated SQL statements and direct inclusion of request parameters
- Code review checklists focused on verifying that all database interactions use prepared statements and parameter binding
- Runtime monitoring and database activity logging to identify anomalous query patterns, such as unexpected UNIONs or multi-statement payloads
- Security testing practices (e.g., automated scanners or fuzzers) that probe endpoints with injection payloads and alert on error messages or abnormal responses

