Mapbox API Access Token with No Scope Can Read Styles
A Mapbox API token with no scopes still had styles:read and could read public map styles, more than the user expected.
- Triaged in 4 days
- Fixed in 54 days
- Paid in 54 days
- Disclosed after 3 months
Summary by the program
On March 10th, 2016, @bugs3ra reported that a public Mapbox API access token with no explicitly declared scopes could read public map styles. This meant that a token with no scopes had the styles:read scope. In fact, the no scope token had all three public scopes associated with a user's default public access token - styles:tiles, styles:read, and fonts:read.
To fix this issue, we updated the UI in Studio to make token scopes more clear. We updated the text "No scopes" to "Public token (all public scopes)" in the token creation modal dialog.
We decided to award a bounty for this report since granting more scopes than expected is unexpected for the user and represents a minor violation of the principle of least privilege.
The report
HI I created one api token with 0 scope. Then I sent the following request to server
GET /styles/v1/katilthe?access_token=pk.eyJ1Ijoia2F0aWx0aGUiLCJhIjoiY2lsbWJwcWpjNjhmNnZubWNhYXdwZm5obyJ9.2cPnaIiXcFnDRFMfrD1TRw HTTP/1.1 Host: api.mapbox.com User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate, br Referer: https://www.mapbox.com/studio/styles/fonts/ Origin: https://www.mapbox.com Connection: keep-alive
I Got 200 OK in response and my styles.
[{"version":8,"name":"test"><svg/onload=alert(2)>-copy-copy","center":[-78.90145050000001,33.70101199999998],"zoom":12,"bearing":0,"pitch":0,"created":"2016-03-10T13:45:51.193Z","id":"cilmbusls00cvc6m23qpi69gg","modified":"2016-03-10T13:45:51.193Z","owner":"katilthe"},{"version":8,"name":"test"><svg/onload=alert(2)>-copy","center":[0,-1.1368683772161603e-13],"zoom":0.3106126682923422,"bearing":0,"pitch":0,"created":"2016-03-10T13:43:58.005Z","id":"cilmbsd9s00cfc7mcl1m7nnrz","modified":"2016-03-10T13:43:58.005Z","owner":"katilthe"}]
Attachments


