Skip to content
Access control Write-up Advanced

$5k Service dependencies

Ezequiel Pereira Follow

Published on ezequiel.tech

Bounty$5,000 View original

Original post on my old site

Ezequiel Pereira, on ezequiel.tech

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 Google Service Management API lets developers describe a service through a Service object, push that configuration with the create or submit methods, and then roll it out so the settings take effect. Among the settings a Service object can carry are usage settings: requirements a consumer must satisfy, or rules for calling particular methods.

On 18 November 2016, while looking through those usage settings, I found a hidden option called dependsOnServices. It was documented as an array of strings, with this description:

Text
Services that must be activated in order for this service to be used.The set of services activated as a result of these relations are allactivated in parallel with no guaranteed order of activation.Each string is a service name, e.g. `calendar.googleapis.com`.

The option was meant to be reachable only by Google internal clients. The idea behind it is straightforward: when a service is enabled, the services it depends on are activated alongside it.

Setup

I tested the field through the Google Cloud Console client, which talks to servicemanagement.clients6.google.com. The request needs an authenticated session: a SAPISIDHASH authorization header, an X-Origin header naming the console, and the usual Google cookies. I used a service of my own, a project of mine, and an API key for the console client.

Finding it

The field was a hidden option meant to be reachable only by Google internal clients, and its semantics were interesting: whatever service names I put in the array would be activated as a side effect of enabling my own service.

Exploitation

Step 1: push a configuration containing dependsOnServices

I crafted a Service object with the hidden field and sent it to the console client's configs endpoint, then rolled the configuration out and enabled my service on one of my projects:

HTTP
POST /v1/services/<SERVICE NAME>/configs?key=[redacted] HTTP/1.1
Host: servicemanagement.clients6.google.com
Authorization: SAPISIDHASH <SAPISIDHASH>
X-Origin: https://console.cloud.google.com
Cookie: <GOOGLE COOKIES>
Content-Length: <CONTENT-LENGTH>

{
  "name": "<SERVICE NAME>",
  "producerProjectId": "<PROJECT>",
  "configVersion": 3,  "usage": {    "dependsOnServices": [      ...<SERVICES>...    ]  }
}

The body names my service and its producer project, sets configVersion to 3, and puts the list of target services under usage.dependsOnServices. The key parameter is the console client's API key, and the SAPISIDHASH header and cookies authenticate the session.

Step 2: enable the service and observe the side effect

After a little testing I understood the behaviour: every time I enable my service on a project, each service named in usage.dependsOnServices is enabled too, as long as the project satisfies that service's usage requirements. Billing enabled is the example I give for compute.googleapis.com.

Step 3: the missing authorisation check

Enabling a service normally requires the servicemanagement.services.bind permission. The dependency logic never checked whether the user had been granted that permission for the services in the list. So an attacker could bypass the authorisation check that is usually performed and enable other people's services without their permission, and probably without their knowledge.

This matters beyond ordinary services. Among the private services reachable this way are private Google APIs meant only for internal use, for development (including staging and test versions), or for a small set of white-listed users such as Trusted Testers and the Google My Business API. Those APIs may not be held to the same security standards as public Google APIs, and may have flaws that allow very dangerous attacks.

Step 4: reward and the first attempted fix

After my original report, Google rewarded me $5000, after I successfully demonstrated that I could enable and access private internal Google APIs. One day I received an email from Google:

I did as the message said and checked whether I could replicate the bug. Through the original vector, the Google Cloud Console client, I could not: it no longer had access to the field. Knowing that any client with the proper visibility access would still be able to set it, I tried the Firebase client. Surprisingly, it not only had access to the field, the bug worked flawlessly as reported.

Step 5: a vector that works from any client

Google then blocked access to the field for the Firebase client, but not for other clients. I also found a much better approach that let any client set the field: the submit configuration method. Sending usage.dependsOnServices through submit worked regardless of whether the client had access to the field through the API, because the field was set in the file given to the method, which is checked differently.

About a month after reporting the new vector I asked Google how it was going, and got this response:

Root cause

