Severity:

HIGH RISK

(7.3)

SQL Injection in /ajax.php?action=login of Pharmacy Sales

CVE-2026-6189

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

The login endpoint in SourceCodester Pharmacy Sales and Inventory System 1.0 is vulnerable to SQL injection via the Username parameter in /ajax.php?action=login.

A remote attacker can manipulate this parameter to alter backend SQL queries, potentially bypassing authentication and accessing or modifying sensitive data.

Affected context

This vulnerability affects deployments of the Pharmacy Sales and Inventory System 1.0 that expose the /ajax.php?action=login endpoint over a network.

It manifests when user-supplied values from the Username field are included directly in SQL statements without robust parameterization or sanitization.

Typical installations running on common LAMP/WAMP stacks with default configurations and no additional web application firewalling are more likely to be impacted.

Exploit preconditions

  • Attack surface: Public or internal web interface at /ajax.php?action=login
  • Required access: Network access to the login AJAX endpoint (no prior authentication needed)
  • Trigger point: Submission of crafted input in the Username parameter during the login request
  • Why exploitation is possible: The application appears to concatenate the Username value into SQL queries without using prepared statements or proper escaping, allowing attackers to inject arbitrary SQL fragments

Why this happens

The core issue is improper neutralization of special elements used in SQL commands, mapping directly to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

The login logic likely builds SQL queries by string concatenation, embedding raw Username input into the query text.

This pattern treats user input as trusted, executable query syntax rather than as data, enabling attackers to break out of the intended query structure and supply their own conditions or operations.

CWE-74 (Improper Neutralization of Special Elements in Output) is also relevant, as untrusted data is not being safely handled when incorporated into backend command contexts.

Potential impact

  • Bypass of login authentication using crafted Username values
  • Unauthorized access to user or administrative accounts
  • Reading sensitive information from the database, such as customer, inventory, or transaction records
  • Modification or deletion of pharmacy sales and inventory data
  • Creation of backdoor accounts or manipulation of billing and stock information
  • Potential pivot to underlying host if database-level features or stored procedures are abused

General mitigation guidance

Effective mitigation focuses on eliminating direct string-based query construction and reducing the trust placed in user input entering database contexts.

Recommended patterns include:

  • Using parameterized queries or prepared statements for all database interactions, especially authentication logic
  • Centralizing data access in a minimal, well-reviewed database abstraction layer that enforces safe query patterns
  • Applying input validation for authentication fields, such as restricting Username to expected character sets and lengths
  • Separating application and database privileges so that the application account has only the minimal rights necessary (no schema changes, no unnecessary administrative privileges)
  • Implementing secure-by-default coding standards that prohibit ad hoc SQL string concatenation
  • Considering deployment of a Web Application Firewall (WAF) with rules tuned to detect and block common SQL injection patterns as a compensating control

How teams detect issues like this

Organizations can identify this class of vulnerability using a combination of static and dynamic approaches:

  • Static analysis rules that flag SQL query construction using string concatenation or interpolation with user-controlled variables (e.g., direct use of $_POST['Username'] in SQL strings)
  • Code review checklists that explicitly require verification of prepared statement usage for all authentication-related queries
  • Database activity monitoring configured to alert on anomalous queries containing tautologies, UNION-based exfiltration, or unexpected metadata access
  • Dynamic application security testing (DAST) that systematically probes input parameters like Username with SQL metacharacters and payloads to observe abnormal responses
  • Continuous integration hooks that block merges when unsafe database access patterns are detected by automated tools

Sources

SourceLink
github.comgithub.com/lingzezzz/lingze/issues/1
vuldb.comvuldb.com/submit/797377
vuldb.comvuldb.com/vuln/357111
vuldb.comvuldb.com/vuln/357111/cti
sourcecodester.comsourcecodester.com/

Frequently asked

questions

Yes. The vulnerability is reachable via the /ajax.php?action=login endpoint, and any attacker with network access to the application can attempt exploitation.

No. The issue occurs in the login routine itself, so exploitation can typically be attempted without prior authentication by sending crafted Username values.

The most robust fix is to refactor the login code to use parameterized queries or prepared statements, ensuring that user input is always bound as data parameters rather than concatenated into SQL strings. Complement this with strict validation of authentication inputs.

Establish development standards that forbid string-based SQL construction, enforce use of safe database APIs, and integrate automated scanning plus security-focused code reviews into the development lifecycle. Limiting database privileges and using defense-in-depth controls such as WAF rules further reduces risk from missed cases.

Find out what's already
exploitable in your codebase.