Skip to content
XSS Disclosed report Beginner

Stored xss in editor

A stored cross-site scripting flaw existed in Mapbox Editor: a user-supplied name and description for a drawn line were saved and later rendered without proper escaping. An attacker could inject script that executed in the browser of anyone who viewed the shared map.

eh0x01 Follow

Originally disclosed on HackerOne

Bounty$1,000 View original
  • Disclosed after 2.4 years

Summary by the program

On March 28th, 2015 @sahilsaif reported an issue with stored XSS in Mapbox Editor (www.mapbox.com/editor). We deployed a fix for this issue on March 30th, 2015.

Summary by the researcher

On March 28th, 2015, I found a Stored XSS in Mapbox Editor.

Which was hosted on https://mapbox.com/editor Mapbox Editor is now deprecated and replaced with Mapbox Studio. (https://mapbox.com/studio).

This Issue was very straight forward.

Following was the Reproduction Steps.

  1. Go to: http://mapbox.com/editor

  2. Draw a line on the map using tool bar.

  3. Give the name to the created line.

  4. Enter Following JS payload on Name & Description Input Box.

"><img src=x onerror=prompt(111);>

  1. Save it.

  2. Reload the Page, Js payload will be executed.

Exploitation: You can share the created maps to other Mapbox users and js payload will be executed on the targetted browser.

Screenshot

https://www.dropbox.com/s/2lxd8fhw1bttwrh/Screen_Shot_2015-03-28_at_9.44.25_AM.png?dl=0

-Sahil

The original report as published on HackerOne, by eh0x01. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Mapbox Editor was a web application at www.mapbox.com/editor that let users draw features on a map, such as lines, and give them a name and a description. The editor is now deprecated and has been replaced by Mapbox Studio at https://mapbox.com/studio. The bug in this report is a stored cross-site scripting issue in the naming and description fields of a drawn feature.

Setup

The report does not describe any special account, role or tooling. The researcher reached the editor at http://mapbox.com/editor and used the toolbar to draw a line on the map. No preconditions beyond access to the editor are stated.

Finding it

The researcher describes the issue as very straightforward. The editor accepts a name and a description for a drawn line, and those values are stored and later rendered back to the user. The researcher entered the payload in the name and description fields and found that it executed after saving and reloading.

Exploitation

Step 1: Open the editor

HTTP
http://mapbox.com/editor

This is the entry point to the editor, where a map and its features can be created.

Step 2: Draw a line

Using the toolbar, draw a line on the map. This creates a feature that can be named and described.

Step 3: Name the line

Give the created line a name. This is the first of the two input fields that will carry the payload.

Step 4: Enter the payload

Enter the following JavaScript payload in both the Name and Description input boxes:

HTML
"><img src=x onerror=prompt(111);>

The payload first closes the attribute or tag context with ">, then injects an img element whose src is the invalid value x. Because the image cannot load, the onerror handler fires and calls prompt(111), which is a harmless proof of execution.

Step 5: Save

Save the feature. The name and description, including the payload, are stored by the application.

Step 6: Reload

Reload the page. The stored payload is rendered back and the JavaScript executes, showing the prompt.

Sharing the map

The researcher notes that the created maps can be shared with other Mapbox users, and the JavaScript payload will then execute in the targeted user's browser. The researcher notes the payload executes in the targeted user's browser when the map is shared.

A screenshot of the execution was linked in the report at https://www.dropbox.com/s/2lxd8fhw1bttwrh/Screen_Shot_2015-03-28_at_9.44.25_AM.png?dl=0.

Root cause

The editor stored the user-supplied name and description and rendered them back into the page without encoding or sanitising them, so HTML and event handlers in those fields were interpreted by the browser. The report does not describe the server-side or client-side code, so the exact rendering path is not stated.

Impact

An attacker who can create a map feature can store JavaScript that runs in the browser of a user the map is shared with. The report frames the impact through map sharing: the payload executes on the targeted browser of the recipient.

Fix

The program states that a fix was deployed on March 30th, 2015, two days after the report on March 28th, 2015.

