Cross-Site Scripting Via Unsanitized Input In a PHP Endpoint
A PHP endpoint reflected the user-supplied 'files' parameter into the HTML response without encoding, allowing an attacker to inject and execute arbitrary JavaScript in a victim's browser. The report demonstrates this with a simple image tag that triggers an alert.
Published on ajay-vardhan01.medium.com
Cross-Site Scripting (XSS) is a client-side vulnerability that allows attackers to inject malicious JavaScript into web applications. When user-supplied input is reflected back into the response without proper sanitization, an attacker can execute arbitrary scripts in a victim’s browser.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
User input is rendered into the HTML response without escaping special characters such as <, >, or '.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser, potentially stealing session cookies or tokens and delivering malware via trusted application pages.
What the attacker needed
Victim clicks a crafted link
The fix
The endpoint should validate input and apply strict output encoding before rendering user-supplied data in HTML responses.
How it was found
- Modify the 'files' parameter to include HTML content.
- URL-encode the payload and append it to the request.
- Observe that the server reflects the input without filtering.
- See the injected HTML tag in the response and the JavaScript alert execute.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a website takes something you type (like a search term or a file name) and puts it directly into the page without cleaning it, a malicious user can type code instead of normal text. That code then runs in the browser of anyone who clicks a crafted link, which is called cross-site scripting (XSS). Here, the 'files' parameter was reflected back without any filtering, so a simple image tag with an error handler could run JavaScript.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.