Summary
SourceCodester Online Class Record System 1.0 contains a SQL injection vulnerability in the /admin/message/search.php endpoint, where the term parameter is used unsafely in database queries.
A remote attacker can manipulate this parameter to interfere with SQL query logic, potentially accessing or modifying data beyond their intended permissions when the vulnerable search functionality is invoked.
Affected context
The vulnerability occurs within the administrative messaging/search functionality of the Online Class Record System, specifically in /admin/message/search.php.
It is present when user-supplied input from the term parameter is incorporated into SQL queries without adequate neutralization, validation, or use of parameterized statements.
The issue is most relevant in deployments where the application is internet-accessible and the admin search endpoint can be reached directly or through an authenticated session.
Exploit preconditions
- Attack surface: HTTP(S) requests to the Online Class Record System, targeting /admin/message/search.php.
- Required access: Ability to send requests that reach the admin message search endpoint; in some deployments this may require valid admin or staff credentials, while in others misconfiguration might expose the endpoint more broadly.
- Trigger point: Supplying crafted values in the term parameter of a search request so that the input is incorporated into SQL queries.
- Why exploitation is possible: The application constructs SQL statements using the term parameter without proper use of prepared statements or robust input neutralization, allowing attacker-controlled fragments to alter query structure.
Why this happens
The core defect is the dynamic construction of SQL queries using untrusted input, which maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Rather than binding user input as data via prepared statements, the code likely concatenates the term parameter directly into the WHERE or LIKE clause, allowing control characters (quotes, operators, comments) to change the intended query.
The presence of CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component reflects that data destined for the database is not sanitized in a way that preserves its role as data, turning it into executable SQL for the downstream DBMS.
Potential impact
- Extraction of sensitive class records, messages, or user information that the attacker should not be able to view
- Modification or deletion of records in the underlying database, including grade data or user accounts
- Bypassing of application-level access controls by directly querying restricted tables or views
- Potential creation of new privileged accounts or alteration of existing authentication data
- In some database configurations, execution of database-native commands that could impact system availability or integrity
General mitigation guidance
Effective mitigation focuses on treating all external input as data, never as SQL syntax, and tightening database privileges:
- Adopt parameterized queries or prepared statements for all database access paths that incorporate user-supplied values, including search features.
- Enforce strict input validation for search parameters such as term, constraining them to expected character sets, length, and format before reaching the data access layer.
- Centralize query construction in a data access layer that consistently uses safe query APIs instead of ad hoc string concatenation in PHP scripts.
- Apply least-privilege principles at the database level, granting the application account only the minimal rights needed to perform its intended operations.
- Consider using query builders or ORM abstractions that default to safe binding of parameters rather than raw SQL string assembly.
How teams detect issues like this
Detection generally combines code-centric analysis with runtime monitoring:
- Use static analysis rules or linters to flag dynamic SQL construction patterns (e.g., string concatenation involving $_GET/$_POST variables being passed to database APIs).
- During code review, scrutinize all database interactions in PHP files such as /admin/message/search.php for direct embedding of request parameters.
- Implement web application firewalls or request filtering rules tuned to detect and block common SQL injection payload patterns in parameters like term.
- Capture and review database query logs for anomalous queries containing unexpected operators, comment markers, or concatenated literals that deviate from normal patterns.
- Integrate automated security testing (DAST) into CI/CD to probe endpoints with fuzzed inputs and watch for error signatures or unexpected data leakage.

