/

CVE-2025-65336

Severity:

CRITICAL RISK

(9.8)

SQL Injection (CWE-89) in Fruits Bazar price lookup

CVE-2025-65336

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Compromise and Data Exfiltration

Severity:

CRITICAL RISK

(9.8)

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

A critical SQL injection flaw in the Fruits Bazar PHP/Mysqli ecommerce project allows attackers to manipulate database queries through unvalidated product ID parameters.

When user-supplied input is directly concatenated into SQL in show_price_by_pdtId.php, an attacker can bypass application logic, exfiltrate data, or modify database contents.

Affected context

The vulnerability occurs in the price lookup functionality of the Fruits Bazar ecommerce project when product IDs from HTTP requests are used to build SQL queries without proper sanitization.

It is most relevant in deployments where:

  • The application is publicly accessible over the internet
  • The database account used by the PHP application has broad read/write privileges
  • Input validation or parameterization is missing or inconsistently applied in show_price_by_pdtId.php

Exploit preconditions

  • Attack surface: Web endpoint /show_price_by_pdtId.php accepting product identifiers via query string, form data, or AJAX requests
  • Required access: Network access to the web application; no special privileges are typically needed beyond reaching the endpoint
  • Trigger point: Execution of SQL queries that incorporate the attacker-controlled product ID directly into the query string
  • Why exploitation is possible: The application interpolates raw user input into SQL without prepared statements or robust escaping, allowing crafted input to alter the intended query structure

Why this happens

The root cause aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

In this case, the PHP code in show_price_by_pdtId.php constructs SQL statements by concatenating request parameters (such as product IDs) into query strings.

Without using prepared statements with bound parameters or strict input validation, special characters introduced by an attacker are interpreted as part of the SQL syntax, enabling injection of additional clauses or entirely different queries.

Potential impact

  • Attackers may read sensitive customer and order information from the database
  • Attackers could modify product prices, inventory records, or user data
  • Attackers can potentially create or escalate user accounts, including administrative roles
  • Attackers may delete or corrupt tables, leading to loss of availability and data integrity issues
  • Attackers could chain this access to further compromise the underlying server or other connected systems, depending on database permissions and configuration

General mitigation guidance

Effective mitigation focuses on treating all external input as untrusted and ensuring SQL queries are constructed safely by design.

Common defensive patterns include:

  • Consistently using prepared statements (parameterized queries) for all database operations instead of concatenating strings
  • Applying strict server-side validation and normalization for product IDs and similar parameters (e.g., enforcing numeric types)
  • Minimizing database privileges for the application account so that even a successful injection has limited effect
  • Centralizing data access logic in a well-reviewed layer to avoid ad hoc query construction across multiple PHP files
  • Adopting secure-by-default database access abstractions or ORM layers that discourage direct string-based query building

How teams detect issues like this

Organizations can detect SQL injection risks in applications like Fruits Bazar using a combination of:

  • Static analysis rules that flag dynamic SQL creation, especially concatenation of $_GET, $_POST, or other user-controlled variables
  • Code review checklists that require verification of prepared statements and proper validation for every database interaction
  • Runtime monitoring and logging for anomalous query patterns, such as unexpected use of UNION, OR 1=1, or comment sequences originating from web inputs
  • Security testing (including automated scanners and manual penetration testing) focused on input vectors reaching show_price_by_pdtId.php and similar endpoints
  • CI/CD integration of automated tools that enforce policies against unsafe query construction before code is merged

Sources

SourceLink
github.comgithub.com/um-dsp/TaintRadar/blob/main/sql_injection_cves/ecommercefruitsbazarmaster/20250811-ecommerce-project-with-php-and-mysqli-fruits-bazar-show_price_by_pdtid.php-pid-sqli/20250811-ecommerce-project-with-php-and-mysqli-fruits-bazar-show_price_by_pdtid.php-pid-sqli.md

Frequently asked

questions

It is typically widely exploitable anywhere the vulnerable endpoint is exposed, because attackers only need network access to the web application and can interact with the price lookup functionality directly.

In many ecommerce setups, product price lookup endpoints are publicly accessible; therefore, exploitation may not require authentication. However, if the endpoint is behind login, any user with access to it could potentially attempt injection.

The safest approach is to replace all string-concatenated SQL with prepared statements and bound parameters, combined with strict validation of input types (e.g., ensuring product IDs are integers) and reduced database privileges for the application user.

Establish development standards that mandate parameterized queries, centralize database access in a reviewed layer, apply consistent input validation, and integrate automated checks and security reviews into the development lifecycle so unsafe query patterns are caught before deployment.

Find out what's already
exploitable in your codebase.