Summary
A SQL injection vulnerability in the Hospital Information System allows attacker-controlled input supplied to the prescription lookup function to alter database queries. Because the affected endpoint can be reached remotely, an attacker who can submit crafted identifier values may access, modify, or otherwise interfere with sensitive healthcare data.
Affected context
The vulnerability occurs in the getSinglePresp function within includes/presp/PrespController.php when the prescription identifier is incorporated into a database query without sufficient separation between data and SQL syntax. Risk is higher when the function is exposed through a remotely reachable application endpoint and the input is not consistently validated or parameterized.
Exploit preconditions
- Attack surface: A remotely reachable Hospital Information System endpoint that invokes the prescription lookup functionality
- Required access: The ability to submit requests to the affected function; authentication requirements depend on the application's access controls
- Trigger point: Processing of the
IDargument bygetSinglePresp - Why exploitation is possible: Attacker-controlled input may be interpreted as part of a database statement when query construction does not reliably use parameter binding
Why this happens
The underlying bug is an injection flaw caused by treating externally supplied identifier data as query syntax. If the value is concatenated into a SQL statement or otherwise passed to a database API without parameterization, database commands and user data are not kept separate. This maps primarily to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection); CWE-74 broadly describes the unsafe interpretation of externally controlled input in an expression or command.
Potential impact
- An attacker may retrieve sensitive patient, prescription, or administrative records.
- An attacker could alter or delete database information.
- The application may disclose database errors or internal schema details.
- Database availability could be degraded through resource-intensive queries.
- Compromised records could affect clinical workflows, reporting, or regulatory compliance.
General mitigation guidance
Mitigation generally centers on making database queries data-only by design and reducing trust in request parameters.
Common defensive patterns include:
- Use parameterized queries or prepared statements for every database operation.
- Apply allowlist validation for identifier fields, including expected type, format, and bounds.
- Avoid constructing SQL statements through string concatenation or interpolation.
- Use database accounts with only the permissions required by the application.
- Return generic error messages while keeping detailed database errors in protected logs.
- Apply consistent authorization checks before exposing prescription or patient records.
- Treat validation as a secondary control rather than a replacement for parameter binding.
How teams detect issues like this
Organizations can identify SQL injection risks through:
- Static analysis rules for string-built SQL and database calls that receive request parameters directly.
- Code review checks for query construction in controller and data-access layers.
- Dynamic application testing that evaluates identifier and filter parameters for unexpected query behavior.
- Database activity monitoring for anomalous statement patterns, access volumes, or privilege use.
- Web application firewall and API policy rules that detect suspicious input patterns, used as defense-in-depth rather than the primary fix.
- Automated security review tools that flag unparameterized queries and missing input validation.

