Skip to content
IDOR Write-up Intermediate

Exploitation

A test environment shared authentication with the production Starbucks Singapore app, and an endpoint accepted an email address to associate a session with that account. An attacker could take over any account by knowing the victim's email address, accessing personal information and spending stored credits.

Kamil Onur Özkaleli Follow

Published on kamilonurozkaleli.com

Bounty$6,000 View original

While browsing Starbucks Singapore, I noticed a page loaded with content from a 3rd party site. Let’s call this site example.com in order not to disclose it.

Kamil Onur Özkaleli (@ko2sec), on kamilonurozkaleli.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. 5 min read.

Context

Starbucks Singapore runs its card and account features at card.starbucks.com.sg. While browsing that site, the researcher noticed a page that loaded content from a third-party site, referred to throughout the report as example.com to avoid disclosing it. Researching that site turned up a copy of the same login page under the directory example.com/starbucks.

The feature at the centre of the report is the account and profile system: users register and log in, and the application stores personal information and, potentially, loaded card credit that can be spent in Starbucks stores through the mobile application.

Setup

The researcher worked with two applications: the production site card.starbucks.com.sg and the test copy at example.com/starbucks. No special tools or versions are described. The only precondition that mattered was an ordinary user account, which the researcher created at card.starbucks.com.sg.

Finding it

The discovery of a second copy of the login page raised two possibilities:

  1. The application could be an environment where current developments of card.starbucks.com.sg are made and tested.
  2. It could be an old test environment left idle.

Either way the chance of a bug looked higher there, but the open question was whether a bug found in the test copy would affect production. To answer that, the researcher created a user account at card.starbucks.com.sg and tried to log into example.com/starbucks with it. The login succeeded. Both applications appeared to share the same authentication mechanism.

Scheme-1, both applications are using same database table.
Scheme-1, both applications are using same database table. From the original on kamilonurozkaleli.com

The diagram shows both applications using the same database table, which is what the successful cross-login implied.

Exploitation

Step 1: find an endpoint that only exists in the test copy

Browsing example.com/starbucks, the researcher found an endpoint that does not exist in the production app. It accepted the following POST data:

HTTP
email=[redacted]

The endpoint takes an email parameter. Sending the email address of the account to be taken over in that parameter and issuing the request caused partial information about the account belonging to that email address to appear on the researcher's own profile page.

Step 2: hit the CSRF wall

The takeover was not complete at this point. A password change request failed because the CSRF token generated in this application was invalid.

Step 3: move the session to production

To get around the CSRF problem, the researcher copied the PHPSESSID cookie value from example.com/starbucks to card.starbucks.com.sg. The result was full visibility of the victim's information in the production environment. The valid CSRF tokens generated there allowed the password to be changed, and the account could be completely taken over by anyone who knew the email address.

Multiplying the reward

The researcher then found two more test environments on example.com, referred to as example.com/starbucks2 and example.com/starbucks3. The production account at card.starbucks.com.sg did not work on either of them. example.com/starbucks2 did not allow a new account to be created, so the researcher tried example.com/starbucks3 and successfully created a new account there.

The researcher's assessment was that example.com/starbucks2 and example.com/starbucks3 were using test tables, which is why production users could not log in to them.

With the account created at example.com/starbucks3, the researcher could log in to example.com/starbucks2, but not to card.starbucks.com.sg. However, the PHPSESSID copied from example.com/starbucks2 was valid on card.starbucks.com.sg, and that account could be used there. The chain was:

  1. Create a dummy account with the victim's email address at example.com/starbucks3. (Add to testusers table.)
  2. At example.com/starbucks2, associate the account for that email with your own account via the same endpoint. (Associate the PHPSESSID with the email in the testusers table.)
  3. Copy the PHPSESSID to card.starbucks.com.sg and takeover. (Takeover the real account of the same email address in the production users table.)
Scheme-2, relations between applicaitons and tables.
Scheme-2, relations between applicaitons and tables. From the original on kamilonurozkaleli.com

The second diagram shows the relations between the applications and the tables.

Root cause

The endpoint in the test copy accepted an email address and acted on the account belonging to it without checking that the caller owned that account. That is a classic IDOR: the object reference (the email) is supplied by the client and trusted. The test copy also generated CSRF tokens that were not valid for the action, so the direct path to a password change was blocked there.