When a service was enabled, each service in usage.dependsOnServices was activated without checking that the caller held servicemanagement.services.bind on those services. The only check was that the project met each dependent service's usage requirements, such as billing. The hidden field was supposed to be restricted to internal clients, but the same field could be set through another client, and later through the submit method, where the field is set in the file given to the method, which is checked differently.

Impact

An attacker who can create and roll out a service configuration can enable services on a project, including services the attacker has no permission to bind and private or internal Google APIs, as long as the project satisfies their usage requirements. The only condition is that the project satisfies the usage requirements of the services being enabled. The report notes that such private APIs may not be subject to the same security standards as public ones, and that flaws in them could allow very dangerous attacks. I demonstrated enabling and accessing private internal Google APIs.

Fix

Google's fixes came in stages:

  1. Access to the field was removed from the Google Cloud Console client, then from the Firebase client, but other clients still had it.
  2. A few months after the submit vector was reported, an internal validator was added to the submit configuration method, which successfully blocked setting the field that way.
  3. In March 2018 the original vector was fixed for all clients with access to the field by deprecating usage.dependsOnServices. The field can still be set, but it has no effect when a service is enabled.

Variants to test

  • Other hidden fields in the same resource. Look for options documented as internal-only in a Service object and try to set them through a client that still exposes them. A positive result is the field being accepted and taking effect on rollout.
  • Alternate clients for the same backend. When one client loses access to a field, try others that talk to the same API with different visibility rules, as the Firebase client did here. A positive result is the field being accepted where it should not be.
  • File-based configuration paths. Try methods that take a configuration file, such as submit, rather than a direct resource write. A positive result is the field being honoured even though the direct API path rejects it.
  • Side-effect activation logic. For any feature that activates related resources on the caller's behalf, check whether the caller's permission on those related resources is verified. A positive result is a resource being enabled or created that the caller could not touch directly.

Timeline (UTC-3)

Date Event
2016-11-18 Initial submission and triage
2016-12-06 Google Security team waiting on the product team to make a reward decision
2016-12-13 Working example of the bug requested (and given)
2017-01-10 A reward of 5000 dollars is issued
2017-05-05 Bug "fixed" and verified by a Google security engineer
2017-05-08 Sent example of bug still working with the Firebase client
2017-05-20 Discovered and reported the "submit method" vector
2017-06-15 Asked how the fix was going
2017-06-19 Google replied they were investigating ways to fix the "submit method" vector, but it was tricky
A few months later "Submit method" vector fixed
March 2018 usage.dependsOnServices field deprecated, thus fixed

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

What happened, in plain words

Google runs a system that lets developers describe and publish their own online services. A developer writes down what the service is called, who makes it, and how it should behave, sends that description to Google, and then "rolls it out" so the settings actually take effect. Think of it like filling in a form about a new shop and then pressing a button that opens the shop to the public.

One of the settings in that form is a hidden option called dependsOnServices. It lets a service say "I need these other services to be switched on as well". The idea is sensible: if your service cannot work without, say, a calendar service, then switching on your service should switch on the calendar service too.

The flaw was that when Google switched on those extra services, it never checked whether the person doing it had been granted permission to switch them on. So by putting other people's services (including private Google services meant only for internal use) into that list, an attacker could switch them on without permission. Google paid $5,000 for the report, and the fix took well over a year and several attempts.

Background you need first

What an API is

An API (Application Programming Interface) is a way for one piece of software to talk to another. A useful comparison: a restaurant. You do not walk into the kitchen and cook; you read the menu, tell the waiter what you want, and food comes back. The menu and the waiter are the API. You can only ask for things the menu offers, in the way the restaurant expects.

Most of what happens when you use a website is your browser making API requests to a server: "give me this page", "save this setting", "log me in". Each request has a method (like GET to read or POST to send something), a URL saying what it is about, some headers (extra labels attached to the request), and sometimes a body (the actual data being sent).

What a cookie and a token are

When you log in to a website, the server gives your browser a small piece of data called a cookie. Your browser sends that cookie back with every later request, and that is how the server recognises you. It is like a wristband at an event: you show it at the door and you get in without showing your ID again.

A token is similar but usually travels in a header rather than a cookie. It is a string that proves who you are or what you are allowed to do. If someone steals your cookie or token, they can pretend to be you, which is why they are treated as secrets.

