Persistent cross-site scripting (XSS) in map attribution
A persistent cross-site scripting flaw existed in the map attribution control of Mapbox.js, allowing an attacker to inject JavaScript via a custom map style's attribution field. An attacker could then share a project URL that executed arbitrary JavaScript in a victim's Mapbox.com session, and also in sites using Mapbox.js with untrusted TileJSON.
- Triaged in 18 hours
- Fixed in 8 days
- Paid in 8 days
- Disclosed after 12 months
Summary by the program
@ph3t reported a persistent cross-site scripting (XSS) issue in the map attribution control for Mapbox.js maps. This allowed a potential attacker to have full control over a user's Mapbox.com session and execute arbitrary JavaScript commands. It also allowed for the execution of arbitrary JavaScript in websites using Mapbox.js with the uncommon usage scenario of loading untrusted TileJSON.
@ph3t's proof of concept used our Mapbox Studio Classic desktop application to add a custom attribution with an XSS payload (">{{media:0}}Mapbox</a>"). Support for HTML in the map attribution is necessary and after @ph3t's report, we first deployed a patch to our mapping API for server-side sanitization of user-provided attribution controls. We also released a client-side sanitization fix in Mapbox.js v2.1.7 and v1.6.5 to mitigate the uncommon usage scenario of using untrusted TileJSON. The patches used sanitize-caja to sanitize any script content added to the attribution property of untrusted TileJSON.
Additional details can be found in the Node Security project advisory submitted for this issue, #49 - Content Injection via TileJSON attribute.
The report
Hello,
I have found a Persistent Cross Site Scripting vulnerability when using a custom style uploaded by myself.
Mapbox Studio allows create and upload styles for your maps. So if we create a new style with javascript code as attribution value it will be executed when loading a map that uses our evil style. I used the following javascript code for testing:
"><img src=x onerror=alert(document.cookie)>
To reproduce this vulnerability you must download the Mapbox Studio from here. Then you must write a random name and description. In the Attribution field you must inject the javascript code you want to execute. Save the changes again, upload the project and close the Mapbox Studio. Now, log into your Mapbox account and go to Styles, select the style you have just created, this will expand the div, and click on "New project". The code will be already executed, but the vulnerability is not as much exploitable as we want. We want everybody can execute our javascript code so, choose the settings you want in the project we created and save it. Go to your project list and search the project we have just saved. If we share this project, everybody who access to it will execute the code we have injected, including people without Mapbox account.
Demo video: https://youtu.be/NHjTqjndRik
Regards, Juan Broullón Sampedro.
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
The map attribution control rendered user-provided attribution as HTML without sanitisation, allowing script injection.
What the attacker needed
A Mapbox account; Mapbox Studio desktop application; victim visits a shared project URL
How it was found
- Download Mapbox Studio and create a new style with a random name and description.
- In the Attribution field, inject JavaScript code.
- Save changes, upload the project, and close Mapbox Studio.
- Log into Mapbox account, go to Styles, select the created style, and click 'New project'.
- Choose settings and save the project.
- Share the project URL; anyone who accesses it will execute the injected code.
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.
Cross-site scripting (XSS) is when a website displays user-supplied content without properly cleaning it, so an attacker can sneak in code that runs in other people's browsers. Here, the map's attribution text (the small credit line) accepted HTML, and a malicious style could include a script that runs when someone views the map. The attacker could then steal session cookies or act as the victim on Mapbox.com.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.