/

CVE-2026-30531

Severity:

HIGH RISK

(8.8)

SQL Injection in SourceCodester Online Food Ordering System

CVE-2026-30531

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Authentication-bypassing Data Access and Modification via SQL Injection

Severity:

HIGH RISK

(8.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 the save_category action of Actions.php in SourceCodester Online Food Ordering System v1.0 allows untrusted data in the name parameter to be embedded directly into database queries.

An authenticated attacker who can submit crafted category names may inject arbitrary SQL, potentially leading to data exfiltration, modification, or application compromise.

Affected context

This issue arises in the category management functionality of the Online Food Ordering System when processing requests to Actions.php with the save_category action.

The vulnerability is present when the application constructs SQL statements using the name parameter directly (e.g., from POST or GET data) without proper parameterization or robust input handling.

It primarily affects deployments where authenticated users can create or edit categories and where the application's database account has broad permissions on the backing database.

Exploit preconditions

  • Attack surface: Web application HTTP interface (typically via POST/GET requests to Actions.php).
  • Required access: Authenticated access with the ability to invoke the save_category action (e.g., user roles allowed to add or edit categories).
  • Trigger point: Submission of a specially crafted name parameter value during category creation or update.
  • Why exploitation is possible: The application interpolates the name value directly into SQL queries without using parameterized statements or adequate escaping, allowing attacker-controlled input to alter the structure of the SQL command.

Why this happens

The root cause is the dynamic construction of SQL queries using string concatenation that directly incorporates user-supplied data from the name parameter.

This corresponds to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where inputs containing SQL metacharacters (such as quotes, operators, or comment markers) are not properly separated from query logic.

Instead of relying on parameterized queries or prepared statements, the code trusts that the incoming name field is benign, allowing attackers to extend or modify the intended query.

Potential impact

  • Unauthorized reading of sensitive data stored in the application's database (e.g., user details, orders, menus).
  • Modification or deletion of data, including categories, menu items, or orders.
  • Creation of new accounts or modification of existing user roles, depending on schema and query context.
  • Bypassing application-level authorization checks enforced at the data layer.
  • In extreme cases, execution of database-specific administrative commands that could impact database availability or integrity.

General mitigation guidance

Effective mitigation centers on treating all user-controlled data as untrusted and separating it from query logic:

  • Use parameterized queries or prepared statements for all database operations involving external input, including the name parameter in save_category.
  • Apply strict server-side validation and normalization for category names (e.g., length constraints, allowed characters) to reduce the attack surface.
  • Enforce least-privilege on the database account used by the application so that compromise of a single query has limited impact.
  • Centralize database access patterns (e.g., via a data access layer or ORM) to make it easier to apply and audit safe query construction patterns.
  • Avoid constructing ad-hoc SQL strings from request parameters; prefer stored procedures or ORM query builders where appropriate.

How teams detect issues like this

Organizations can detect and monitor for SQL injection risks using a combination of code-level and operational approaches:

  • Static analysis: Configure SAST rules to flag dynamic SQL building in PHP files, especially concatenation patterns involving $_POST, $_GET, or other request variables flowing into database APIs.
  • Code review: During manual reviews, look for SQL statements assembled with string concatenation in Actions.php and related controllers, and verify that parameter binding is consistently used.
  • Dynamic testing: Use automated scanners or manual penetration testing to send crafted input in the name parameter and observe for SQL error messages, anomalous responses, or unexpected data leakage.
  • Runtime monitoring: Enable database and application logging to detect unusual query patterns, especially those containing concatenated literals, comment markers, or always-true predicates.
  • Policy enforcement: Integrate automated tools in CI/CD pipelines that block new code introducing raw SQL with unbound parameters.

Sources

SourceLink
github.comgithub.com/meifukun/Web-Security-PoCs/blob/main/Online-Food-Ordering-System/SQLi-Actions-saveCategory-name.md

Frequently asked

questions

Yes. Any remote user who can authenticate and access the category-saving functionality over HTTP can potentially exploit this issue by sending crafted requests.

Yes. The described vulnerability is in a code path (save_category) that is typically accessible only to authenticated users who have permissions to manage categories.

Refactor all database interactions in the affected path to use parameterized queries or prepared statements instead of string concatenation, and enforce strict server-side validation for the name parameter.

Standardize on secure database access patterns (e.g., ORM or parameterized query APIs), treat all external input as untrusted, enforce automated static analysis rules against dynamic SQL construction, and include targeted security checks for injection vulnerabilities in code review and testing processes.

Find out what's already
exploitable in your codebase.