The deeper problem was the shared session mechanism. A PHPSESSID issued by the test application was accepted by the production application, so a session created in a weaker environment carried the authority of the production site, including its valid CSRF tokens. The test environments also shared or overlapped user tables in a way that let an account created in one test environment be associated with an email in another, and then be used against production. The report does not describe the server-side code behind the shared session.

Impact

An attacker who knows a user's email address could see all personal information belonging to that user and completely take over the account. If the account has loaded credit, those credits can be spent in Starbucks stores via the mobile application.

Fix

The report does not state what was changed. The changes that would address the issues described are: enforce authorisation on the endpoint so that a session can only act on the account it belongs to, and stop sharing session identifiers between test and production applications so that a session issued by a test environment is never accepted by production.

Variants to test

  1. Cross-environment session reuse. Log in on a staging or test copy of a target and replay the session cookie against production. A positive result is being authenticated on production with a session issued elsewhere.
  2. Email-keyed endpoints. Send another user's email address to any endpoint that takes an email parameter and observe whether profile data for that address is returned. A positive result is partial or full account data appearing on your own profile.
  3. CSRF token portability. Take a CSRF token from one environment and use it in another. A positive result is a state-changing action succeeding with a token minted elsewhere.
  4. Test-table chaining. Create an account in one test environment, associate it with a victim's email in a second, then use the resulting session against production. A positive result is a production takeover reached through test-only tables.

Timeline

Date Event
May 17th Report submitted
May 18th Triaged
May 20th Rewarded $4000 bounty
Jun 17th Rewarded $2000 bounty as 1.5x multiplier

The HackerOne report is available at hackerone.com/reports/876300.

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

What happened, in plain words

Starbucks Singapore has a website where customers manage their Starbucks card and their account: card.starbucks.com.sg. You can register, log in, see your personal details, and if you have loaded money onto your card, that balance sits in the account too.

While browsing that site, the researcher noticed that one of its pages loaded content from a completely different website. The report calls that other site example.com so as not to name it publicly. When the researcher looked around on example.com, they found a copy of the very same Starbucks login page, sitting in a folder called example.com/starbucks.

That raised an obvious question: is this a place where new versions of the Starbucks site are built and tested before going live, or is it an old test site that nobody switched off? Either way, test sites are often less carefully protected than the real thing, so a bug there was likely. But a bug on a test site is only interesting if it also affects the real, live site where real customers and real money are. So the researcher did a simple experiment: they created an ordinary account on the real site, card.starbucks.com.sg, and then tried to log in with that same account on the test copy at example.com/starbucks. It worked. The two sites were clearly sharing the same login system, which meant a bug in the test copy could reach real customers.

From there the researcher found a feature in the test copy that does not exist on the live site. You could send it an email address, and it would act on the account belonging to that address, without ever checking that the person sending the request actually owned that account. That kind of flaw is called an IDOR, short for Insecure Direct Object Reference: the program takes an identifier handed to it by the visitor (here, an email address) and trusts it, instead of checking whether the visitor is allowed to touch that thing.

At first the researcher could only see part of the victim's information, because the test copy refused the password change: the security token it generated for that action was not accepted. A CSRF token is a small secret value a site puts into a form so that it can tell a genuine submission from one forged by another website; if the token is wrong, the site refuses the action. The researcher got around this by taking the session cookie from the test copy and using it on the live site. A session cookie is the little badge your browser carries after you log in, so the server knows who you are on each request. The live site accepted the badge issued by the test site, and because the live site generated valid tokens, the password could now be changed. The account was fully taken over by anyone who knew the victim's email address.

The researcher then found two more test environments, called example.com/starbucks2 and example.com/starbucks3, and built a longer chain that reached the same takeover through them. The report was submitted on May 17th, triaged the next day, and paid $4000 on May 20th, with a further $2000 on June 17th as a 1.5x multiplier.

The pieces involved