Variants to test

  1. Try the same payload in every free-text field of a map editor: feature name, description, layer name, popup content and any label shown on the map. A positive result is the prompt firing after save and reload.
  2. Try payloads that break out of different contexts, such as attribute values and JavaScript string literals, for example a quote-closing sequence followed by an event handler. A positive result is execution in the rendered page.
  3. Create a feature, share the map with a second account, and open it there. A positive result is execution in the second user's session, which confirms the stored and cross-user nature of the bug.
  4. Test the same fields through any API that creates or updates features, bypassing the editor UI. A positive result is the payload being stored and later rendered by the web application.

Hunting notes

This kind of bug tends to hide in features where users create content that is later displayed to other users: names, descriptions, labels and popups in mapping, dashboard and collaboration products. During recon, look for any object that can be created and shared, then check whether its text fields are reflected back as HTML. The researcher showed impact by demonstrating execution after reload and by pointing out that shared maps deliver the payload to other users, which is what turns a stored field into a cross-user issue.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

What happened, in plain words

Mapbox Editor was a web tool where you could draw things on a map, such as a line, and give that line a name and a description. The tool saved what you typed and showed it back to you later. The problem was that it showed your text back as if it were part of the web page itself, not as plain text. So if you typed in a piece of JavaScript (a small program that runs in the browser), the browser would run it instead of just displaying it.

This kind of bug is called stored cross-site scripting, or stored XSS. "Stored" means the dangerous text is saved on the server and comes back later, every time the page is opened. "Cross-site" means it can affect other people, not just the person who typed it. In this case, the researcher showed that a map could be shared with other Mapbox users, and the little program would then run in their browsers too.

The researcher found it on March 28th, 2015, and the Mapbox team says they fixed it on March 30th, 2015, two days later. The editor has since been retired and replaced by a newer tool called Mapbox Studio. The report was paid a bounty of 1000.00 USD.

The product and the feature

Mapbox Editor lived at www.mapbox.com/editor. It let you draw features on a map, such as lines, and attach a name and a description to each one. Think of it like a shared online whiteboard: you draw something, you label it, and the label is saved so that you and others can see it again later.

The report says the editor is now deprecated, meaning it is no longer in use, and has been replaced by Mapbox Studio at https://mapbox.com/studio.

The bug is in the two text fields where you type the name and the description of a drawn feature.

Setup

The report does not describe any special account, role or tooling. The researcher simply opened the editor in a browser and used the toolbar to draw a line on the map. Nothing else was needed to reach the vulnerable fields.

Finding it

The researcher calls the issue very straightforward. The editor accepts a name and a description for a drawn line, saves them, and later shows them back to the user. The researcher entered the payload in those fields and found that it executed after saving and reloading.

To understand why that matters, you need two ideas:

  • HTML is the language web pages are written in. It uses tags such as <img> to tell the browser what to display.
  • JavaScript is a programming language that browsers can run. It can do harmless things, such as show a pop-up box, or harmful things, such as read data from the page.

Normally, when a website shows text that a user typed, it should treat that text as text only. If it instead treats it as HTML, the browser will follow any tags inside it, and if those tags contain JavaScript, the browser will run that too. That is the whole bug.

Exploitation

Step 1: Open the editor

HTTP
http://mapbox.com/editor

This is the address of the editor. Opening it gives you a map and a toolbar. The researcher started here because this is where features are created and where the name and description fields live.

Step 2: Draw a line

Using the toolbar, draw a line on the map. This creates a feature that can be named and described. The researcher drew a line on the map using the toolbar.

Step 3: Name the line

Give the created line a name. This is the first of the two input fields that will carry the payload. A payload here just means the piece of text that is designed to make the browser do something unexpected.

Step 4: Enter the payload

Enter the following JavaScript payload in both the Name and Description input boxes:

HTML
"><img src=x onerror=prompt(111);>

Here is what each part does, in plain words:

  • "> closes whatever HTML attribute or tag the page had already opened around your text. Imagine the page has written name=" and is waiting for you to type a value and a closing quote. By typing "> you end the value early and close the tag, so everything after it is treated as new HTML rather than as your name.
  • <img ...> starts an image tag. The browser will try to load an image.
  • src=x tells the browser the image is at the address x. That is not a real address, so the image will fail to load.
  • onerror=prompt(111); is an event handler. An event handler is a piece of JavaScript that the browser runs when something happens. Here, the something is the image failing to load. When it fails, the browser runs prompt(111);.
  • prompt(111); opens a small pop-up box in the browser showing the number 111. It is harmless. The researcher used it only as proof that JavaScript had run.