What the Google Service Management API is

The Google Service Management API is the part of Google Cloud that lets developers describe a service and publish that description. The description is called a Service object: a structured block of settings, a bit like a form with named fields. You send it to Google with a method called create or submit, and then you roll it out, which means "make these settings live".

Among the settings a Service object can carry are usage settings: rules about what a consumer of the service must satisfy, or how particular methods may be called.

What the vulnerability class is

This bug is a missing authorisation check. Authorisation means "are you allowed to do this?", as opposed to authentication, which means "who are you?". A missing authorisation check is like a building where the front desk checks your badge, but the side door that leads to the same rooms has no guard at all. The system knows who you are; it just forgets to ask whether you are allowed.

Finding the hidden option

On 18 November 2016, while looking through those usage settings, I found a hidden option called dependsOnServices. It was documented as an array of strings (a list of text values), with this description:

Text
Services that must be activated in order for this service to be used.The set of services activated as a result of these relations are allactivated in parallel with no guaranteed order of activation.Each string is a service name, e.g. `calendar.googleapis.com`.

Line by line, in plain words:

  • The first sentence says that the services in the list must be switched on before this service can be used. In other words, they are dependencies.
  • The second sentence says that all of those dependencies get switched on at the same time, and you cannot rely on any particular order. If you listed three services, you should not assume the first is ready before the third.
  • The third sentence explains the format: each entry is a service name, and the example given is calendar.googleapis.com.

The option was meant to be reachable only by Google internal clients. The idea behind it is straightforward: when a service is enabled, the services it depends on are activated alongside it.

Setting up the test

I tested the field through the Google Cloud Console client, which talks to servicemanagement.clients6.google.com. A "client" here means a particular piece of software that talks to Google's servers on your behalf; the Cloud Console is the web interface you see when you manage things in Google Cloud.

The request needs an authenticated session: a SAPISIDHASH authorization header, an X-Origin header naming the console, and the usual Google cookies. In plain terms:

  • The SAPISIDHASH header is a value derived from your Google session that proves the request really comes from you.
  • The X-Origin header tells the server which website the request is coming from, here the Cloud Console.
  • The cookies are the wristband described earlier: they carry your logged-in session.

I used a service of my own, a project of mine, and an API key for the console client. An API key is a string that identifies which application is calling; it is not the same as being logged in, and it is not a secret in the way a password is, but it still should not be shared carelessly.

Why the field itself was the finding

The field itself was the finding. It appeared in the Service resource but was not something a normal client should be able to set, and its meaning was interesting: whatever service names I put in the list would be switched on as a side effect of enabling my own service. A side effect here means something that happens as a consequence of an action, without you asking for it directly, like a shop's alarm also switching on the lights next door.

Step 1: push a configuration containing dependsOnServices

I crafted a Service object with the hidden field and sent it to the console client's configs endpoint, then rolled the configuration out and enabled my service on one of my projects:

HTTP
POST /v1/services/<SERVICE NAME>/configs?key=[redacted] HTTP/1.1
Host: servicemanagement.clients6.google.com
Authorization: SAPISIDHASH <SAPISIDHASH>
X-Origin: https://console.cloud.google.com
Cookie: <GOOGLE COOKIES>
Content-Length: <CONTENT-LENGTH>

{
  "name": "<SERVICE NAME>",
  "producerProjectId": "<PROJECT>",
  "configVersion": 3,  "usage": {    "dependsOnServices": [      ...<SERVICES>...    ]  }
}

Line by line:

  • POST /v1/services/<SERVICE NAME>/configs?key=... is the request line. POST means "I am sending data". The path says which service's configurations I am touching, and ?key=... passes the console client's API key as part of the URL.
  • Host: servicemanagement.clients6.google.com says which server the request is addressed to.
  • Authorization: SAPISIDHASH <SAPISIDHASH> carries the proof that the request is from my logged-in session. The placeholder stands for the real value.
  • X-Origin: https://console.cloud.google.com says the request originates from the Cloud Console web page.
  • Cookie: <GOOGLE COOKIES> carries the session cookies.
  • Content-Length: <CONTENT-LENGTH> says how many bytes the body below contains, so the server knows where it ends.
  • The body is a JSON object (a text format for structured data, using curly braces and quoted names). name is my service's name, producerProjectId is the project that produces the service, and configVersion is set to 3.
  • usage.dependsOnServices is the hidden list. The ...<SERVICES>... stands for the service names I wanted switched on.

