Skip to content
IDOR Write-up Beginner

Leaking API keys in Bing Maps Portal

The Bing Maps Portal usage page accepted an account identifier as a URL parameter without checking that it belonged to the logged-in user. By changing that number, an attacker could view other users' API keys, application names and usage statistics.

Sai Krishna Kothapalli Follow

Published on medium.com

{{media:0}}

Sai Krishna Kothapalli, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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. 3 min read.

Context

Bing Maps, like most API products, requires an API key before you can use it. Developers register applications and manage their keys through the Bing Maps Portal at https://www.bingmapsportal.com/. The portal also has a page that shows usage details for the API keys belonging to an account.

The report is about that usage page. It was written by Sai Krishna Kothapalli, who found the issue while preparing for a Microsoft hackathon, and it was disclosed on 31 December 2015.

Setup

There are no special tools or roles involved. The researcher registered a normal account on the Bing Maps Portal, created an application and an API key, and browsed the portal to become familiar with it. The only precondition is a logged-in portal account with at least one application and key.

Image for post
Image for post From the original on medium.com

The screenshot shows the portal where applications and their Bing Maps keys are managed.

Image for post
Image for post From the original on medium.com

This one shows the researcher creating a new API key and using it. The application and key created for testing were deleted afterwards.

Finding it

The portal has a page where you can see the usage details of all your API keys. Because the key had not been used yet, the page showed no statistics. What caught the researcher's attention was the URL: when the page made its GET request, it sent the account ID as a parameter.

Image for post
Image for post From the original on medium.com
Image for post
Image for post
Image for post
Image for post

These screenshots show the usage page and the request with the account ID in the URL.

Exploitation

Step 1: Change the account ID

The researcher's own account ID was 1418765. Changing that value in the URL to 1418766 and pressing enter returned the API keys of the other user.

Text
1418766

That single increment was enough. Changing the account ID in the request returned the other user's data.

Step 2: Read what came back

The response contained the API keys of the other account, along with application names, usage details and the statistics shown on the page. The researcher says he could get the API keys, application names, usage details and statistics of every user ever registered, and that there were even enterprise level API keys.

Root cause

The usage page trusted a client-supplied account ID and used it directly to look up data, instead of deriving the account from the authenticated session. This is a classic insecure direct object reference: the object identifier is in the request, and authorisation is not checked against it. The report does not describe the server-side code, so the exact implementation is not known.

Impact

Anyone with a portal account could change the account ID and read another user's API keys, application names, usage details and statistics. The keys themselves were returned, and the researcher points out that enterprise level keys were among the data. The report does not state how many accounts were affected or whether the keys could be used to incur charges.

Fix

Microsoft fixed the bug, and the URL now looks different. The report does not include the new URL string. The vulnerability was patched.

Image for post
Image for post From the original on medium.com

The final screenshot accompanies the note that the URL now looks different and the vulnerability was patched.

Timeline

Date Event
10/11/2015 Bug report sent
11/11/2015 Mail received saying the bug was being analysed
12/11/2015 Fix confirmed by the researcher
17/11/2015 Official mail asking for the researcher's details

The researcher was listed in the Microsoft Hall of Fame for November.

Variants to test

  1. Increment or decrement numeric identifiers in URLs and request bodies on any portal that shows per-account data, such as usage, billing or key management pages. A positive result is another account's data appearing in the response.
  2. Look for identifiers in query strings, path segments and JSON bodies on pages that render statistics or reports. A positive result is data that belongs to an object you do not own.
  3. Try the same identifier swap on endpoints that return keys, tokens or secrets rather than just statistics. A positive result is a credential you can use.
  4. Check whether the server derives the account from the session when the identifier is omitted or replaced with an invalid value. A positive result is a response that still returns another account's data, or an error that reveals the lookup is based on the supplied value.

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

A student signed up for a normal account on a Microsoft website that hands out keys for Bing Maps, the mapping service. While clicking around, he noticed that one page put a number in the address bar that said which account's data to show. He changed that number by one, pressed Enter, and the page showed him another person's secret keys. He reported it, Microsoft fixed it, and he ended up in the Microsoft Hall of Fame for November.

That is the whole story. The rest of this article walks through it slowly, explaining each idea as it comes up, so that someone who has never done security work can follow exactly what was done and why.

Some background

This was the author's first time reporting a security problem to a large company. He says he had a little prior knowledge of web security, gained from practising on his institute's websites and servers and from taking part in many Capture The Flag contests. A Capture The Flag contest is a game where players try to find hidden weaknesses in deliberately vulnerable systems to collect flags, and doing many of them builds the habit of checking everything.

Every year Microsoft runs a hackathon called code.fun.do at some IITs. A hackathon is a short event where teams build a working piece of software. The theme was to build a web or mobile application using one of Microsoft's technologies. The author's team had an idea that involved Bing Maps, so they needed to use the Bing Maps service from their own code.

Sai Krishna Kothapalli
Sai Krishna Kothapalli From the original on medium.com

What an API and an API key are

An API (Application Programming Interface) is a way for one piece of software to ask another piece of software to do something. A simple comparison: a restaurant menu. You do not walk into the kitchen and cook; you pick an item from the menu, the kitchen prepares it, and the waiter brings it back. An API is that menu plus the waiter: a fixed list of things you can ask for, and a fixed way of asking.

Bing Maps offers such a menu: give me a map image, give me directions, and so on. But the service needs to know who is asking, so it can count usage and bill the right party. That is what an API key is: a long string of characters that identifies your application, like a membership card you show at the door. Anyone who has your key can pretend to be your application, which is why keys are secrets.

