Severity:

HIGH RISK

(7.3)

SQL Injection in ajax.php?action=login2 of Simple Doctors

CVE-2026-5180

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-74, CWE-89

Impact:

Authentication Bypass and Data Compromise via SQL Injection

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

SourceCodester Simple Doctors Appointment System 1.0 contains a SQL injection vulnerability in the admin login endpoint /admin/ajax.php?action=login2, where the email parameter is unsafely incorporated into database queries.

A remote attacker can send crafted values for the email argument to manipulate the underlying SQL query, which may lead to authentication bypass, data exfiltration, or modification of application data.

Affected context

The vulnerability occurs in the administrative login AJAX handler of the Simple Doctors Appointment System, specifically when processing the email parameter in /admin/ajax.php?action=login2.

It is relevant in deployments where user-supplied input is passed directly into SQL queries without parameterization or proper escaping.

The issue is most critical when the application is exposed over the network and connected to a production database containing real patient, appointment, or user account data.

Exploit preconditions

  • Attack surface: HTTP(S) requests to the web application's admin login endpoint /admin/ajax.php?action=login2.
  • Required access: Network access to the application; no prior authentication is strictly required if the endpoint is reachable pre-login.
  • Trigger point: Submission of crafted email parameter values via POST or GET (depending on implementation) to the vulnerable endpoint.
  • Why exploitation is possible: The email value is interpolated directly into SQL statements without prepared statements or adequate input validation, enabling attackers to alter query structure and logic.

Why this happens

This issue stems from constructing SQL statements by concatenating or interpolating raw user input into query strings.

Instead of using parameterized queries or prepared statements, the login logic appears to embed the email parameter directly into the WHERE clause, allowing attackers to inject their own SQL fragments.

This pattern maps directly to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, and also relates to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, because the application fails to neutralize SQL metacharacters before sending the query to the database engine.

Potential impact

  • Attackers may bypass authentication and gain administrative access to the application.
  • Sensitive data (such as user accounts, appointment details, or contact information) could be read from arbitrary database tables.
  • Database records, including users, appointments, and configuration, can potentially be modified or deleted.
  • The database server may be further leveraged for lateral movement if additional insecure features (e.g., file writes, OS command extensions) are enabled.
  • Application integrity and availability could be degraded through destructive queries (e.g., table truncation or dropping).

General mitigation guidance

Effective mitigation centers on eliminating direct concatenation of user input in SQL queries and reducing trust in incoming data:

  • Use parameterized queries or prepared statements for all database access, ensuring user inputs (such as email) are bound as parameters rather than embedded into SQL strings.
  • Apply robust server-side validation and normalization for login fields, constraining email to expected formats and lengths before interacting with the database.
  • Centralize database access logic in a data access layer with a standard, secure-by-default query API.
  • Follow the principle of least privilege for database accounts, restricting them to only the minimal operations required by the application (e.g., no schema modification privileges for the web-facing account).
  • Implement generic error handling that does not reveal raw SQL errors or stack traces to clients, reducing information useful for refining injection attempts.

How teams detect issues like this

Detection typically involves both code-centric and behavior-centric approaches:

  • Static analysis: Configure SAST tools or linters to flag raw SQL string concatenation, especially where variables from HTTP request parameters (e.g., $_POST['email'], $_GET['email']) flow into query construction.
  • Code review: During manual reviews, pay particular attention to authentication and admin endpoints; look for inline SQL built with string interpolation and absence of prepared statements.
  • Dynamic testing: Use application security testing tools (DAST) or manual penetration testing to probe parameters such as email with common SQL injection payload patterns and observe anomalies in responses or error messages.
  • Logging and monitoring: Monitor database logs for unusual query patterns, such as unexpected UNION statements, tautological WHERE clauses, or syntax errors indicative of testing for SQL injection.

Sources

SourceLink
github.comgithub.com/dyh1213-wq/cve/issues/4
vuldb.comvuldb.com/submit/780354
vuldb.comvuldb.com/vuln/354248
vuldb.comvuldb.com/vuln/354248/cti
sourcecodester.comsourcecodester.com/

Frequently asked

questions

If the /admin/ajax.php?action=login2 endpoint is reachable over the network without prior authentication, a remote attacker can interact with it directly. Exploitability then depends mainly on whether the vulnerable query is executed on every login attempt and how the database responds to injected input.

Not necessarily. Since the vulnerability exists in the login process itself, the attacker typically only needs the ability to send crafted HTTP requests to the affected endpoint. Valid credentials are not a prerequisite if the vulnerable code executes before authentication.

Replace all dynamic SQL constructions in the login flow with parameterized queries or prepared statements, and ensure that the email and related fields are strictly validated and bound as parameters. As part of this fix pattern, centralize database access to a vetted abstraction layer that discourages raw string concatenation.

Adopt a secure coding standard that mandates parameterized queries for all database operations, enforce it with code review and automated checks, and provide developers with high-level database APIs that make the secure path the default. Combine this with regular security testing, including SAST and DAST, to catch injection patterns early in the development lifecycle.

Find out what's already
exploitable in your codebase.