The body names my service and its producer project, sets configVersion to 3, and puts the list of target services under usage.dependsOnServices. The key parameter is the console client's API key, and the SAPISIDHASH header and cookies authenticate the session.

Step 2: enable the service and observe the side effect

After a little testing I understood the behaviour: every time I enable my service on a project, each service named in usage.dependsOnServices is enabled too, as long as the project satisfies that service's usage requirements. Billing enabled is the example I give for compute.googleapis.com.

In everyday terms: switching on my service also flipped the switches for everything on my list, provided the project was set up in a way those services accept. For a service that needs billing, the project must have billing turned on; otherwise that particular dependency is not switched on.

Step 3: the missing authorisation check

Enabling a service normally requires the servicemanagement.services.bind permission. A permission is a named rule that says "this account may do this specific thing". The dependency logic never checked whether the user had been granted that permission for the services in the list. So an attacker could bypass the authorisation check that is usually performed and enable other people's services without their permission, and probably without their knowledge.

This matters beyond ordinary services. Among the private services reachable this way are private Google APIs meant only for internal use, for development (including staging and test versions), or for a small set of white-listed users such as Trusted Testers and the Google My Business API. Those APIs may not be held to the same security standards as public Google APIs, and may have flaws that allow very dangerous attacks.

Why that is serious: a public API is exposed to the whole world and is therefore tested and hardened heavily. An internal or staging API is often built on the assumption that outsiders cannot reach it at all. If you can switch it on and call it, you are testing code that was never meant to face you.

Step 4: reward and the first attempted fix

After my original report, Google rewarded me $5000, after I successfully demonstrated that I could enable and access private internal Google APIs. One day I received an email from Google:

The image shows the email Google sent. I did as the message said and checked whether I could replicate the bug. Through the original vector, the Google Cloud Console client, I could not: it no longer had access to the field. A vector here means a route or method of reaching the bug; closing one route does not necessarily close the others.

Knowing that any client with the proper visibility access would still be able to set it, I tried the Firebase client. Firebase is another Google product with its own web interface and its own way of talking to Google's servers. Surprisingly, it not only had access to the field, the bug worked flawlessly as reported.

The lesson is that hiding a field from one client is not the same as forbidding it. If several different programs talk to the same backend, each with its own idea of which fields are visible, then removing the field from one program's menu does nothing about the others.

Step 5: a vector that works from any client

Google then blocked access to the field for the Firebase client, but not for other clients. I also found a much better approach that let any client set the field: the submit configuration method. Sending usage.dependsOnServices through submit worked regardless of whether the client had access to the field through the API, because the field was set in the file given to the method, which is checked differently.

In plain words: instead of typing the setting into a form field that the client controls, you hand the server a whole configuration file. The server checks the file by different rules, and those rules did not reject the hidden field. It is like a club that searches your pockets at the door but lets a sealed parcel through unchecked.

About a month after reporting the new vector I asked Google how it was going, and got this response:

The image shows Google's reply.

Root cause

The dependency expansion ran when a service was enabled, but the code that activated each service in usage.dependsOnServices did not verify that the caller held servicemanagement.services.bind on those services. The only check was that the project met each dependent service's usage requirements, such as billing. The hidden field was supposed to be restricted to internal clients, but visibility filtering on one client is not an authorisation control: the same field could be set through another client, and later through the submit method, where the configuration arrives in a file and is validated differently.

Put simply, there were two separate mistakes. First, the switch-on code trusted the list without asking whether the caller was allowed to switch those services on. Second, the protection for the hidden field was "do not show it in this client", which is a display decision, not a permission decision.

Impact

An attacker who can create and roll out a service configuration can enable arbitrary services on a project, including services the attacker has no permission to bind and private or internal Google APIs. The only condition is that the project satisfies the usage requirements of the services being enabled. The report notes that such private APIs may not be subject to the same security standards as public ones, and that flaws in them could allow very dangerous attacks. I demonstrated enabling and accessing private internal Google APIs.