To get a key you register an application in a portal. A portal here is just a website where you manage your account, your applications and their keys. For Bing Maps that website is:

Text
https://www.bingmapsportal.com/

So the author registered an account there.

Image for post
Image for post From the original on medium.com

The screenshot shows the portal where applications and their Bing Maps keys are managed.

Getting familiar with the portal

Next he explored the site and created a new API key to see how the whole thing worked.

Image for post
Image for post From the original on medium.com

This one shows the researcher creating a new API key and using it. The application and key created for testing were deleted afterwards.

The page that caught his eye

The portal has a page where you can see the usage details of all your API keys: how many requests each key has made, and similar statistics. Because his key had not been used yet, the page showed no statistics at all. The interesting part was not the numbers but the address bar.

Image for post
Image for post From the original on medium.com
Image for post
Image for post
Image for post
Image for post

These screenshots show the usage page and the request with the account ID in the URL.

When the page loaded, it made a GET request. A GET request is simply the browser asking a server for a page or some data; it is what happens every time you type an address and press Enter. The request carried the account ID as a parameter. A parameter is a piece of information attached to the address, usually after a question mark, that the server reads to decide what to send back. Think of it as writing a room number on an order form: the kitchen sends food to whichever room number is written there.

That is the key observation. The GET request sent the account ID as a parameter, so the account was named in the request.

Exploitation

Step 1: Change the account ID

The author's own account ID was 1418765. He changed that value in the URL to 1418766, one higher, and pressed Enter. The page came back with the API keys of the other user.

Text
1418766

That single increment was enough. Changing the account ID in the request returned the other user's data. In everyday terms: the waiter delivered the food to whatever room number was written on the form, without checking that the person who ordered was a guest in that room.

Step 2: Read what came back

The response contained the API keys of the other account, along with application names, usage details and the statistics shown on the page. The author says he could get the API keys, application names, usage details and statistics of every user ever registered, and that there were even enterprise level API keys. The author notes that there were even enterprise level API keys.

Why this kind of bug has a name

This is called an insecure direct object reference, often shortened to IDOR. "Object" here means a thing stored on the server, such as an account, an order or a file. "Reference" means the identifier the client uses to point at that thing, here the account ID. "Direct" means the client sends that identifier itself. "Insecure" means the server does not check that the person asking is allowed to see that particular object.

The usage page trusted a client-supplied account ID and used it directly to look up data, instead of deriving the account from the authenticated session. A session is the server's memory of who you are after you log in; it is usually carried by a cookie, a small piece of data the browser stores and sends back with each request, like a wristband you get at an event that proves you paid to get in. The right design is to read the wristband, not to trust a number written on the order form. The report does not describe the server-side code, so the exact implementation is not known.

Impact

Anyone with a portal account could change the account ID and read another user's API keys, application names, usage details and statistics. The keys themselves were returned, and the author points out that enterprise level keys were among the data. The report does not state how many accounts were affected or whether the keys could be used to incur charges.

The fix

Microsoft fixed the bug, and the URL now looks different. The report does not include the new URL string. The vulnerability was patched.

Image for post
Image for post From the original on medium.com

The final screenshot accompanies the note that the URL now looks different and the vulnerability was patched.

Timeline

Date Event
10/11/2015 Bug report sent
11/11/2015 Mail received saying the bug was being analysed
12/11/2015 Fix confirmed by the researcher
17/11/2015 Official mail asking for the researcher's details

The researcher was listed in the Microsoft Hall of Fame for November. The team did not win the hackathon, but the author counts the Hall of Fame listing as a win anyway.

Variants to test

If you want to look for the same kind of mistake yourself, these are the places to start. Each one is a variation on the same idea: change an identifier and see whose data comes back.

  1. Increment or decrement numeric identifiers in URLs and request bodies on any portal that shows per-account data, such as usage, billing or key management pages. A positive result is another account's data appearing in the response.
  2. Look for identifiers in query strings, path segments and JSON bodies on pages that render statistics or reports. A positive result is data that belongs to an object you do not own.
  3. Try the same identifier swap on endpoints that return keys, tokens or secrets rather than just statistics. A positive result is a credential you can use.
  4. Check whether the server derives the account from the session when the identifier is omitted or replaced with an invalid value. A positive result is a response that still returns another account's data, or an error that reveals the lookup is based on the supplied value.

Glossary

  • API: a fixed way for one piece of software to ask another for data or actions, like a menu you order from.
  • API key: a secret string that identifies your application to a service, like a membership card; anyone holding it can act as your application.
  • Portal: a website where you manage an account, its applications and their keys.
  • GET request: the browser asking a server for a page or data, which happens whenever you load an address.
  • Parameter: extra information attached to an address, usually after a question mark, that the server reads to decide what to return.
  • Account ID: the number that identifies a particular account on the server.
  • Session: the server's memory of who you are after logging in, usually carried by a cookie.
  • Cookie: a small piece of data the browser stores and sends back with requests, like a wristband proving you are logged in.
  • IDOR (insecure direct object reference): a bug where the client sends an identifier for a stored object and the server returns it without checking that the requester is allowed to see it.
  • Enterprise level: keys issued to large business customers, typically more valuable than a hobbyist's key.
  • Hackathon: a short event where teams build a working piece of software.
  • Capture The Flag (CTF): a contest where players find hidden weaknesses in deliberately vulnerable systems to collect flags.
  • Hall of Fame: a public list of people who reported security problems to a company.

More by Sai Krishna Kothapalli

View all

4 more disclosed reports, best first.

More from Microsoft

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.