Context
Mapbox exposes a REST API at api.mapbox.com for working with map data, and access to that API is controlled by access tokens. Tokens are created in Mapbox Studio, where the user chooses which scopes the token should carry. One of the resources behind the API is styles: a style is a JSON document describing how a map is rendered, and it can be read through the /styles/v1/ endpoint.
The report concerns a token created with no scopes at all. The expectation, from the user's point of view, is that such a token grants nothing. The researcher found that it actually behaved like a full public token.
Setup
The researcher created a single API token in Studio and selected zero scopes for it. No other accounts, roles or tooling are described. The only precondition is a Mapbox account able to create tokens and to own at least one style.
Finding it
The question the researcher asked was simple: what can a token with no scopes do? The test was to take that token and call a styles endpoint that belongs to the same account. If the scope model were enforced as displayed, the request should have been rejected. Instead it returned the account's styles.
Exploitation
Step 1: create a token with no scopes
A token was created in Studio with 0 scopes. The resulting token string is embedded in the request below.
Step 2: request the styles endpoint with that token
GET /styles/v1/katilthe?access_token=pk.[redacted].2cPnaIiXcFnDRFMfrD1TRw HTTP/1.1
Host: api.mapbox.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://www.mapbox.com/studio/styles/fonts/
Origin: https://www.mapbox.com
Connection: keep-alive
The path /styles/v1/katilthe addresses the style collection of the account named in the path, and the access_token query parameter carries the zero-scope token. The Referer and Origin headers show the request was issued in the context of the Studio styles page, but the authorisation decision rests on the token alone.
Step 3: read the response
The server answered 200 OK and returned the account's styles:
[{"version":8,"name":"test\"><svg/onload=alert(2)>-copy-copy","center":[-78.90145050000001,33.70101199999998],"zoom":12,"bearing":0,"pitch":0,"created":"2016-03-10T13:45:51.193Z","id":"cilmbusls00cvc6m23qpi69gg","modified":"2016-03-10T13:45:51.193Z","owner":"katilthe"},{"version":8,"name":"test\"><svg/onload=alert(2)>-copy","center":[0,-1.1368683772161603e-13],"zoom":0.3106126682923422,"bearing":0,"pitch":0,"created":"2016-03-10T13:43:58.005Z","id":"cilmbsd9s00cfc7mcl1m7nnrz","modified":"2016-03-10T13:43:58.005Z","owner":"katilthe"}]
The body lists two style objects, each with its id, name, center, zoom, bearing, pitch, created, modified and owner fields. The owner value matches the account in the request path. The style names in this response contain an SVG payload, but that is incidental to the finding: the point is that the styles were readable at all with a token that declared no scopes.
Root cause
According to the program's summary, a token with no explicitly declared scopes was treated as carrying all three public scopes associated with a user's default public access token: styles:tiles, styles:read and fonts:read. The zero-scope token therefore had styles:read in practice, which is exactly the permission needed for the request above.
The program's summary states that a token with no explicitly declared scopes carried all three public scopes of a user's default public access token. The UI reinforced the misunderstanding: the token creation dialog labelled this state "No scopes", which reads as a denial of all access rather than as a grant of the public set.
Impact
The program describes the issue as granting more scopes than expected, which is unexpected for the user and a minor violation of the principle of least privilege. In concrete terms, anyone holding a token that its owner believed to be inert could read that account's public styles. The report does not describe any way to reach other accounts' data, to write anything, or to escalate beyond the public scopes, and the program's own framing keeps the severity low. The bounty awarded was 200.00 USD.
Fix
The program changed the Studio UI rather than the token semantics. In the token creation modal dialog, the text "No scopes" was replaced with "Public token (all public scopes)", so that the label now states what the token actually grants. The program's summary describes only the UI text change; it does not say whether the token behaviour itself was altered.
Variants to test
- Create tokens with each individual scope and with none, then call every endpoint family the product exposes (styles, tiles, fonts and any others the documentation lists). A positive result is a
200where the declared scope should have produced a403. - Compare a zero-scope token against a token explicitly limited to a single scope on the same resource. If both return the same data, the scope list is not being enforced.
- Check whether the default public scope set differs between token types (for example default public tokens versus tokens created through the UI or API). A positive result is a token type whose implicit scopes exceed what its label suggests.
- Look for the same pattern in other products that use scope checkboxes: an empty selection that is stored as null or an empty array and then treated as "unrestricted" by the authorisation layer.
Hunting notes
This kind of bug hides in the gap between how a permission is displayed and how it is evaluated. The signal during recon is a UI that offers a "none" or "no scopes" option without saying what that state means on the server, especially when a separate "default public token" concept exists in the same product. Testing it costs one token and one request: create the empty token, call a read endpoint that belongs to your own account, and compare the status code with what the label promises.
The program awarded a bounty because granting more scopes than expected is unexpected for the user and a minor violation of the principle of least privilege.
Attachments


