Severity:

HIGH RISK

(7.3)

SQL Injection in SourceCodester Pharmacy Sales and

CVE-2026-7550

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-74, CWE-89

Impact:

Confidentiality, Integrity, and Availability compromise of the backend database 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=save_customer endpoint via the ID parameter.

A remote attacker can manipulate this parameter to inject arbitrary SQL queries, potentially accessing or modifying backend database data when the vulnerable code path is invoked.

Affected context

The vulnerability exists in the web-based Pharmacy Sales and Inventory System when handling customer-related AJAX requests through /ajax.php?action=save_customer.

It appears in deployments where user-controlled input (the ID argument) is directly incorporated into database queries without robust parameterization or sanitization.

The issue is typically exposed on internet- or intranet-facing instances where the application's AJAX endpoints are reachable over HTTP/S and customer data operations are performed dynamically.

Exploit preconditions

  • Attack surface: HTTP/S endpoint at /ajax.php?action=save_customer
  • Required access: Network-level access to the web application (no special privileges implied by the description)
  • User-controlled input: The ID parameter supplied to the endpoint can be crafted by an attacker
  • Trigger point: Execution of database queries that embed the ID value into SQL statements without safe parameterization
  • Why exploitation is possible: The server-side logic constructs SQL queries by concatenating or interpolating the ID value directly into SQL, violating strong separation between code and data as described by CWE-89.

Why this happens

The root cause is improper neutralization of special elements used in SQL commands (CWE-89).

The backend logic for /ajax.php?action=save_customer relies on building SQL statements using raw request parameters, likely concatenating the ID argument into WHERE or INSERT/UPDATE clauses.

Because no parameterized queries, stored procedures with strict parameter binding, or equivalent defenses are applied, database interpreters treat crafted input as part of the SQL command itself.

This pattern aligns with command/markup injection (CWE-74), where untrusted data is introduced into a structured language context without appropriate escaping or binding, enabling arbitrary query manipulation.

Potential impact

  • Unauthorized reading of sensitive customer or inventory records from the database
  • Modification or deletion of customer, sales, or inventory data, affecting business integrity
  • Creation of fraudulent records (e.g., fake customers or transactions)
  • Potential extraction of authentication hashes or session-related data stored in the database
  • Database service disruption via destructive queries (e.g., table drops or heavy, resource-intensive queries)
  • Use of the database as a pivot point for further attacks if additional flaws (e.g., xp_cmdshell, file write capabilities) exist

General mitigation guidance

Effective mitigation focuses on eliminating direct injection channels and reducing trust in all external input:

  • Prefer parameterized queries or prepared statements for all database access paths, ensuring that user data is always bound as data, not code.
  • Centralize database access through a data access layer that enforces safe query construction patterns across the application.
  • Apply strict server-side validation for parameters like ID (e.g., enforce numeric types, length, and format constraints) before they reach the database layer.
  • Use context-appropriate escaping only as a secondary safeguard, not as the primary defense, when constructing dynamic fragments.
  • Restrict database account privileges so the application can perform only necessary operations, limiting damage if a query is successfully manipulated.
  • Adopt secure-by-default coding guidelines and development frameworks that encourage ORM usage or other safe abstractions for database interactions.

How teams detect issues like this

Detection typically combines code-level inspection with behavioral monitoring:

  • Static analysis rules that flag any SQL query constructed via string concatenation or interpolation of request parameters (especially ID fields) within PHP or similar server-side code.
  • Manual code review checklists that require verification of prepared statement usage for all queries in endpoints such as /ajax.php, with special attention to AJAX handlers that commonly evolve rapidly.
  • CI/CD pipeline policies that block merges when unsafe SQL patterns are detected or when new endpoints bypass the shared database abstraction layer.
  • Dynamic testing using web vulnerability scanners or custom fuzzers to probe parameters like ID for error-based, boolean-based, or time-based injection behaviors.
  • Monitoring of database logs and application logs for anomalous query patterns (e.g., unexpected OR 1=1 clauses, stacked queries, or syntax errors involving user-controlled values).

Sources

SourceLink
github.comgithub.com/khairulazly760530-cell/cves/issues/2
vuldb.comvuldb.com/submit/805539
vuldb.comvuldb.com/vuln/360360
vuldb.comvuldb.com/vuln/360360/cti
sourcecodester.comsourcecodester.com/

Frequently asked

questions

Yes. The vulnerable AJAX endpoint is reachable over the network, and an attacker can send crafted HTTP requests containing malicious ID parameter values without needing local access to the server.

An attacker generally needs only the ability to interact with the web interface or directly invoke /ajax.php?action=save_customer over HTTP/S. No prior authentication is explicitly required by the description, though real-world deployments might place this endpoint behind a login.

The most robust fix is to refactor all affected queries to use prepared statements or parameterized queries, ensuring that user input is always bound as typed parameters rather than concatenated into SQL strings. This should be accompanied by input validation and constrained database privileges.

Preventive measures include adopting secure coding standards that mandate parameterized queries, using ORMs or query builders that enforce binding by default, integrating static analysis tools into the build pipeline to flag unsafe database access patterns, and training developers to treat all external input as untrusted, regardless of source.

Find out what's already
exploitable in your codebase.