Summary
A high-severity SQL injection vulnerability affects the patient login functionality of code-projects Doctor Appointment System 1.0. An attacker who can reach the login endpoint remotely may manipulate the email input to alter database queries, potentially exposing or changing application data.
Affected context
The vulnerability occurs in the patient login workflow at /patient_login.php, where the email argument is processed in a database-backed request. Deployments are at risk when this input reaches query construction without robust parameterization and when the endpoint is accessible over a network.
Exploit preconditions
- Attack surface: Remote web application endpoint
- Required access: Network access to the patient login function; a valid account is not necessarily required
- Trigger point: Processing of the
emailparameter in/patient_login.php - Why exploitation is possible: User-controlled input may influence database query structure instead of being handled solely as a value
Why this happens
The underlying bug is a failure to separate SQL instructions from untrusted input. When application code incorporates the email value into a database query without dependable parameter binding or equivalent safeguards, attackers may influence query behavior. This maps primarily to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection); the broader CWE-74 classification covers injection into command or query interpreters.
Potential impact
- An attacker may bypass intended authentication checks
- Sensitive patient or appointment records could be disclosed
- Database records could be modified or deleted
- Application integrity and availability could be affected
- Database credentials or connected services could be exposed depending on permissions
General mitigation guidance
Mitigation generally centers on treating all request parameters as untrusted data and preventing them from changing query structure.
Common defensive patterns include:
- Use parameterized queries or prepared statements for every database operation
- Apply allowlist-based validation appropriate to the expected email format
- Avoid building SQL statements through string concatenation or interpolation
- Use database accounts with only the permissions required by the application
- Return generic authentication errors and avoid exposing database details
- Centralize database access controls and apply secure-by-default query APIs
How teams detect issues like this
Detection can include static analysis for SQL strings assembled with request parameters, unsafe string concatenation near database APIs, and database calls that lack parameter binding. Code reviews should examine authentication handlers, input validation boundaries, error handling, and database account privileges. Web application monitoring and database audit logs can help identify abnormal query errors, unexpected authentication patterns, and unusual record access. Automated security scanning and policy checks can provide additional coverage without replacing manual review.