Fix

Google's fixes came in stages:

  1. Access to the field was removed from the Google Cloud Console client, then from the Firebase client, but other clients still had it.
  2. A few months after the submit vector was reported, an internal validator was added to the submit configuration method, which successfully blocked setting the field that way. A validator is a check that inspects incoming data and rejects it if it breaks the rules.
  3. In March 2018 the original vector was fixed for all clients with access to the field by deprecating usage.dependsOnServices. Deprecating means the feature is retired: the field can still be set, but it has no effect when a service is enabled.

Variants to test

These are the kinds of follow-up checks the same thinking suggests:

  • Other hidden fields in the same resource. Look for options documented as internal-only in a Service object and try to set them through a client that still exposes them. A positive result is the field being accepted and taking effect on rollout.
  • Alternate clients for the same backend. When one client loses access to a field, try others that talk to the same API with different visibility rules, as the Firebase client did here. A positive result is the field being accepted where it should not be.
  • File-based configuration paths. Try methods that take a configuration file, such as submit, rather than a direct resource write. A positive result is the field being honoured even though the direct API path rejects it.
  • Side-effect activation logic. For any feature that activates related resources on the caller's behalf, check whether the caller's permission on those related resources is verified. A positive result is a resource being enabled or created that the caller could not touch directly.

Timeline (UTC-3)

Date Event
2016-11-18 Initial submission and triage
2016-12-06 Google Security team waiting on the product team to make a reward decision
2016-12-13 Working example of the bug requested (and given)
2017-01-10 A reward of 5000 dollars is issued
2017-05-05 Bug "fixed" and verified by a Google security engineer
2017-05-08 Sent example of bug still working with the Firebase client
2017-05-20 Discovered and reported the "submit method" vector
2017-06-15 Asked how the fix was going
2017-06-19 Google replied they were investigating ways to fix the "submit method" vector, but it was tricky
A few months later "Submit method" vector fixed
March 2018 usage.dependsOnServices field deprecated, thus fixed

Glossary

  • API: a defined way for one piece of software to ask another for something, like a menu and waiter in a restaurant.
  • API key: a string that identifies which application is making a request; not the same as a login.
  • Array: an ordered list of values, written in square brackets in JSON.
  • Authentication: proving who you are, for example by logging in.
  • Authorisation: deciding whether you are allowed to do a particular thing.
  • Authorisation check: the code that compares your identity and permissions against what the action requires.
  • Body: the data part of a request, after the headers.
  • Client: a program that talks to a server on your behalf, such as a web console or a mobile app.
  • Configuration: a set of settings that describe how something should behave.
  • Cookie: a small piece of data a site stores in your browser and your browser sends back, used to keep you logged in.
  • Dependency: something that must be present or switched on before another thing can work.
  • Deprecate: to retire a feature so that it still exists but no longer does anything.
  • Endpoint: a specific address on a server that accepts a particular kind of request.
  • Header: an extra labelled value attached to a request, such as who is asking or what format is being sent.
  • JSON: a text format for structured data using braces, brackets and quoted names.
  • Method (HTTP): the verb of a request, such as GET to read or POST to send.
  • Missing authorisation check: a flaw where the system knows who you are but never asks whether you are allowed.
  • Permission: a named rule granting an account the right to do a specific action.
  • Private API: an API meant only for internal or selected users, not the general public.
  • Project: a container in Google Cloud that holds your resources and settings.
  • Request: one message from a client to a server asking it to do something.
  • Resource: an object the API manages, such as a service or a configuration.
  • Rollout: the act of making a configuration live.
  • Service object: the structured description of a service, made of named settings.
  • Side effect: something that happens as a consequence of an action without being asked for directly.
  • Staging: a test copy of a system, close to the real one but not public.
  • Token: a string that proves identity or permission, usually sent in a header.
  • Triage: the first review of a report to decide how serious it is and who handles it.
  • Validator: a check that inspects incoming data and rejects it if it breaks the rules.
  • Vector: a route or method of reaching a bug.
  • White-listed: explicitly allowed, as opposed to open to everyone.

More by Ezequiel Pereira

View all

7 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.