Summary
The Hospitals Patient Records Management System 1.0 contains a SQL injection vulnerability in the /classes/Users.php?f=save endpoint, where the ID parameter is incorporated into database queries without adequate sanitization.
A remote attacker who can send crafted requests to this endpoint may manipulate SQL statements, potentially accessing, modifying, or deleting patient and user-related data.
Affected context
This vulnerability appears in the user management logic of the Hospitals Patient Records Management System, specifically in the save functionality exposed at /classes/Users.php?f=save.
It typically manifests when request parameters, such as ID, are passed directly into SQL queries on a relational database without using parameterized statements or robust input validation.
The issue is relevant in deployments where this PHP endpoint is reachable over a network and database credentials allow read or write operations on patient and user data.
Exploit preconditions
- Attack surface: HTTP(S) endpoint
/classes/Users.php?f=saveexposed by the web application. - Required access: Ability to send requests to the application (usually anonymous or low-privileged web access).
- Trigger point: Supplying specially crafted values in the
IDparameter (or related input) that are concatenated into SQL queries. - Why exploitation is possible: The application constructs SQL queries by directly embedding user-controlled input without parameterization or sufficient escaping, allowing modification of query structure.
Why this happens
The root cause aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
The save function in Users.php likely builds SQL statements through string concatenation, inserting the ID parameter and possibly other fields directly into the query.
Because these values are not handled with prepared statements or strict validation, attackers can inject SQL control characters and clauses, altering the intended query.
The reference to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component reflects that unsafe input flows into the database engine, a downstream interpreter, without appropriate neutralization.
Potential impact
- May read sensitive patient records and user account details from the database.
- Could modify or delete patient data, appointments, or user accounts.
- May create or escalate accounts with administrative privileges within the application.
- Could disrupt application functionality or cause data integrity issues by altering queries.
- In some environments, may lead to further compromise if database access can be chained to other weaknesses (e.g., reading configuration secrets).
General mitigation guidance
Effective mitigation focuses on breaking the direct trust between user input and SQL construction:
- Prefer parameterized queries or prepared statements for all database operations, ensuring user-controlled data is always treated as parameters, not query text.
- Apply strict server-side validation and normalization on identifier fields like
ID, enforcing expected formats (e.g., integers only) and rejecting unexpected input. - Centralize database access logic to reduce ad-hoc query building and allow consistent security patterns.
- Limit database privileges for the application user to only the operations and tables required, reducing impact if injection occurs.
- Consider introducing an abstraction or ORM that encourages safe-by-default query composition.
How teams detect issues like this
Organizations can identify this vulnerability class using a combination of code and behavior analysis:
- Static analysis: Configure rules to flag dynamic SQL construction in PHP files, especially where
$_GET,$_POST, or other request variables are concatenated into queries without parameterization. - Code review: Look for repeated patterns of
"SELECT ... WHERE id='$id'"or similar constructs, and verify that all user inputs flow through prepared statements or sanitized APIs. - Dynamic testing: Use automated security testing tools or fuzzers that send malformed or SQL-specific payloads to endpoints like
/classes/Users.php?f=saveand observe for database error messages or unexpected responses. - Policy enforcement: Establish coding standards requiring prepared statements and enforce them via pre-commit hooks, CI checks, or secure coding training.