What happened, in plain words
Mapbox is a service that lets people build maps into websites and apps. It stores map designs, called styles, and serves them through an API. An API is a way for one computer program to ask another computer program for data over the internet, like a waiter taking your order to the kitchen and bringing back the food. To use the Mapbox API you need an access token: a long string of characters that works like a key card. The server checks the token and decides what you are allowed to do.
When you create a token in Mapbox Studio (the website where you manage your Mapbox account), you tick boxes to choose its scopes. A scope is a named permission, for example "may read styles" or "may read fonts". The researcher created a token and ticked no boxes at all. The website labelled this state "No scopes", which sounds like the token can do nothing.
The researcher then used that token to ask the Mapbox API for the list of styles belonging to their own account. The server answered 200 OK, which is the standard success code in HTTP (the language browsers and servers use to talk), and returned the styles. So a token that was presented as having no permissions actually had permission to read styles. The program later explained that a token with no scopes was silently given all three public scopes that a normal public token has: styles:tiles, styles:read and fonts:read. The fix was to change the label in the token creation dialog from "No scopes" to "Public token (all public scopes)", so the interface now says what the token really grants. A bounty of 200.00 USD was paid.
Context
Mapbox runs a REST API at api.mapbox.com. REST is a common style of API where each URL represents a resource (a thing, such as a style or a font) and the HTTP method (GET to read, POST to create, and so on) says what you want to do with it. Access to that API is controlled by access tokens.
Tokens are created in Mapbox Studio. When you create one, you choose which scopes it should carry. One of the resources behind the API is styles. A style is a JSON document describing how a map is rendered: JSON is a text format for structured data, made of keys and values inside curly braces and square brackets. A style can be read through the /styles/v1/ endpoint. An endpoint is a specific URL path on a server that performs a particular job.
The report concerns a token created with no scopes at all. From the user's point of view, the expectation is that such a token grants nothing. The researcher found that it actually behaved like a full public token.
Setup
The researcher created a single API token in Studio and selected zero scopes for it. No other accounts, roles or tools are described. The only precondition is a Mapbox account that can create tokens and that owns at least one style.
Finding it
The question the researcher asked was simple: what can a token with no scopes do? The test was to take that token and call a styles endpoint belonging to the same account. If the scope model worked the way the website displayed it, the request should have been rejected. Instead it returned the account's styles.
Exploitation
Step 1: create a token with no scopes
A token was created in Studio with 0 scopes. The resulting token string appears in the request below. Creating the token is the whole setup: the researcher wanted a key that, according to its label, should open no doors.
Step 2: request the styles endpoint with that token
GET /styles/v1/katilthe?access_token=pk.[redacted].2cPnaIiXcFnDRFMfrD1TRw HTTP/1.1
Host: api.mapbox.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://www.mapbox.com/studio/styles/fonts/
Origin: https://www.mapbox.com
Connection: keep-alive
Line by line:
GET /styles/v1/katilthe?access_token=... HTTP/1.1is the request line.GETmeans "read this"./styles/v1/katiltheis the path: it addresses the style collection of the account namedkatilthe. The part after?is the query string, a set of key=value pairs sent along with the URL; hereaccess_tokencarries the zero-scope token.HTTP/1.1is the version of the protocol being used.Host: api.mapbox.comtells the server which website name the request is for. One server can host many sites, so it needs to know which one you mean.User-Agent: ...identifies the browser and operating system that sent the request. Here it says Firefox 44 on 64-bit Windows.Accept: ...lists the kinds of response the browser is willing to receive, such as HTML, XHTML and XML, with quality values after the semicolons.Accept-Language: en-US,en;q=0.5says the browser prefers US English, with plain English as a fallback.Accept-Encoding: gzip, deflate, brsays the browser can accept compressed responses to save bandwidth.Referer: https://www.mapbox.com/studio/styles/fonts/tells the server which page the request came from. It shows the request was made in the context of the Studio styles page.Origin: https://www.mapbox.comtells the server which site the request originated from. Browsers send it for cross-origin requests, and servers use it for security decisions.Connection: keep-aliveasks the server to keep the network connection open for further requests instead of closing it after this one.
The Referer and Origin headers show the request was issued from the Studio styles page, but the authorisation decision rests on the token alone. In other words, the server does not trust the page you came from; it trusts the key you present.
Step 3: read the response
The server answered 200 OK and returned the account's styles:
[{"version":8,"name":"test\"><svg/onload=alert(2)>-copy-copy","center":[-78.90145050000001,33.70101199999998],"zoom":12,"bearing":0,"pitch":0,"created":"2016-03-10T13:45:51.193Z","id":"cilmbusls00cvc6m23qpi69gg","modified":"2016-03-10T13:45:51.193Z","owner":"katilthe"},{"version":8,"name":"test\"><svg/onload=alert(2)>-copy","center":[0,-1.1368683772161603e-13],"zoom":0.3106126682923422,"bearing":0,"pitch":0,"created":"2016-03-10T13:43:58.005Z","id":"cilmbsd9s00cfc7mcl1m7nnrz","modified":"2016-03-10T13:43:58.005Z","owner":"katilthe"}]
The body is a JSON array (the outer square brackets) containing two style objects (the curly braces). Each object has these fields:
version: the style format version, here 8.name: the human-readable name of the style.center: the longitude and latitude the map is centred on.zoom: how far the map is zoomed in.bearing: the compass direction the map is rotated to.pitch: the tilt of the map.createdandmodified: timestamps in ISO 8601 format, which is a standard way of writing dates and times.id: a unique identifier for the style.owner: the account that owns the style, herekatilthe, matching the account in the request path.
The style names in this response contain an SVG payload, but that is incidental to the finding. SVG is a format for drawing vector images, and the text inside the names looks like an HTML injection attempt. The point is that the styles were readable at all with a token that declared no scopes.
Root cause
According to the program's summary, a token with no explicitly declared scopes was treated as carrying all three public scopes associated with a user's default public access token: styles:tiles, styles:read and fonts:read. The zero-scope token therefore had styles:read in practice, which is exactly the permission needed for the request above.
The program's summary states that a token with no explicitly declared scopes carried all three public scopes of a user's default public access token. The UI reinforced the misunderstanding: the token creation dialog labelled this state "No scopes", which reads as a denial of all access rather than as a grant of the public set.
Impact
The program describes the issue as granting more scopes than expected, which is unexpected for the user and a minor violation of the principle of least privilege. The principle of least privilege is the idea that every key, account or program should have only the permissions it needs to do its job, and nothing more. In concrete terms, anyone holding a token that its owner believed to be inert could read that account's public styles. The report does not describe any way to reach other accounts' data, to write anything, or to escalate beyond the public scopes, and the program's own framing keeps the severity low. The bounty awarded was 200.00 USD.
Fix
The program changed the Studio UI rather than the token semantics. In the token creation modal dialog, the text "No scopes" was replaced with "Public token (all public scopes)", so the label now states what the token actually grants. The program's summary describes only the UI text change; it does not say whether the token behaviour itself was altered.
Variants to test
- Create tokens with each individual scope and with none, then call every endpoint family the product exposes (styles, tiles, fonts and any others the documentation lists). A positive result is a
200where the declared scope should have produced a403. HTTP status codes are three-digit numbers:200means success,403means forbidden. - Compare a zero-scope token against a token explicitly limited to a single scope on the same resource. If both return the same data, the scope list is not being enforced.
- Check whether the default public scope set differs between token types (for example default public tokens versus tokens created through the UI or API). A positive result is a token type whose implicit scopes exceed what its label suggests.
- Look for the same pattern in other products that use scope checkboxes: an empty selection that is stored as null or an empty array and then treated as "unrestricted" by the authorisation layer.
Hunting notes
This kind of bug hides in the gap between how a permission is displayed and how it is evaluated. The signal during recon is a UI that offers a "none" or "no scopes" option without saying what that state means on the server, especially when a separate "default public token" concept exists in the same product. Testing it costs one token and one request: create the empty token, call a read endpoint that belongs to your own account, and compare the status code with what the label promises.
The program awarded a bounty because granting more scopes than expected is unexpected for the user and a minor violation of the principle of least privilege.
Attachments