Before the steps make sense, a few everyday ideas need names.

  • Production is the real, live website that customers use. Here that is card.starbucks.com.sg.
  • A test environment (also called staging) is a copy of the site used to try out changes before they go live. It often sits on a different address, sometimes on a different company's server.
  • An endpoint is one specific address inside a web application that does one specific job, like "log in" or "change password". When you fill in a form and press a button, your browser sends your answers to an endpoint.
  • A POST request is the way a browser sends data to a server when it is submitting a form. The data travels in the body of the request, in pairs like name=value.
  • A parameter is one of those named values. In email=[redacted], email is the parameter name and [redacted] is the value.
  • A cookie is a small piece of text a website asks your browser to store and send back on every later request to that site. It is how a website remembers that you already logged in.
  • PHPSESSID is the standard name PHP (a programming language many websites are built with) gives to the cookie that holds a session identifier. A session identifier is a long random string that stands for "this logged-in user". Whoever holds it is treated as that user.
  • A CSRF token is a second, separate secret that a site puts inside forms that change something, such as a password change. The site checks it to be sure the request came from its own pages and not from a malicious site trying to act on your behalf. CSRF stands for Cross-Site Request Forgery.
  • An IDOR is when a program accepts an identifier from the visitor and acts on it without checking permission. A comparison: a cloakroom that hands out any coat to anyone who reads the ticket number aloud, without checking that the ticket is theirs.
  • Account takeover means logging in as somebody else and controlling their account, including changing their password so the real owner is locked out.

The feature at the centre of the report is the account and profile system: users register and log in, the application stores personal information, and potentially loaded card credit that can be spent in Starbucks stores through the mobile application.

Setting up

The researcher worked with two applications: the production site card.starbucks.com.sg and the test copy at example.com/starbucks. No special tools or versions are described. The only precondition that mattered was an ordinary user account, which the researcher created at card.starbucks.com.sg.

Finding it

Seeing a second copy of the login page raised two possibilities:

  1. The application could be an environment where current developments of card.starbucks.com.sg are made and tested.
  2. It could be an old test environment left idle.

Either way the chance of a bug looked higher there, but the open question was whether a bug found in the test copy would affect production. To answer that, the researcher created a user account at card.starbucks.com.sg and tried to log into example.com/starbucks with it. The login succeeded. Both applications appeared to share the same authentication mechanism.

Scheme-1, both applications are using same database table.
Scheme-1, both applications are using same database table. From the original on kamilonurozkaleli.com

The diagram shows both applications using the same database table, which is what the successful cross-login implied. A database table is simply an organised list of records, like a spreadsheet with one row per user; if two websites read and write the same table, an account made on one exists on the other.

Exploitation

Step 1: find an endpoint that only exists in the test copy

Browsing example.com/starbucks, the researcher found an endpoint that does not exist in the production app. It accepted the following POST data:

HTTP
email=[redacted]

This is the body of a form submission. There is one parameter, named email, and its value is the address [redacted]. In the researcher's test, that value was replaced with the email address of the account they wanted to take over. The endpoint takes an email parameter. Sending the email address of the account to be taken over in that parameter and issuing the request caused partial information about the account belonging to that email address to appear on the researcher's own profile page. In other words, the site looked up the account by the email it was given and showed some of that account's details to whoever asked, without checking that the asker owned it.

Step 2: hit the CSRF wall

The takeover was not complete at this point. A password change request failed because the CSRF token generated in this application was invalid. The test copy was willing to show data, but not to accept a password change, because the token it generated was invalid.

Step 3: move the session to production

To get around the CSRF problem, the researcher copied the PHPSESSID cookie value from example.com/starbucks to card.starbucks.com.sg. Copying a cookie means taking that stored string out of the browser's storage for one site and putting it into the requests sent to the other site, so the second site sees the same session identifier. The result was full visibility of the victim's information in the production environment. The valid CSRF tokens generated there allowed the password to be changed, and the account could be completely taken over by anyone who knew the email address.

Multiplying the reward

The researcher then found two more test environments on example.com, referred to as example.com/starbucks2 and example.com/starbucks3. The production account at card.starbucks.com.sg did not work on either of them. example.com/starbucks2 did not allow a new account to be created, so the researcher tried example.com/starbucks3 and successfully created a new account there.

The researcher's assessment was that example.com/starbucks2 and example.com/starbucks3 were using test tables, which is why production users could not log in to them. A test table is a separate list of users kept for testing, so accounts in the real list are unknown there.

