Submit #1070048: SourceCodester Online Food Ordering System 1.0 Cross Site Scriptinginfo

TitleSourceCodester Online Food Ordering System 1.0 Cross Site Scripting
DescriptionTitle: Online Food Ordering System 1.0 — Reflected Cross-Site Scripting via search Parameter in food-search.php VENDOR INFORMATION: Vendor homepage: https://www.sourcecodester.com/ Product page: https://www.sourcecodester.com/php/18232/food-order-system.html VULNERABILITY TYPE: Reflected Cross-Site Scripting (XSS) CWE(s): CWE-79 — Improper Neutralization of Input During Web Page Generation (‘Cross-site Scripting’) CWE-116 — Improper Encoding or Escaping of Output SEVERITY: According to the CVSS v3.1 scoring system, this vulnerability has a severity rating of 6.1 (Medium) CVSS Score: 6.1 Vector String: AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N Severity Level: Medium AFFECTED ENDPOINT: /web/food-search.php VULNERABLE PARAMETER: search (POST) AFFECTED COMPONENT: Public Food Search Handler (customer-facing search feature, no authentication required) DESCRIPTION: A vulnerability has been found in SourceCodester Online Food Ordering System 1.0. Affected by this vulnerability is an unknown functionality of the file food-search.php. The manipulation of the argument search leads to cross-site scripting. The attack can be initiated remotely. No authentication is required for exploitation. The affected endpoint sanitizes the search parameter using mysqli_real_escape_string(), which neutralizes SQL-injection-relevant characters but performs no HTML entity encoding. The sanitized value is echoed directly into the page's response with no output escaping, allowing attacker-controlled HTML and JavaScript to execute in the browser of any user who submits, or is induced to submit, a crafted search term. Exploitation requires no prior authentication and was confirmed via a crafted search request returning unescaped script content in the server's raw HTTP response, as well as live script execution in a standard browser. ROOT CAUSE: $search = mysqli_real_escape_string($conn, $_POST['search']); ... <h2>Foods on Your Search <a href="#" class="text-white">"<?php echo $search ?>"</a></h2> mysqli_real_escape_string() is a SQL-context sanitization function; it is not designed for, and does not provide, HTML output encoding. The subsequent echo $search renders the value directly into the HTML response with zero escaping of <, >, or other HTML-significant characters, enabling arbitrary HTML/JavaScript injection into the rendered page. STEPS TO REPRODUCE: Step 1: Navigate to the public homepage (localhost/web/) and locate the food search field. Enter the following payload directly into the search box: <script>alert(1)</script> Step 2: Click Search. The page submits to food-search.php, which reflects the search value back into the response with no HTML encoding applied. The injected script executes immediately on page load, producing a JavaScript alert dialog. Step 3: Submit the following payload in the search box: <script>alert(document.cookie)</script> The resulting alert dialog displayed the application’s PHPSESSID value. Step 4: Replay the Step 1 request directly against the server via curl, with no browser involved, to confirm the raw HTTP response itself contains the unescaped payload (ruling out any browser-side rendering artifact): curl.exe -s -X POST "http://localhost/web/food-search.php" --data-urlencode "search=<script>alert(1)</script>" | Select-String "Foods on Your Search" The response confirms the server returns the payload completely unescaped: <h2>Foods on Your Search <a href="#" class="text-white">"<script>alert(1)</script>"</a></h2> PROOF OF CONCEPT: The injection was verified end-to-end on a clean, unauthenticated installation: 1) A baseline search request confirmed the search parameter is reflected verbatim into the page’s <h2> heading. 2) A raw HTTP response, captured via curl with no browser involved, confirmed the server returns <script> tags completely unescaped — ruling out any client-side rendering artifact as the cause. 3) Submitting <script>alert(1)</script> via the browser’s search form triggered an immediate JavaScript alert dialog, confirming live script execution in the victim’s browser context. 4) All results were reproduced consistently across both the browser and curl, confirming the vulnerability is stable and server-side in nature, not a browser- or client-side artifact. 5) Full technical write-up, including annotated screenshots of every step above, is published at the Advisory link provided with this submission. IMPACT: This vulnerability allows an unauthenticated remote attacker to execute arbitrary JavaScript in the browser of any victim who submits (or is induced to submit, e.g. via a self-submitting malicious HTML form hosted elsewhere) a crafted search term to this endpoint. Confirmed script execution in the victim’s browser context enables a range of attacks typical of reflected XSS, including content injection, page defacement, credential phishing via fake UI overlays, and redirection to attacker-controlled sites — all executing under the legitimate application’s origin, which increases their credibility to a victim. SUGGESTED REMEDIATION: 1) Output Encoding: Apply htmlspecialchars() (with ENT_QUOTES and the correct character set) to $search at the point of output, regardless of any SQL-layer sanitization already applied: <h2>Foods on Your Search <a href="#" class="text-white">"<?php echo htmlspecialchars($search, ENT_QUOTES, 'UTF-8') ?>"</a></h2> 2) Defense-in-Depth: Separate Sanitization Concerns: SQL sanitization (mysqli_real_escape_string(), or better, parameterized queries) and HTML output encoding (htmlspecialchars()) address entirely different attack surfaces and must both be applied independently wherever user input is both used in a query and rendered back into HTML — one does not substitute for the other. DISCOVERED BY: Ali Raza (Independent Security Researcher)
Source⚠️ https://medium.com/@developerali15/online-food-ordering-system-1-0-8013e5c6c379
User
 aliraza15 (UID 60676)
Submission11/02/2026 13:58 (26 days ago)
Moderation11/28/2026 08:10 (26 days later)
StatusDuplicate
VulDB entry444234 [SourceCodester Online Food Ordering System 1.0 Food Search food-search.php search cross site scripting]
Points0

Do you know our Splunk app?

Download it now for free!