Summary
The Online Doctor Appointment System 1.0 contains a SQL injection vulnerability in the /admin/patient_action.php endpoint via the patient_id parameter.
A remote attacker can manipulate this parameter to inject arbitrary SQL, potentially accessing or modifying patient and administrative data without authorization.
Affected context
This vulnerability occurs in the administrative portion of the Online Doctor Appointment System 1.0, specifically within the /admin/patient_action.php script.
It manifests when the patient_id parameter is taken from HTTP requests and interpolated into database queries without robust input validation or parameterization.
The issue is present in deployments where the application directly constructs SQL statements using request parameters and where the database account has broad access to patient or administrative tables.
Exploit preconditions
- Attack surface: HTTP interface of the admin module, reachable over the network.
- Required access: Ability to send crafted requests to /admin/patient_action.php (with whatever level of access is needed to reach that endpoint in a given deployment).
- Trigger point: Handling of the patient_id parameter when building SQL queries in patient_action.php.
- Why exploitation is possible: The application appears to concatenate the patient_id value directly into SQL statements without using prepared statements or adequate escaping, allowing attacker-controlled input to alter the structure of the query.
Why this happens
The underlying issue is improper neutralization of special elements used in SQL commands, aligning with CWE-89 (Improper Neutralization of Special Elements used in an SQL Command).
Instead of using parameterized queries, the code likely interpolates the patient_id parameter directly into a SQL statement string, treating external input as trusted and allowing it to influence the command structure.
CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component) is also relevant because the untrusted input is propagated into a downstream SQL interpreter without appropriate sanitization or context-aware encoding.
Potential impact
- Access to sensitive patient records and associated personal or medical information.
- Unauthorized modification or deletion of patient or appointment data.
- Creation of arbitrary administrative entries or manipulation of user accounts, depending on schema and privileges.
- Extraction of application configuration data stored in the database, which could aid further compromise.
- Potential full compromise of the underlying database if the connected account has extensive privileges.
General mitigation guidance
Mitigation efforts typically focus on eliminating direct string concatenation in SQL and reducing trust in externally supplied data:
- Adopt parameterized queries or prepared statements for all database interactions involving user-controlled input, including patient_id.
- Apply strict server-side validation and normalization for identifier fields, enforcing expected formats (e.g., numeric-only IDs) before they reach the database layer.
- Implement least-privilege database accounts so that the application can only access the specific tables and operations it requires.
- Introduce centralized data access layers that encapsulate query construction and enforce safe query building patterns by default.
- Consider defense-in-depth measures such as query allowlists or ORM frameworks that generate SQL in a controlled manner.
How teams detect issues like this
Effective detection typically combines code-centric and behavior-centric approaches:
- Use static application security testing (SAST) tools or linters configured to flag dynamic SQL construction and unparameterized queries, especially around request parameters like patient_id.
- Incorporate manual code review checklists that highlight high-risk patterns such as string concatenation in SQL and direct use of $_GET/$_POST variables in query strings.
- Enable application and database logging to capture anomalous query patterns (e.g., unexpected operators, UNION clauses, or comment markers) that may indicate injection attempts.
- Apply web application firewalls (WAF) or API gateways with rules tuned to detect and block common SQL injection payload patterns, while treating them as a supplement, not a primary control.

