Severity:

HIGH RISK

(7.3)

SQL Injection in delete_customer Endpoint of Pharmacy Sales

CVE-2026-7549

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-74, CWE-89

Impact:

Data Exposure and Integrity 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 Pharmacy Sales and Inventory System 1.0 contains a SQL injection vulnerability in the /ajax.php?action=delete_customer endpoint, where the ID parameter is not safely handled before being used in a database query.

A remote attacker can manipulate this parameter to inject arbitrary SQL, potentially reading, modifying, or deleting data within the application's database.

Affected context

The issue occurs in the web application's AJAX handler at /ajax.php?action=delete_customer, specifically when processing the ID argument used to identify a customer record.

The vulnerability is present when incoming request parameters are directly concatenated into SQL statements without robust input validation, parameterization, or output encoding at the database boundary.

Any deployment that exposes this endpoint over a network and relies on a relational database backend is potentially affected, especially where database privileges are broad or shared across multiple tables.

Exploit preconditions

  • Attack surface: HTTP interface of the Pharmacy Sales and Inventory System, particularly the /ajax.php?action=delete_customer endpoint.
  • Required access: Ability to send crafted requests to the vulnerable endpoint; this may be unauthenticated or low-privileged depending on application access controls.
  • Trigger point: Submission of a malicious ID parameter value that is incorporated into an SQL query.
  • Why exploitation is possible: The application constructs SQL queries using string concatenation or interpolation with the raw ID parameter instead of using parameterized queries or strict type handling. As a result, attacker-controlled input can alter the structure of the SQL statement executed by the database.

Why this happens

This vulnerability stems from improper neutralization of special elements used in SQL commands (CWE-89) and insufficient output encoding or escaping in dynamically constructed queries (related to CWE-74).

In the delete_customer flow, the ID parameter appears to be trusted and embedded directly into a SQL statement, such as in a DELETE or SELECT query, without binding as a typed parameter.

This insecure pattern allows attacker-supplied input to break out of the intended query context and inject additional SQL operations, reflecting the classic SQL injection bug class where application logic blurs the boundary between data and code.

Potential impact

  • An attacker may delete arbitrary customer records from the database.
  • An attacker could extract sensitive information from other database tables, depending on the query and schema.
  • An attacker may modify or corrupt application data, impacting inventory accuracy and transaction integrity.
  • An attacker could escalate impact to full database compromise if the database user has extensive privileges.
  • An attacker may chain SQL injection with other weaknesses (e.g., weak authentication) to gain broader control over the application environment.

General mitigation guidance

Effective mitigation centers on strictly separating data from SQL command logic and minimizing trust in client-supplied parameters.

Recommended defensive patterns include:

  • Consistently using parameterized queries or prepared statements for all database operations, including simple DELETE calls based on IDs.
  • Enforcing strict server-side validation and type checking for identifier parameters (e.g., ensuring ID is a numeric value within expected bounds) before interacting with the database layer.
  • Centralizing database access through a data access layer that prohibits ad hoc string-built SQL and enforces safe query construction APIs.
  • Applying least-privilege principles to the database account used by the application, limiting its ability to access or modify unrelated tables or perform administrative operations.
  • Implementing defense-in-depth controls such as application-level error handling that avoids exposing raw SQL errors and database structure in responses.

How teams detect issues like this

Detection generally involves combining code-centric analysis with runtime monitoring:

  • Static analysis: Configure SAST tools or linters to flag dynamic SQL construction patterns (e.g., string concatenation with request parameters, $_GET/$_POST usage in query strings) and enforce the use of prepared statements.
  • Code review: During manual review, focus on AJAX handlers and CRUD endpoints to identify where request parameters like ID are directly interpolated into SQL queries without parameter binding or validation.
  • Security testing: Use targeted dynamic testing (DAST) to send crafted payloads through the /ajax.php?action=delete_customer endpoint, observing for anomalous responses, SQL errors, or data changes that indicate injectable queries.
  • Operational monitoring: Monitor database logs and web server logs for suspicious query patterns, such as unexpected operators, comment markers, or always-true conditions in WHERE clauses, which may suggest exploitation attempts.

Sources

SourceLink
github.comgithub.com/khairulazly760530-cell/cves/issues/3
vuldb.comvuldb.com/submit/805538
vuldb.comvuldb.com/vuln/360359
vuldb.comvuldb.com/vuln/360359/cti
sourcecodester.comsourcecodester.com/

Frequently asked

questions

Yes. The vulnerable endpoint is exposed over HTTP, so any attacker who can reach the application over the network can attempt to exploit the SQL injection, subject to authentication or access controls configured on that route.

The attacker needs the ability to send requests to /ajax.php?action=delete_customer with a controllable ID parameter. If the endpoint is accessible without strong authentication or authorization, even unauthenticated users may be able to exploit it.

Replace all string-built SQL that incorporates user-controlled input with parameterized queries or prepared statements, ensure that the ID parameter is handled as a strictly typed value, and encapsulate query construction in a data access layer that enforces these patterns by design.

Establish development standards mandating parameterized queries, incorporate secure coding training for SQL interactions, enforce static analysis checks in the CI/CD pipeline to block unsafe query construction, and perform regular security-focused code reviews of all endpoints that interact with the database.

Find out what's already
exploitable in your codebase.