Breaking In — Behind the Exploit (Understanding and executi
A sample PHP web application failed to sanitise user input in a URL query parameter, allowing an attacker to inject a script that executes in a victim's browser. The attacker could steal cookies, session tokens, or credentials, or perform actions on the victim's behalf.
Published on medium.com
In a XSS, the attacker injects malicious scripts into a website, which are then executed in the victim’s browser without their knowledge. These scripts can steal sensitive information such as cookies, session tokens, and login credentials, or perform other harmful activities on behalf of the victim.
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
Likely the application reflected user input from a URL query parameter into the page without validating or sanitising it.
Impact
An attacker could steal cookies, session tokens, and login credentials, or perform harmful activities on behalf of the victim.
What the attacker needed
Victim clicks a crafted link; attacker can host or send a URL
The fix
Input should be validated by type, length and format, and inline JavaScript should be avoided in HTML attributes.
How it was found
- Create a PHP file and start the Apache server to run it.
- Run the vulnerable sample web application on Ubuntu.
- Access the application from the attacker's machine using the Ubuntu IP address and application URL.
- Inject a script into the URL query parameter via the unsanitised input field.
- When a user opens the URL, the script executes automatically in their browser.
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.
Cross-site scripting (XSS) is when a website takes text from a user and puts it into a page without cleaning it first. An attacker can put a small program (a script) in that text, and when someone else opens the page, their browser runs it. That script can then read things like login cookies or act as the victim.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.