Severity:

HIGH RISK

(7.3)

SQL Injection in Hospital Management System PHP

CVE-2026-8785

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-74, CWE-89

Impact:

Data Exposure and Integrity Compromise via SQL Injection

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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_no parameter
  • 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.php over 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 getAllPatientDetail and constructs SQL queries using the appointment_no GET 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_no value as a typed parameter.
  • Enforce stringent server-side validation on request parameters, restricting appointment_no to 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.

Sources

SourceLink
github.comgithub.com/lutherping/CVE
github.comgithub.com/projectworldsofficial/Hospital-management-system-in-php/issues/8
vuldb.comvuldb.com/submit/812010
vuldb.comvuldb.com/vuln/364409
vuldb.comvuldb.com/vuln/364409/cti

Frequently asked

questions

The vulnerability is remotely exploitable by anyone who can reach the affected endpoint and send crafted GET requests. The practical impact depends on whether the endpoint is public and if additional authentication controls are present.

Typically, only network access to the web application is required. If the endpoint does not enforce authentication or is reachable after low-privilege login, an attacker can attempt SQL injection without any special permissions.

Replace all raw SQL string concatenation involving user input with prepared statements and bound parameters, and apply strict server-side validation for parameters such as appointment_no. This structural change should be applied consistently across the data access layer.

Standardize on safe database access abstractions (ORMs or parameterized query wrappers), adopt coding standards that forbid direct interpolation of request data into SQL, and enforce these through code review, static analysis, and CI policies.

Find out what's already
exploitable in your codebase.