Summary
A SQL injection vulnerability in the Hospital Management System in PHP allows attackers to manipulate the appointment_no GET parameter processed by getAllPatientDetail in update_info.php.
When user-controlled values are concatenated directly into SQL queries without proper validation or parameterization, a remote attacker can alter the query logic, potentially accessing or modifying patient and appointment data.
Affected context
This vulnerability arises in deployments of the Hospital Management System in PHP where update_info.php is exposed over HTTP and the appointment_no parameter is passed directly from the GET request into SQL statements.
It typically occurs when:
- The application builds SQL queries dynamically using string concatenation
- There is no use of prepared statements or proper escaping for the
appointment_noparameter - Input validation is minimal or non-existent, treating request parameters as trusted data
Exploit preconditions
- Attack surface: Public or internal web interface exposing
update_info.phpover HTTP/HTTPS. - Required access: Ability to send crafted HTTP GET requests to the application (no prior authentication may be required, depending on configuration).
- Trigger point: The application invokes
getAllPatientDetailand constructs SQL queries using theappointment_noGET parameter. - Why exploitation is possible: User-controlled input is embedded directly into SQL query strings without parameterization, escaping, or strict type enforcement, allowing attackers to inject additional SQL syntax.
Why this happens
The core issue is the construction of SQL queries using untrusted input without proper binding or sanitization, corresponding to CWE-89: SQL Injection.
In this pattern, the appointment_no parameter from the GET request is treated as a literal part of the SQL statement rather than as a data value, enabling the attacker to modify query structure, predicates, and sometimes appended statements.
CWE-74 (Improper Neutralization of Special Elements in Output) is also implicated, as special characters meaningful to SQL (quotes, operators, delimiters) are not neutralized before being embedded into the query string.
This reflects a common insecure coding practice where convenience or legacy patterns (e.g., interpolating variables directly into SQL) replace parameterized queries and strict validation.
Potential impact
- Unauthorized reading of patient records and appointment details
- Modification or deletion of medical data, appointments, or user records
- Extraction of sensitive information such as personally identifiable information (PII)
- Escalation to full database compromise if the database account has broad privileges
- Potential disclosure of authentication hashes or configuration data stored in the same database
General mitigation guidance
Effective mitigation focuses on eliminating direct concatenation of user input into SQL and enforcing strict input handling:
- Use parameterized queries or prepared statements for all database access, binding the
appointment_novalue as a typed parameter. - Enforce stringent server-side validation on request parameters, restricting
appointment_noto the expected format (e.g., numeric or well-defined identifier pattern). - Apply least-privilege to the database account used by the application, limiting it to only the operations and tables required.
- Centralize data-access patterns in a small number of components or repositories to enforce consistent secure query-building practices.
- Consider implementing an application-wide input validation layer or query builder/ORM that discourages raw SQL string interpolation by default.
How teams detect issues like this
To detect similar vulnerabilities, organizations can use a combination of code and runtime analysis:
- Static code analysis: Scan PHP code for dynamic SQL construction patterns such as string concatenation involving
$_GET,$_POST, or other superglobals, especially around database calls (e.g.,mysqli_query,PDO::query). - Code review signals: Flag any occurrence where request parameters are directly embedded into SQL strings; verify that prepared statements and bound parameters are the norm.
- Security testing: Run automated SQL injection tests using dynamic application security testing (DAST) tools or targeted penetration testing against endpoints handling identifiers like
appointment_no. - Policy enforcement: Introduce coding guidelines and CI checks that require use of parameterized queries and reject direct interpolation of user input into SQL as part of pull-request workflows.

