Summary
A SQL injection vulnerability in the Hospital Information System allows attacker-controlled search input to influence database queries through the findBySearch function in addReq.php.
Because the affected functionality may be reachable remotely, an attacker could potentially retrieve, modify, or interfere with application data when input is not safely handled.
Affected context
The vulnerability occurs in Hospital Information System 1.0 where the findBySearch function processes the Search argument in addReq.php. Risk exists when this argument reaches database query construction without reliable parameterization or equivalent query separation, particularly when the endpoint is exposed to remote users.
Exploit preconditions
- Attack surface: The remotely reachable search functionality associated with
addReq.php - Required access: Access to submit requests containing a search value; authentication requirements depend on the deployment
- Trigger point: Processing of the
Searchargument by thefindBySearchfunction - Why exploitation is possible: Input may be incorporated into a database statement as query syntax rather than being treated strictly as data
Why this happens
The underlying bug is an injection flaw in which externally controlled search input is allowed to affect the structure or behavior of a SQL query. This pattern maps primarily to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection) and is also related to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component. The insecure design occurs when application data and database commands are combined without a trusted query interface that keeps them separate.
Potential impact
- An attacker may read data beyond the intended search results.
- An attacker could modify or delete database records if the database account permits those operations.
- Application functionality may be disrupted through database resource exhaustion or destructive queries.
- Sensitive patient, administrative, or operational information could be exposed.
- The application could become a stepping stone for further compromise if database permissions are excessive.
General mitigation guidance
Mitigation generally focuses on ensuring that user-supplied search values cannot alter SQL statement structure.
Common defensive patterns include:
- Use parameterized queries or prepared statements for all database operations.
- Apply a narrowly defined data-access layer that separates query code from values.
- Validate search inputs against the expected type, length, and character constraints without treating validation as a replacement for parameterization.
- Use database accounts with only the permissions required by the application.
- Avoid dynamically constructed SQL where a fixed query or safe query-builder abstraction is sufficient.
- Return generic database errors to users while recording useful security telemetry internally.
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis rules that flag string concatenation, interpolation, or formatting used to build SQL statements.
- Code review checks for request parameters flowing into database APIs without parameter binding.
- Dynamic testing of search endpoints using benign special-character and boundary inputs to identify unexpected query behavior.
- Web-application firewall or database monitoring policies that detect anomalous query patterns, while treating these controls as supplementary.
- Automated security review tools that trace user-controlled data into SQL execution sinks.

