Skip to content
IDOR Write-up Beginner

IDOR and APIkeys🔑Token Hardcode Exposed

An Android food delivery app accepted a modified purchase order identifier, letting the author view other customers' orders and personal details. The app package also contained a hardcoded Stripe secret key that was still valid and gave access to the company's payment account.

medium.com

Published on medium.com

Bug Bounty

querylab, 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. 6 min read.

Context

The target was an Android food delivery app from Puerto Rico, which the author refers to as hungbite.com** because the app's real name is withheld. Each purchase order is identified by an orderId and is associated with a customer and a delivery person. The author describes the API behind the app as having a bug that allowed a purchase order parameter to be modified to read other users' order information, and the APK shipped a Stripe secret key in its resources.

The author introduces IDOR (Insecure Direct Object Reference) with a Google Drive analogy: in https://drive.google.com/document/101, the 101 is the identifier of the document, and replacing it with 102 normally returns an error such as "document not found" or "you do not have permission to view this document", because document 102 belongs to another user.

From the original on medium.com

Applied to the app, the API allowed a purchase order parameter to be changed so that the information of other users became visible: if your own order ended in 101 and you changed it to end in 102, you would see another user's information.

Setup

The work was done after ordering fast food through the app. The main tool was Burp Suite, used as an intercepting proxy to modify requests. For the second finding, the author used APK-Tools (https://www.kali.org/tools/apktool/) to reverse engineer the Android application, and Postman with the JSON collection offered by Stripe (https://github.com/stripe/stripe-postman) to verify the scope of the extracted key. The author also points to https://github.com/streaak/keyhacks as a reference for checking whether a token is alive. The finding dates from the end of August 2021, and a report with these and more vulnerabilities was sent to the app's security team; the issues were already patched.

Finding it

The author ordered fast food through the app and then checked whether there was any user data leakage. The first thing tried was changing the price of the product purchase to $0. The server accepted the request with 200 OK.

From the original on medium.com

That alone raised the question of whether free food was possible, but the author decided to investigate further and looked at past Purchase Orders. Changing orderId=321448 to orderId=321444 also returned 200 OK from the server.

From the original on medium.com

Bingo: the response showed the customer user as well as the delivery person in charge of that order, including all the personal information and some URL with photos of the delivery person.

From the original on medium.com

Exploitation

Step 1: change the purchase price to $0

With Burp Suite intercepting the purchase request, the price of the product purchase was changed to $0. The report does not include the raw request or response for this step, only the result.

Step 2: enumerate purchase orders by orderId

In the past Purchase Orders view, the orderId parameter was changed from 321448 to 321444:

The server accepted the request with 200 OK, and the response contained the order of another user. The data exposed in that response, as listed by the author, was:

Field
CostumerName
CostumerEmail
PhoneCustumer
CostumerAddress
Costumer Comment to deliveryman
Username deliveryman
Email deliveryman
Phone deliveryman
Description of the deliveryman vehicle (Plate, Model, Colour, Brand)
Order Tracking URL
Photo ID deliveryman

Changing the identifier value returned another user's order, and the response contained both the customer's and the delivery person's personal data.

Step 3: reverse engineer the APK

Some Android and iOS apps store tokens that can be abused to leak harmful data. The author notes that some keys are harmless and are required to be in the app, for example Google and Mapbox API keys, while others can expose harmful data that could affect the company. The tool used to reverse engineer Android apps and discover secret tokens stored in them is available online; APK-Tools is one of them.

From the original on medium.com

After reverse engineering the APK, the author found a string.xml file that stores the global variables of the app.

From the original on medium.com

That file contained secret keys used to access external services of the application. One that caught the author's attention was the STRIPE_SECRET_KEY. Stripe is an online payment processing system for Android, iOS and web apps that makes it easy to make payments.

From the original on medium.com

Step 4: check whether the Stripe key is alive

To check whether a token is alive, the author recommends https://github.com/streaak/keyhacks.

From the original on medium.com

The STRIPE_SECRET_KEY was valid. To verify the scope of the token, the author used Postman with the JSON Format Collection offered by Stripe for Postman (https://github.com/stripe/stripe-postman), which allows pushes and pulls from the official Stripe account of hungrybite.com, something the author describes as potentially devastating. To verify whether a Stripe access key is alive, the Stripe API method "retrieve" can be used: it retrieves information about a specific object, such as a Stripe account, and if the call succeeds, the provided access key is valid.

From the original on medium.com

The report does not include the exact request or the response body of the Stripe call.

Root cause

Changing the orderId value returned another user's order, which the author describes as an IDOR. On the app side, the Stripe secret key was hardcoded in the APK's string.xml, which stores the global variables of the app; anything shipped in the APK can be extracted by reverse engineering. The author notes that developers frequently use tokens and forget the access token in public repositories, which is potentially dangerous.

Impact

Through the IDOR, an authenticated user could read other customers' orders, including names, emails, phone numbers, addresses, comments to the delivery person, and the delivery person's username, email, phone, vehicle description (plate, model, colour, brand), order tracking URL and photo ID. The price change to $0 was accepted by the server with 200 OK, and the author wondered whether free food was possible. The exposed Stripe secret key was valid, and the author notes the Stripe Postman collection allows pushes and pulls from the official Stripe account of hungrybite.com, which the author describes as potentially devastating.

Fix

The author says a report with these and more vulnerabilities was sent to the security team and the issues were already patched; the report does not describe the code changes. For the token, the author recommends revoking it and generating a new one, not leaving API access tokens in public repositories, and periodically changing tokens to prevent them from being stolen.

Variants to test

  1. Sequential order identifiers. On any app with a purchase or order history, change the numeric identifier to a neighbouring value. A positive result is a 200 OK with another user's order data instead of an authorisation error.
  2. Price parameter tampering. Intercept the purchase request and set the price to 0. A positive result is a 200 OK that accepts the modified price.
  3. Hardcoded secrets in mobile apps. Decompile the APK with APK-Tools and inspect string.xml and other resource files for keys. A positive result is a key that passes a liveness check, for example a Stripe key for which the "retrieve" call succeeds.
  4. Scope of a leaked Stripe key. Load the key into the Stripe Postman collection and attempt read and write operations. A positive result is a successful call against the live account rather than an authentication error.

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

What happened, in plain words

A security researcher ordered food through an Android food delivery app from Puerto Rico. The app's real name is withheld, so the author calls it hungrybite.com. While using the app, the researcher found two separate problems.

The first problem was in the app's API. An API is the set of addresses a program uses to talk to a server, like a waiter who takes your order to the kitchen and brings the food back. When the app asked the server for a past purchase order, it sent an order number along with the request. By changing that number, the researcher could see other people's orders: their names, emails, phone numbers, addresses, and details about the delivery person. This kind of bug is called an IDOR (Insecure Direct Object Reference).

The second problem was inside the app itself. Android apps are packaged in a file called an APK, which is like a zip archive. The researcher opened the APK and found a file called string.xml that held a Stripe secret key. Stripe is a payment service that apps use to take money. That key was still valid, and the author notes the Stripe Postman collection allows pushes and pulls from the company's official Stripe account.

The author found the issues at the end of August 2021 and says a report with these and more vulnerabilities was sent to the app's security team; the issues were already patched.

What an IDOR is, with a simple example

An IDOR happens when a program uses a simple identifier, like a number, to decide which record to show you, and it does not check whether that record belongs to you. If you can guess or change the number, you can reach someone else's data.

The author uses Google Drive as an example. Imagine you open a document and the address bar shows:

Text
https://drive.google.com/document/101

The 101 at the end is the identifier of that document. If you change it to 102, you will almost certainly get an error such as "document not found" or "you do not have permission to view this document". That is because document 101 belongs to you, but document 102 probably belongs to another user, and Google Drive checks who is asking before it shows anything.

From the original on medium.com

In the food delivery app, the API allowed a purchase order parameter to be changed so that another user's information became visible.

The tools used

The researcher worked after ordering fast food through the app. The main tool was Burp Suite, which is an intercepting proxy. A proxy sits between your browser or app and the server, like a mail room that opens every letter, reads it, and can rewrite it before sending it on. Burp lets you pause a request, change a value in it, and send it forward.

For the second finding, the researcher used APK-Tools (https://www.kali.org/tools/apktool/) to reverse engineer the Android application. Reverse engineering here means unpacking the APK and reading the files inside it. The researcher also used Postman, a program for sending requests to APIs by hand, together with a collection of ready-made Stripe requests (https://github.com/stripe/stripe-postman). To check whether a token is alive, the author points to https://github.com/streaak/keyhacks.

Finding the first problem

After ordering fast food through the app, the researcher wanted to see whether any user data was leaking. The first thing tried was changing the price of the product purchase to $0. The server accepted the request with 200 OK.

From the original on medium.com

A 200 OK is the standard HTTP status code that means "the request succeeded". Seeing it here meant the server did not reject the modified price. That raised the question of whether free food was possible, but the researcher decided to look further and checked past Purchase Orders instead.

Step 1: change the purchase price to $0

With Burp Suite intercepting the purchase request, the price of the product purchase was changed to $0. The report does not include the raw request or response for this step, only the result.

Step 2: change the order number

In the past Purchase Orders view, the researcher changed the orderId parameter from 321448 to 321444:

A parameter is a named value sent along with a request, like a field on a form. Here orderId is the name and 321448 is the value. The arrow shows the original value on the left and the changed value on the right.

The server accepted the request with 200 OK, and the response contained the order of another user.

From the original on medium.com

Bingo.

From the original on medium.com

The response showed the customer user as well as the delivery person in charge of that order, including all the personal information and some URL with photos of the delivery person. A URL is a web address, the same kind you type into a browser.

The data exposed in that response, as listed by the author, was:

Field
CostumerName
CostumerEmail
PhoneCustumer
CostumerAddress
Costumer Comment to deliveryman
Username deliveryman
Email deliveryman
Phone deliveryman
Description of the deliveryman vehicle (Plate, Model, Colour, Brand)
Order Tracking URL
Photo ID deliveryman

Changing the identifier value returned another user's order, and the response contained both the customer's and the delivery person's personal data. The response returns both the customer's and the delivery person's personal data.

Step 3: open the APK and look inside

Some Android and iOS apps store tokens that can be abused to leak harmful data. A token is a long string of characters that acts like a key: whoever holds it can use the service it belongs to, without needing a username or password. The author notes that some keys are harmless and are required to be in the app, for example Google and Mapbox API keys, while others can expose harmful data that could affect the company.

The tool used to reverse engineer Android apps and discover secret tokens stored in them is available online; APK-Tools is one of them.

From the original on medium.com

After reverse engineering the APK, the researcher found a string.xml file that stores the global variables of the app. A global variable is a value that the whole program can read, so putting a secret there means every part of the app can use it, and so can anyone who opens the file.

From the original on medium.com

That file contained secret keys used to access external services of the application. One that caught the researcher's attention was the STRIPE_SECRET_KEY. Stripe is an online payment processing system for Android, iOS and web apps that makes it easy to make payments.

From the original on medium.com

Step 4: check whether the Stripe key is alive

To check whether a token is alive, the author recommends https://github.com/streaak/keyhacks. "Alive" here means the key still works: the service has not revoked it, so it can still be used.

From the original on medium.com

The STRIPE_SECRET_KEY was valid. To verify the scope of the token, the researcher used Postman with the JSON Format Collection offered by Stripe for Postman (https://github.com/stripe/stripe-postman). Scope means how much a key is allowed to do: read only, or read and write, and on which account. That collection allows pushes and pulls from the official Stripe account of hungrybite.com, something the author describes as potentially devastating.

To verify whether a Stripe access key is alive, the Stripe API method "retrieve" can be used. It retrieves information about a specific object, such as a Stripe account, and if the call succeeds, the provided access key is valid.

From the original on medium.com

The report does not include the exact request or the response body of the Stripe call.

Why this happened

Changing the orderId value returned another user's order, which the author describes as an IDOR. On the app side, the Stripe secret key was hardcoded in the APK's string.xml, which stores the global variables of the app. Anything shipped in the APK can be extracted by reverse engineering. The author notes that developers frequently use tokens and forget the access token in public repositories, which is potentially dangerous.

What the impact was

Through the IDOR, an authenticated user could read other customers' orders, including names, emails, phone numbers, addresses, comments to the delivery person, and the delivery person's username, email, phone, vehicle description (plate, model, colour, brand), order tracking URL and photo ID. The price change to $0 was accepted by the server with 200 OK, and the author wondered whether free food was possible. The exposed Stripe secret key was valid, and the author notes the Stripe Postman collection allows pushes and pulls from the official Stripe account of hungrybite.com, which the author describes as potentially devastating.

How it was fixed

The author says a report with these and more vulnerabilities was sent to the security team and the issues were already patched; the report does not describe the code changes. For the token, the author recommends revoking it and generating a new one, not leaving API access tokens in public repositories, and periodically changing tokens to prevent them from being stolen. Revoking means telling the service to stop accepting that key, so even if someone else has a copy, it no longer works.

Things to try on other apps

  1. Sequential order identifiers. On any app with a purchase or order history, change the numeric identifier to a neighbouring value. A positive result is a 200 OK with another user's order data instead of an authorisation error.
  2. Price parameter tampering. Intercept the purchase request and set the price to 0. A positive result is a 200 OK that accepts the modified price.
  3. Hardcoded secrets in mobile apps. Decompile the APK with APK-Tools and inspect string.xml and other resource files for keys. A positive result is a key that passes a liveness check, for example a Stripe key for which the "retrieve" call succeeds.
  4. Scope of a leaked Stripe key. Load the key into the Stripe Postman collection and attempt read and write operations. A positive result is a successful call against the live account rather than an authentication error.

Glossary

  • API: the set of addresses and rules a program uses to talk to a server, like a waiter carrying orders between you and the kitchen.
  • APK: the file format Android apps are packaged in; it is essentially a zip archive of the app's files.
  • APK-Tools: a program that unpacks an APK so you can read the files inside it.
  • Burp Suite: a tool that sits between your app and the server, letting you pause, read and change requests.
  • Endpoint: a specific address on a server that accepts requests, for example the one that returns a purchase order.
  • Global variable: a value stored once and readable by the whole program.
  • Hardcoded: written directly into the app's files instead of being fetched from a safe place at runtime.
  • HTTP status code: a number the server sends back to say how the request went; 200 OK means it succeeded.
  • IDOR (Insecure Direct Object Reference): a bug where a program uses a guessable identifier to pick a record and does not check that the record belongs to you.
  • Intercepting proxy: a tool that sits between your app and the server and lets you read and modify the traffic.
  • Parameter: a named value sent with a request, like a field on a form; orderId is one.
  • Postman: a program for sending requests to APIs by hand and inspecting the responses.
  • Reverse engineering: taking a finished program apart to see how it is built and what is inside it.
  • Revoke: tell a service to stop accepting a key or token, so copies of it stop working.
  • Scope (of a key): how much a key is allowed to do and on which account.
  • Sequential identifier: an identifier that goes up one by one, such as 321444, 321445, 321446, which makes it easy to guess.
  • Stripe: an online payment processing service used by apps to take payments.
  • Token: a long string of characters that acts like a key, letting whoever holds it use a service.
  • URL: a web address, the kind you type into a browser.

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.