Severity:

HIGH RISK

(7.3)

SQL Injection in delete_category Endpoint of Pharmacy Sales

CVE-2026-7130

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-74, CWE-89

Impact:

Data Exfiltration and Database Compromise

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 Pharmacy Sales and Inventory System 1.0 contains a SQL injection vulnerability in the /ajax.php?action=delete_category functionality, where the ID parameter is used unsafely in database queries.

A remote attacker who can send crafted HTTP requests to this endpoint may manipulate backend SQL statements, potentially leading to data access, modification, or application compromise.

Affected context

This vulnerability occurs in the backend AJAX handler of the Pharmacy Sales and Inventory System when processing delete operations for product categories.

The ID parameter provided by the client is incorporated into SQL statements without sufficient input validation, sanitization, or parameterization.

The issue is relevant in deployments where the /ajax.php endpoint is network-accessible and protected only by standard application authentication, without additional query hardening or database-layer controls.

Exploit preconditions

  • Attack surface: HTTP(S) endpoint at /ajax.php?action=delete_category within the Pharmacy Sales and Inventory System web interface.
  • Required access: Ability to send requests to the application; in many cases this may require only basic user access, depending on how the delete_category action is exposed.
  • Trigger point: Submission of a crafted ID parameter value in a request handled by ajax.php for the delete_category action.
  • Why exploitation is possible: The ID argument is directly embedded into a SQL query (or concatenated into the query string) without using prepared statements or proper escaping, allowing attacker-controlled input to alter query structure.

Why this happens

The underlying issue is unsafe construction of SQL queries with user-supplied data, a classic case of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Instead of using parameterized queries, the code likely concatenates the raw ID parameter into the SQL command, trusting the client to provide a numeric identifier.

In combination with CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, the failure to neutralize SQL metacharacters lets the attacker inject additional SQL clauses or statements that the database faithfully executes.

Potential impact

  • Extraction of sensitive pharmacy and customer data from the database
  • Unauthorized modification or deletion of inventory, sales, or category records
  • Creation of rogue administrative accounts or escalation of application privileges via database tampering
  • Bypassing authentication or authorization checks that rely on database queries
  • Potential execution of destructive operations such as dropping tables or truncating critical data
  • Using database access as a pivot to further compromise the hosting environment, depending on configuration

General mitigation guidance

Effective mitigation focuses on eliminating dynamic SQL construction and tightening trust boundaries around user input:

  • Use parameterized queries or prepared statements for all database operations, treating the ID as a bound parameter rather than concatenated text.
  • Enforce strict server-side validation on the ID parameter (e.g., numeric type checks and range validation) before it reaches any database layer.
  • Apply centralized input-neutralization routines for data destined for SQL, while preferring parameterization over manual escaping.
  • Implement least-privilege database accounts so that the application user has only the minimum rights needed for CRUD operations, reducing the blast radius of a successful injection.
  • Introduce an abstraction layer or ORM that encourages safe query building patterns by default.
  • Add server-side authorization checks around delete operations so only appropriately privileged users can trigger category deletion.

How teams detect issues like this

Organizations can use a combination of code-centric and runtime approaches to detect this vulnerability pattern:

  • Static code analysis to flag direct string concatenation of request parameters into SQL queries, especially around ID fields and AJAX handlers.
  • Manual code review focusing on server-side controllers like ajax.php and looking for:
  • Raw access to $_GET/$_POST/$_REQUEST variables
  • SQL strings built with interpolation or concatenation
  • Absence of prepared statements or query binding functions
  • Security testing and dynamic analysis (DAST) to probe endpoints such as /ajax.php?action=delete_category with test payloads, watching for SQL errors or anomalous responses.
  • Web application firewall (WAF) policies that monitor and optionally block suspicious SQL-like patterns in parameters such as ID.
  • Integration of automated scanning tools into CI/CD pipelines to catch new instances of unsafe SQL construction before deployment.

Sources

SourceLink
github.comgithub.com/lonelyuan/vunls/issues/11
vuldb.comvuldb.com/submit/800975
vuldb.comvuldb.com/vuln/359729
vuldb.comvuldb.com/vuln/359729/cti
sourcecodester.comsourcecodester.com/

Frequently asked

questions

The exploit has been publicly disclosed, which lowers the barrier for attackers. If the endpoint is reachable and not strongly access-controlled, exploitation can be straightforward, depending on database configuration and available privileges.

It depends on how the Pharmacy Sales and Inventory System is deployed. In some setups, invoking delete_category may require an authenticated session; in less secure deployments, the endpoint could be reachable with minimal or no authentication. In either case, any user capable of calling this endpoint can potentially attempt exploitation.

Replace all dynamic SQL string concatenation involving the ID parameter with parameterized queries, add strict type and range validation for ID, and ensure that delete operations are guarded by robust authorization checks. These changes address both the immediate injection vector and improper access to deletion functionality.

Adopt a development standard that mandates prepared statements for all database access, centralize input validation, and perform regular security-focused code reviews. Complement these practices with automated static and dynamic analysis, and enforce least-privilege database permissions so that even if an injection occurs, its impact is limited.

Find out what's already
exploitable in your codebase.