With the account created at example.com/starbucks3, the researcher could log in to example.com/starbucks2, but not to card.starbucks.com.sg. However, the PHPSESSID copied from example.com/starbucks2 was valid on card.starbucks.com.sg, and that account could be used there. The chain was:

  1. Create a dummy account with the victim's email address at example.com/starbucks3. (Add to testusers table.)
  2. At example.com/starbucks2, associate the account for that email with your own account via the same endpoint. (Associate the PHPSESSID with the email in the testusers table.)
  3. Copy the PHPSESSID to card.starbucks.com.sg and takeover. (Takeover the real account of the same email address in the production users table.)
Scheme-2, relations between applicaitons and tables.
Scheme-2, relations between applicaitons and tables. From the original on kamilonurozkaleli.com

The second diagram shows the relations between the applications and the tables.

Why it worked

The endpoint in the test copy accepted an email address and acted on the account belonging to it without checking that the caller owned that account. That is a classic IDOR: the object reference (the email) is supplied by the client and trusted. The test copy also generated CSRF tokens that were not valid for the action, so the direct path to a password change was blocked there.

The deeper problem was the shared session mechanism. A PHPSESSID issued by the test application was accepted by the production application, so a session created in a weaker environment carried the authority of the production site, including its valid CSRF tokens. The test environments also shared or overlapped user tables in a way that let an account created in one test environment be associated with an email in another, and then be used against production. The report does not describe the server-side code behind the shared session.

What an attacker could do

An attacker who knows a user's email address could see all personal information belonging to that user and completely take over the account. If the account has loaded credit, those credits can be spent in Starbucks stores via the mobile application.

How it was fixed

The report does not state what was changed. The changes that would address the issues described are: enforce authorisation on the endpoint so that a session can only act on the account it belongs to, and stop sharing session identifiers between test and production applications so that a session issued by a test environment is never accepted by production.

Things worth trying elsewhere

  1. Cross-environment session reuse. Log in on a staging or test copy of a target and replay the session cookie against production. A positive result is being authenticated on production with a session issued elsewhere.
  2. Email-keyed endpoints. Send another user's email address to any endpoint that takes an email parameter and observe whether profile data for that address is returned. A positive result is partial or full account data appearing on your own profile.
  3. CSRF token portability. Take a CSRF token from one environment and use it in another. A positive result is a state-changing action succeeding with a token minted elsewhere.
  4. Test-table chaining. Create an account in one test environment, associate it with a victim's email in a second, then use the resulting session against production. A positive result is a production takeover reached through test-only tables.

Timeline

Date Event
May 17th Report submitted
May 18th Triaged
May 20th Rewarded $4000 bounty
Jun 17th Rewarded $2000 bounty as 1.5x multiplier

Triaged means the programme's security team reviewed the report and confirmed it was a real issue worth working on. The HackerOne report is available at hackerone.com/reports/876300.

Glossary

  • Production: the real, live website that customers use.
  • Test environment / staging: a copy of a website used to try changes before they go live.
  • Endpoint: one specific address inside a web application that performs one specific job.
  • POST request: a request in which the browser sends form data to a server in the body.
  • Parameter: a named value inside a request, such as email in email=[redacted].
  • Cookie: a small piece of text stored by the browser and sent back to a site on later requests, used to remember who you are.
  • Session: the state of being logged in, represented by a session identifier.
  • Session identifier: a long random string that stands for a logged-in user; whoever holds it is treated as that user.
  • PHPSESSID: the standard cookie name PHP uses for the session identifier.
  • CSRF: Cross-Site Request Forgery, an attack where another site makes your browser send a request you did not intend.
  • CSRF token: a secret value placed in forms that change something, so the site can tell a genuine submission from a forged one.
  • IDOR: Insecure Direct Object Reference, when a program acts on an identifier supplied by the visitor without checking permission.
  • Authentication mechanism: the system that decides who a visitor is when they log in.
  • Database table: an organised list of records, like a spreadsheet with one row per user.
  • Test table: a separate list of users kept for testing, so real accounts are not present in it.
  • Account takeover: logging in as somebody else and controlling their account, including changing their password.
  • Bounty: a payment made by a company to a researcher who reports a security bug.
  • Triaged: reviewed and confirmed as a real issue by the programme's security team.
  • Multiplier: a factor applied to a bounty, here 1.5x, increasing the reward.

More by Kamil Onur Özkaleli

View all

2 more disclosed reports, best first.

More from Starbucks

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.