Submeter #1062369: SourceCodester Online Food Ordering System 1.0 xssinformação

TítuloSourceCodester Online Food Ordering System 1.0 xss
Descrição# [G12] The food search term is reflected into HTML without output encoding **Assessment:** Confirmed by source audit; present as a YASA candidate but left pending by the final Agent investigation. **Vulnerability type:** Reflected Cross-Site Scripting (XSS) (CWE-79). ## Description The public search handler SQL-escapes the submitted term for its database query, then writes the same value directly into an HTML heading. SQL escaping protects a different parser; it does not encode `<`, `>`, or other HTML syntax. A crafted search response can therefore contain attacker-controlled markup. ## Source evidence and analysis Repository root: `targets/web-scan-20261028/web/`. `food-search.php` (lines 5–8) reads and renders the POST value: ```php <?php $search = mysqli_real_escape_string($conn, $_POST['search']); ?> <h2>Foods on Your Search <a href="#" class="text-white">"<?php echo $search ?>"</a> </h2> ``` The value is also used in the `LIKE` query at lines 21–22. That SQL escaping is not HTML encoding: the browser parses the raw value in the heading as markup. The reflection occurs before the results are rendered, so it does not depend on a matching database row. ## Reproduction (local instance only) Send this POST in a browser to the local test server (a `curl` request below lets you inspect the response source, but `curl` does not execute JavaScript): ```bash BASE=http://127.0.0.1:8080 curl -i -X POST "$BASE/food-search.php" \ --data-urlencode 'search=<svg onload=alert(document.domain)>x</svg>' ``` Open the equivalent POST response in a browser on the local instance. The heading contains an SVG element; its `onload` handler runs when inline event handlers are permitted. For a browser-based check, submit the same value through the search form using a disposable local page or the browser's request editor. No stored database value is required. ## Impact and scope A victim who is induced to submit or open a crafted search request can execute script in the application's origin. Depending on the victim's session and browser policy, that script can read page-visible data or issue same-origin requests as the victim. A restrictive Content Security Policy could block this payload, but none is established by the reviewed application source. ## Recommended fix HTML-encode the value at the text-node output, for example with `htmlspecialchars($search, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8')`. Keep SQL parameterization for the `LIKE` query as a separate control. Do not reuse SQL-escaped values as browser-safe output.
Fonte⚠️ https://gist.github.com/Ka7arotto/c74ecc431ff3df8150a66bd3063113c5/edit
Utilizador
 Goku (UID 80486)
Submissão28/10/2026 13h36 (há 29 dias)
Moderação26/11/2026 09h36 (29 days later)
EstadoAceite
Entrada VulDB444234 [SourceCodester Online Food Ordering System 1.0 Food Search food-search.php search Script de Site Cruzado]
Pontos20

Do you need the next level of professionalism?

Upgrade your account now!