Summary
A SQL injection vulnerability in the Drug Recommendation System allows attacker-controlled input in the ID argument of /Admin/edit_symptom.php to alter database queries. Because the affected endpoint is remotely reachable, an attacker may access, modify, or otherwise interfere with database information when input is not safely handled.
Affected context
The weakness occurs in the administrative symptom-editing functionality of SourceCodester Drug Recommendation System 1.0. It becomes risky when the ID request parameter is incorporated into database queries without reliable parameterization, validation, or contextual escaping, particularly if the endpoint is exposed to remote users.
Exploit preconditions
- Attack surface: The remotely reachable
/Admin/edit_symptom.phpendpoint - Required access: Ability to send requests to the affected functionality; authentication requirements may depend on the deployment configuration
- Trigger point: Processing of the
IDargument during symptom-edit operations - Why exploitation is possible: Attacker-controlled input may influence SQL query structure when it is concatenated into a database statement without parameter binding
Why this happens
The underlying bug is an injection flaw in which externally supplied input is treated as part of a SQL statement rather than as data. This behavior maps primarily to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, commonly known as SQL injection. CWE-74 is also relevant as a broader classification for improper neutralization of special elements in output used by a downstream interpreter.
Potential impact
- An attacker may read unauthorized records from the application database.
- An attacker could modify or delete symptom and related application data.
- Database integrity and availability may be affected.
- Sensitive information stored in the database may be disclosed.
- Compromised data could undermine recommendation accuracy or application trust.
General mitigation guidance
Mitigation generally centers on ensuring that database commands cannot be structurally altered by request data.
Common defensive patterns include:
- Use parameterized queries or prepared statements for every database operation.
- Apply allowlist validation for identifier-like values such as numeric record IDs.
- Avoid constructing SQL statements through string concatenation.
- Enforce authorization checks independently of input validation before editing records.
- Limit the database account to the minimum permissions required by the application.
- Use secure error handling that does not expose query details or database diagnostics.
- Treat all client-supplied values as untrusted, including values submitted through administrative interfaces.
How teams detect issues like this
Detection can include static analysis for SQL statements built through string concatenation, especially where request parameters such as ID flow into query construction. Code reviews should look for missing prepared statements, weak validation of identifier fields, inconsistent authorization checks, and verbose database errors. Dynamic testing and web application security testing can verify that unexpected input is handled as data without changing query behavior. CI policy checks may require approved database access libraries and reject unsafe query-construction patterns.

