Story Of Stored Xss
The 'Reason for Visit' field allowed HTML injection and stored a link with a javascript: URL, which executed script when clicked. An attacker could store a payload that runs in the context of a user who views the appointment, potentially stealing cookies.
I’m Gajendraworking as Penetration Tester. Today I am going to share how I found Stored Cross-Site Scripting (XSS).
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 blacklisted only the word 'script' instead of properly encoding or sanitising user input, allowing other HTML and javascript: URLs.
Impact
An attacker could store a link that, when clicked by a user viewing the appointment, executes script in that user's browser and could access cookies.
What the attacker needed
A normal user account; victim clicks the stored link
How it was found
- Log in as a normal user and start booking an appointment.
- Fill in the required details such as doctor name and time slot.
- Enter special characters in the 'Reason for Visit' field and observe they are reflected as-is.
- Try a script tag payload, which is rejected because 'script' is blacklisted.
- Try an HTML injection payload, which executes in the response.
- Use an anchor tag with a javascript: URL in the field, which is stored successfully.
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.
A stored cross-site scripting (XSS) bug lets an attacker save malicious code in a website, so it runs later in another person's browser. Here, a text box accepted HTML, and a link with a javascript: address ran code when clicked.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.