Severity:

HIGH RISK

(7.3)

SQL Injection in SourceCodester Pharmacy Sales and

CVE-2026-7194

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-74, CWE-89

Impact:

Data Exposure 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=save_product endpoint via the ID parameter.

A remote attacker can manipulate this parameter to interfere with database queries, potentially accessing, modifying, or deleting backend data when the application passes untrusted input directly into SQL statements.

Affected context

The vulnerability occurs in the web-based Pharmacy Sales and Inventory System when handling AJAX requests to /ajax.php?action=save_product.

It manifests where user-controlled data (the ID argument) is used to construct SQL queries without robust input validation, output encoding, or parameterization.

Any deployment that exposes this endpoint over the network and relies on dynamically built SQL queries is at risk, especially when the application runs with elevated database privileges.

Exploit preconditions

  • Attack surface: Public or internal web interface exposing /ajax.php?action=save_product
  • Required access: Ability to send crafted HTTP requests to the vulnerable endpoint (typically unauthenticated or low-privilege web access, depending on configuration)
  • Trigger point: Submission of a malicious ID parameter value in a request to ajax.php with action=save_product
  • Why exploitation is possible: The server-side code interpolates the ID argument directly into SQL statements without using prepared statements or sufficient validation, allowing attackers to alter the intended query structure

Why this happens

This issue is rooted in constructing SQL queries by concatenating or interpolating user-provided input directly into the query string.

Instead of treating the ID parameter as data, the application effectively allows parts of it to be interpreted as SQL syntax, matching CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

The broader pattern relates to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, where untrusted input is passed into a downstream interpreter (the SQL database) without proper neutralization or parameterization.

Potential impact

  • Disclosure of sensitive pharmacy and inventory data (e.g., product records, transaction details)
  • Unauthorized modification or deletion of database records
  • Creation of fraudulent entries that affect inventory, pricing, or sales reports
  • Potential elevation of privileges within the application if user or role data is stored in the same database
  • Denial of service by corrupting critical tables or causing heavy, resource-intensive queries

General mitigation guidance

Effective mitigation focuses on strictly separating data from SQL logic and reducing trust in user input:

  • Use parameterized queries or prepared statements for all database access, ensuring user-supplied values are always bound as parameters
  • Centralize input handling and enforce strict type validation for identifiers like ID (e.g., numeric-only checks with server-side enforcement)
  • Apply a least-privilege model for database accounts so that the web application cannot perform operations beyond what is necessary
  • Introduce an abstraction layer or ORM that defaults to safe query construction patterns and discourages raw SQL string concatenation
  • Implement consistent input validation and encoding policies for all entry points, including AJAX endpoints, not just form submissions

How teams detect issues like this

Organizations can identify this class of vulnerability using layered detection approaches:

  • Static analysis: Configure rules to flag dynamic SQL string construction that concatenates request parameters (e.g., $_GET, $_POST, or AJAX payloads) without parameterization
  • Code review: Systematically review data access layers and AJAX handlers for raw SQL usage, focusing on functions like save_product and other CRUD operations on core entities
  • Dynamic testing: Use automated or manual penetration testing tools to send crafted payloads in the ID parameter and observe anomalous database error messages or response time variations
  • Runtime monitoring: Enable database query logging and alert on queries containing suspicious patterns (unexpected operators, stacked statements) originating from web application accounts

Sources

SourceLink
github.comgithub.com/bfs045313-wq/cv3-protect/issues/2
vuldb.comvuldb.com/submit/800977
vuldb.comvuldb.com/vuln/359798
vuldb.comvuldb.com/vuln/359798/cti
sourcecodester.comsourcecodester.com/

Frequently asked

questions

Yes. As long as the web interface exposing /ajax.php?action=save_product is reachable over the network, an attacker can send malicious requests to attempt SQL injection.

It depends on the specific deployment and access controls around the save_product action. If the endpoint is reachable to unauthenticated or low-privileged users, those users could attempt exploitation.

Refactor the affected code to use parameterized queries or prepared statements everywhere the ID parameter (and other user inputs) are used in SQL, combined with strict server-side validation of expected types and ranges.

Adopt a development standard that prohibits raw SQL concatenation with user input, enforce secure coding guidelines via code reviews and static analysis, and use frameworks or ORMs that encourage parameterization by default.

Find out what's already
exploitable in your codebase.