Summary
The Class and Exam Timetabling System 1.0 contains a SQL injection flaw in the /edit_schoolyr.php endpoint, where the ID parameter is not safely handled before being used in database queries.
A remote attacker can manipulate this parameter to interfere with SQL statements, which may expose or modify timetable data and potentially compromise the underlying database when the vulnerable page is accessible.
Affected context
This vulnerability occurs in web deployments of SourceCodester Class and Exam Timetabling System 1.0 that expose the /edit_schoolyr.php script.
The issue is typically present when user-supplied parameters (such as the ID argument) are directly embedded into SQL queries without using proper parameterization or escaping.
It is most relevant in environments where the application server can reach a relational database and where access to the edit school year functionality is available over the network.
Exploit preconditions
- Attack surface: HTTP requests sent to the /edit_schoolyr.php endpoint.
- Required access: Ability to reach the web application over the network; further access constraints depend on how the page is exposed (e.g., authenticated vs. public).
- Trigger point: Supplying crafted values in the ID parameter so that they are concatenated into SQL statements.
- Why exploitation is possible: The backend constructs SQL queries using string concatenation or unsafely interpolated variables, allowing attacker-controlled input to alter query structure instead of being treated strictly as data.
Why this happens
The underlying issue is improper neutralization of special elements used in an SQL command (CWE-89), a specific case of injection (CWE-74).
The application appears to construct queries in /edit_schoolyr.php by inserting the ID parameter directly into SQL text without using prepared statements or proper binding.
As a result, input that includes SQL syntax (such as quotes or operators) can change the intended query logic, enabling attackers to execute arbitrary SQL statements within the database session associated with the web application.
Potential impact
- Attackers may extract sensitive timetable and user-related records from the database.
- Malicious actors could modify or delete school year and scheduling data, disrupting operations.
- SQL injection chains may allow creation of new application accounts or escalation of privileges within the system.
- In certain configurations, attackers can leverage database features to execute server-side commands or pivot to other parts of the infrastructure.
General mitigation guidance
Effective mitigation focuses on removing the injection primitive and tightening data handling boundaries.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all database operations, ensuring the ID parameter is bound as data.
- Applying strict input validation on identifier fields, enforcing expected formats (e.g., integer-only IDs) before processing.
- Centralizing database access through a data access layer that prohibits raw query concatenation.
- Running the database with least-privilege credentials so that, if a query is abused, its capabilities are limited to what the application genuinely needs.
- Enforcing defense-in-depth controls such as web application firewalls that can help detect and block obvious SQL injection payloads.
How teams detect issues like this
Detection typically combines code-focused and behavior-focused approaches:
- Static analysis rules to flag dynamic SQL construction using string concatenation or interpolation with request parameters in PHP files (particularly /edit_schoolyr.php).
- Manual code review patterns that look for direct use of $_GET/$_POST variables in SQL statements, missing prepared statements, and absent validation on critical identifiers.
- Runtime monitoring of database queries to identify anomalous patterns, such as unexpected logical operators, tautologies, or stacked statements originating from web requests.
- Integration of automated security testing (e.g., DAST tools) in CI/CD pipelines to probe web endpoints for injection behavior and regressions.

