/

CVE-2026-30532

Severity:

CRITICAL RISK

(9.8)

SQL Injection in SourceCodester Online Food Ordering System

CVE-2026-30532

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Compromise and Potential Remote Code Execution via SQL Injection

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 SQL Injection vulnerability in SourceCodester Online Food Ordering System v1.0 allows untrusted data from the id parameter in admin/view_product.php to be embedded directly into SQL queries.

Under typical deployments, an attacker who can control this parameter may manipulate database queries, potentially leading to data exfiltration, modification, or full compromise of the underlying database.

Affected context

The vulnerability occurs in the administrative product viewing functionality (admin/view_product.php) of the Online Food Ordering System v1.0.

It is exposed when the application builds SQL statements using the id request parameter without proper parameterization or input validation.

In many installations, this page may be reachable after authentication, but weak access controls, shared accounts, or reused endpoints can widen exposure beyond intended administrators.

Exploit preconditions

  • Attack surface: HTTP(S) interface of the Online Food Ordering System, specifically requests handled by admin/view_product.php.
  • Required access: Ability to send crafted requests that influence the id parameter; in some configurations this may require admin or staff credentials, in others misconfigurations or shared links may expose it more broadly.
  • Trigger point: Server-side execution of a dynamically constructed SQL query where the id value is concatenated directly into the query string.
  • Why exploitation is possible: The application trusts the id parameter and incorporates it into SQL without using prepared statements or robust input handling, matching the pattern described in CWE-89 (Improper Neutralization of Special Elements used in an SQL Command).

Why this happens

The root cause is the construction of SQL statements using string concatenation with untrusted input from the id parameter in admin/view_product.php.

Instead of using bound parameters or prepared statements, the code likely interpolates the id value directly into the query (e.g., in a WHERE clause), allowing SQL control characters and fragments supplied by an attacker to alter the intended query structure.

This is a classic instance of SQL Injection as described by CWE-89, where data and control planes are not separated, enabling external input to influence the logic of database commands.

Potential impact

  • Extraction of sensitive customer information, including orders and associated personal data.
  • Unauthorized viewing, modification, or deletion of product, order, and user records.
  • Creation of new administrative or application accounts within the database.
  • Bypassing of authentication or authorization checks enforced at the application or data layer.
  • Potential execution of database-specific functions leading to file read/write or code execution on the underlying server, depending on DBMS configuration.
  • Disruption of service availability through destructive queries, such as dropping or truncating tables.

General mitigation guidance

Effective mitigation centers on consistently separating untrusted input from SQL command structure and hardening database interactions:

  • Adopt parameterized queries or prepared statements for all database operations, ensuring the id and other user-controlled fields are always passed as bound parameters.
  • Apply strict server-side validation and type enforcement for identifiers like id (e.g., ensuring they conform to expected numeric or UUID formats rather than arbitrary strings).
  • Introduce a minimal data access layer or repository pattern that centralizes query construction and prohibits ad-hoc string-concatenated SQL.
  • Limit database privileges for the application account to only the operations truly required (least-privilege), reducing impact if injection occurs.
  • Where feasible, segment sensitive data across schemas or databases and restrict cross-access to limit blast radius.
  • Consider using stored procedures designed to accept only typed parameters and not dynamic SQL fragments as a defense-in-depth measure.

How teams detect issues like this

Detection can combine static code inspection, dynamic testing, and runtime monitoring:

  • Use static analysis rules or secure code scanning tools to flag string concatenation in SQL queries and direct interpolation of request parameters such as $_GET['id'] or $_POST['id'].
  • During code review, explicitly check data access layers and controller code for any query fragments built from request parameters, ensuring all queries use parameter binding.
  • Integrate automated security testing (DAST) that attempts SQL Injection payloads against endpoints, including authenticated admin paths like admin/view_product.php.
  • Configure logging around database errors and anomalous query patterns (e.g., unexpected UNIONs, OR 1=1 clauses) and feed them into SIEM systems for correlation.
  • Apply Web Application Firewall (WAF) rules tuned to detect common SQL Injection patterns while monitoring for false positives, using them as an additional detection and mitigation layer.

Sources

SourceLink
github.comgithub.com/meifukun/Web-Security-PoCs/blob/main/Online-Food-Ordering-System/SQLi-ViewProduct-id.md

Frequently asked

questions

Yes, if an attacker can send HTTP requests to the affected application and reach the admin/view_product.php endpoint, they can attempt to exploit the SQL Injection through the id parameter. Whether this is directly reachable from the internet depends on deployment and access control configuration.

In many setups, administrative pages are intended to require authentication; however, weak or misconfigured access controls, shared admin links, or reuse of the same logic in non-admin paths can inadvertently expose the vulnerable parameter. From a defensive standpoint, it is safest to assume that if any untrusted user can influence id, the risk exists.

The most robust fix is to replace all string-concatenated SQL with parameterized queries or prepared statements and enforce strict typing/validation on all user-controlled inputs. The id parameter should be treated as data only, bound via placeholders, and never concatenated into SQL strings.

Standardize on a secure data access abstraction that only exposes parameterized query interfaces, enforce coding guidelines that forbid inline SQL concatenation, and integrate security testing (static analysis, dynamic scanning, and targeted code reviews) into the development pipeline. Coupling these practices with least-privilege database accounts and logging helps detect and limit the impact of any missed instances.

Find out what's already
exploitable in your codebase.