Summary
Online Hospital Management System 1.0 contains a SQL injection vulnerability in the /patient.php endpoint via the editid parameter.
When user-controlled input is embedded into SQL queries without proper sanitization or parameterization, a remote attacker can manipulate database queries, potentially exposing or altering sensitive medical data.
Affected context
The vulnerability occurs in the web-facing patient management functionality of the Online Hospital Management System 1.0, specifically in /patient.php where the editid argument is processed.
It is typically exposed when the application directly concatenates request parameters into SQL statements for retrieving or updating patient records.
This tends to manifest in deployments where input validation, output encoding, or parameterized queries are incomplete or inconsistently applied in legacy PHP/MySQL-style code.
Exploit preconditions
- Attack surface: HTTP(S) interface of the Online Hospital Management System, specifically requests to /patient.php.
- Required access: Network access to the web application; depending on deployment, the attacker may need to be an authenticated user if /patient.php is not publicly reachable.
- Trigger point: Supplying crafted values in the editid parameter (e.g., query string or POST body) that are interpreted as part of an SQL statement.
- Why exploitation is possible: The application likely interpolates the editid value directly into SQL without using prepared statements or proper escaping, allowing the attacker's input to alter the structure of the query rather than being treated as data.
Why this happens
This issue stems from constructing SQL queries by concatenating raw user input into query strings within server-side code.
Instead of using parameterized statements, the /patient.php implementation appears to trust the editid parameter and embed it directly into SQL clauses, which corresponds to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
The mention of CWE-74 also reflects insufficient neutralization of special elements in output contexts, but the primary bug class is treating untrusted data as executable SQL logic.
Potential impact
- The attacker may read sensitive patient or hospital records that would normally require higher privileges.
- The attacker could modify, insert, or delete patient data, impacting data integrity and clinical workflows.
- The attacker might escalate privileges by manipulating user or role tables, if accessible.
- The attacker could potentially execute database-specific functions that impact availability, such as causing application errors or locking tables.
- In some environments, the attacker might pivot to underlying system access if unsafe database features or stored procedures are exposed.
General mitigation guidance
Effective mitigation focuses on isolating untrusted input from query execution and reducing trust in user-controlled fields:
- Use parameterized queries or prepared statements for all database interactions involving user input, including IDs such as editid.
- Apply strict server-side validation and type enforcement (e.g., ensuring editid is an integer within expected bounds) before using it in any database context.
- Centralize database access through a data access layer that enforces safe query construction patterns by default.
- Implement least-privilege access for the application's database account so that, even if a query is abused, the account cannot perform unnecessary operations.
- Avoid building dynamic SQL with concatenated strings; where dynamic behavior is unavoidable, restrict allowed values (e.g., via whitelists) and keep them separate from data parameters.
How teams detect issues like this
Organizations can detect this class of vulnerability through several complementary approaches:
- Static application security testing (SAST) rules that flag string concatenation into SQL query builders, especially where HTTP parameters like editid flow directly into queries.
- Manual code review focused on database access layers and legacy PHP patterns (e.g., direct mysqli_* or PDO->query() calls with interpolated variables).
- Runtime application security testing (DAST) that sends crafted payloads in parameters such as editid and monitors for SQL error messages or anomalous responses.
- Database-side monitoring for unusual or malformed queries originating from the application, including tautologies or UNION-based query patterns.
- CI/CD policy checks that prevent merging code containing non-parameterized SQL where user input is present.

