Stored XSS on https://www.algolia.com/realtime-search-demo/*
Attribute values in a generated UI demo were not escaped when printed into JavaScript, allowing an attacker to inject code via a modified input name. The stored payload executed JavaScript in the victim's browser when the shared demo link was opened.
Originally disclosed on HackerOne
- Triaged in 37 hours
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 3 months
Description
When you generate a UI demo, the values of the Attributes are not escaped when printed in the page of the demo.
There is a protection by CloudFlare, but because the values of the Attributes are printed in Javascript code, I found a way to abuse this to execute Javascript code. Seems like ClodFlare is a little more permissive when the malicious code is in the name of the parameter instead of the value: '+something+' is allowed.
Proof of concept
-
Using an existing user, go to https://www.algolia.com/explorer.
-
At the bottom of the right side of the page click on GENERATE A UI DEMO.
-
Enter any Title.
-
Click on NEXT.
-
Right click the field for Primary attribute and click on Inspect Element.
-
Change the name of the
<input>to:engine[primary_attribute]['+document.write`${unescape`%3cimg%20src%3dx%20onerror%3dalert%28document.domain%29%3e`}`+'] -
Click on NEXT.
-
Click on GENERATE UI & SHARE.
-
alert(document.domain)is executed. -
Copy the address from the address bar of your browser.
-
Open the link with other user.
-
alert(document.domain)is executed.
I noticed that the same issue is with the other Attributes fields.
I have a live demo here https://www.algolia.com/realtime-search-demo/some-title. Please, let me know if something is not clear.
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
Impact
An attacker could execute arbitrary JavaScript in the context of the Algolia domain for any user who opens a crafted demo link, though Cloudflare provided some filtering that the attacker bypassed.
What the attacker needed
An existing user account; victim opens a crafted demo link
How it was found
- Log in and open the Algolia explorer.
- Start generating a UI demo and enter a title.
- Inspect the primary attribute input and change its name to a crafted value.
- Proceed and generate the UI demo.
- The payload executes in the browser.
- Share the resulting URL; opening it in another browser also executes the payload.
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.
When a website builds a page from user-supplied settings, it must treat those settings as text, not as code. Here, the site inserted an attribute name directly into a script block without escaping it, so a crafted name could break out and run JavaScript. This is called stored cross-site scripting because the malicious value is saved and later shown to other users.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.