Glossary
- API: a way for one program to ask another program for data or actions over the internet, like a waiter carrying orders between you and the kitchen.
- Access token: a long string that acts as a key card, proving to a server which permissions you have.
- Scope: a named permission attached to a token, such as "read styles".
- Mapbox Studio: the website where Mapbox users create tokens and manage their maps and styles.
- Style: a JSON document that describes how a map is drawn, including its centre, zoom and other settings.
- JSON: a text format for structured data, built from objects in curly braces and arrays in square brackets.
- REST API: an API style where each URL represents a resource and the HTTP method says what to do with it.
- Endpoint: a specific URL path on a server that performs a particular job.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- HTTP method: the verb in a request, such as
GETto read orPOSTto create. - Query string: the part of a URL after
?, made of key=value pairs sent with the request. - Header: a line in an HTTP request or response carrying extra information, such as
HostorUser-Agent. - User-Agent: a header that identifies the browser and operating system making the request.
- Referer: a header that tells the server which page the request came from.
- Origin: a header that tells the server which site the request originated from.
- Status code: a three-digit number in an HTTP response, such as
200for success or403for forbidden. - Principle of least privilege: the rule that every key, account or program should have only the permissions it needs, and no more.
- SVG: a format for drawing vector images, which can contain markup and scripts.
- ISO 8601: a standard way of writing dates and times, such as
2016-03-10T13:45:51.193Z. - Bounty: a reward paid by a company to someone who reports a security problem to it.