The researcher entered the payload in both the Name and Description input boxes.

Step 5: Save

Save the feature. The name and description, including the payload, are stored by the application. This is the "stored" part: the text is now saved on Mapbox's side, not just sitting in the browser.

Step 6: Reload

Reload the page. The stored payload is shown back and the JavaScript runs, showing the prompt. Reloading matters because the payload executes again after the page is reloaded.

Sharing the map

The researcher notes that the created maps can be shared with other Mapbox users, and the JavaScript payload will then run in the targeted user's browser. This is what turns a trick that only affects yourself into an attack on other people. If the payload only ran for the person who typed it, it would be much less serious. Because the map can be shared, the script runs in the browser of the user it is shared with.

A screenshot of the execution was linked in the report at https://www.dropbox.com/s/2lxd8fhw1bttwrh/Screen_Shot_2015-03-28_at_9.44.25_AM.png?dl=0.

Root cause

The editor stored the name and description that the user typed and showed them back on the page without encoding or sanitising them. Encoding means converting special characters such as < and > into a form the browser displays as text instead of treating as HTML. Sanitising means removing or neutralising dangerous parts of the input. Neither was done, so HTML tags and event handlers in those fields were interpreted by the browser.

The report does not describe the server-side or client-side code, so the exact path the text takes when it is shown back is not stated.

Impact

An attacker who can create a map feature can store JavaScript that runs in the browser of a user the map is shared with. The report frames the impact through map sharing: the payload runs in the browser of the person who receives the map.

Fix

The program states that a fix was deployed on March 30th, 2015, two days after the report on March 28th, 2015.

Variants to test

  1. Try the same payload in every free-text field of a map editor: feature name, description, layer name, popup content and any label shown on the map. A positive result is the prompt firing after save and reload.
  2. Try payloads that break out of different contexts, such as attribute values and JavaScript string literals, for example a quote-closing sequence followed by an event handler. A positive result is execution in the rendered page.
  3. Create a feature, share the map with a second account, and open it there. A positive result is execution in the second user's session, which confirms the stored and cross-user nature of the bug.
  4. Test the same fields through any API that creates or updates features, bypassing the editor UI. An API is a way for one program to talk to another over the web, without a person clicking buttons. A positive result is the payload being stored and later shown by the web application.

Hunting notes

This kind of bug tends to hide in features where users create content that is later displayed to other users: names, descriptions, labels and popups in mapping, dashboard and collaboration products. During recon, meaning the early stage of looking around a target, look for any object that can be created and shared, then check whether its text fields are shown back as HTML. The researcher showed impact by demonstrating execution after reload and by pointing out that shared maps deliver the payload to other users, which is what turns a stored field into a cross-user issue.

Glossary

  • API: a way for one program to talk to another over the web, without a person clicking buttons.
  • Bounty: a reward paid by a company to someone who reports a security bug to it.
  • Cross-site scripting (XSS): a bug where a website lets an attacker's JavaScript run in another user's browser.
  • Deprecated: no longer in use, usually because it has been replaced by something newer.
  • Encoding: converting special characters into a safe form so the browser shows them as text instead of treating them as code.
  • Event handler: a piece of JavaScript that the browser runs when something happens, such as an image failing to load.
  • HTML: the language web pages are written in, using tags such as <img> to describe what to display.
  • JavaScript: a programming language that browsers can run inside a web page.
  • Payload: the piece of text or code designed to make the target do something unexpected.
  • Prompt: a small pop-up box a browser can show, often used as harmless proof that JavaScript ran.
  • Recon: the early stage of looking around a target to find things worth testing.
  • Sanitising: removing or neutralising dangerous parts of user input before using it.
  • Stored XSS: XSS where the dangerous text is saved on the server and comes back every time the page is opened.
  • Toolbar: the row of buttons in an application that lets you use its tools, such as drawing a line.

More by eh0x01

View all

5 more disclosed reports, best first.

More from Mapbox

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.