Skip to content
Info disclosure Write-up Advanced

Decoding Google: Converting a Black Box to a White Box

The article describes how Google's internal API discovery documents can be accessed without authentication by using API keys or spoofed client headers, and how error messages leak parameter types. An attacker could enumerate hidden endpoints and parameters to find security bugs.

brutecat Follow

Published on brutecat.com

We've all been there - staring at Google's search box, overwhelmed by the maze of complexity hiding behind that minimalist interface, thinking it's impossible to break in. The key to decoding Google?

brutecat, on brutecat.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. 17 min read.

Context

Google's public APIs publish discovery documents, which work like Swagger documents and list the API methods available on services such as the YouTube Data API. The same mechanism exists for private APIs: the Internal People API, for example, exposes a discovery document at https://people-pa.googleapis.com/$discovery/rest that needs no authentication to view. The goal of this work is to turn Google's attack surface from a black box into a white box: enumerate every endpoint and every parameter, including hidden parameters that are not used by the real application and were left behind from developer testing, since those are the ones most likely to contain security bugs.

Not every private API is this open. Fetching the discovery document of the Takeout Private API returns an error:

Request

HTTP
GET /$discovery/rest
Host: takeout-pa.googleapis.com

Response

HTTP
HTTP/2 403 Forbidden
Content-Type: application/json; charset=UTF-8

{
  : {
    : 403,
    : ,
    :
  }
}

The way past that is to understand how Google authentication works, both on the web and on Android.

Setup

No special tooling is required to start. The researcher uses a browser and DevTools against https://chat.google.com, an API key observed in a real request, and later an Android refresh token. Two helper tools are published on GitHub: a Go tool called req2proto (with a gapi-service sub-tool) and a Rust program, aas-rs, that brute-forces Android client signatures. The web session and the Android refresh token flow both involve a Google account.

Finding it

Web authentication and the API key

A request to the People Internal API that looks up a Google user, captured from DevTools on https://chat.google.com, looks like this:

HTTP
POST /$rpc/[redacted].people.v2.minimal.InternalPeopleMinimalService/GetPeople HTTP/2
Host: people-pa.clients6.google.com
Cookie: <redacted>
Content-Type: application/json+protobuf
X-Goog-Api-Key: [redacted]
Origin: https://chat.google.com
Authorization: SAPISIDHASH <redacted>
...

clients6.google.com is an alias for googleapis.com. Two headers matter here. X-Goog-Api-Key gives permission to call endpoints in the Internal People API. Authentication as a Google account is done through the Cookie header together with SAPISIDHASH, a value generated from the SAPISID cookie.

API keys are tied to a Google-owned Cloud project, and APIs must be enabled for that project before calls succeed. Reusing the same key against an unrelated API, the Play Atoms Private API, shows this:

HTTP
GET /$discovery/rest
Host: playatoms-pa.googleapis.com
X-Goog-Api-Key: [redacted]
JSON
{
  "error": {
    "code": 403,
    "message": "Play Atoms Private API has not been used in project 576267593750 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/playatoms-pa.googleapis.com/overview?project=576267593750 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    ...
  }
}

The key does, however, work against the staging environment of the Internal People API, which is otherwise not public. All staging and test endpoints live under *.sandbox.googleapis.com, and this key additionally requires the chat.google.com Referer:

Request

HTTP
GET /$discovery/rest
Host: staging-people-pa.sandbox.googleapis.com
Referer: https://chat.google.com
X-Goog-Api-Key: [redacted]

Response

HTTP
HTTP/2 200 OK
Content-Type: application/json; charset=UTF-8

{
  "title": "Internal People API - Staging",
  "documentationLink": "http://boq/java/com/google/social/boq/release/socialgraphapiserver",
  "discoveryVersion": "v1",
  "id": "people_pa:v2",
  "revision": "20241031",
  ...
}

Unlike the public discovery document, the staging version carries comments for everything, which leaks a lot of how the system works behind the scenes. One example is the InAppNotificationTarget description, which spells out how and where notifications can be sent to a person, with a worked example involving a contact's email addresses and phone numbers, obfuscated Gaia IDs, and per-app targets such as YouTube and Who's Down:

JSON
...
    "InAppNotificationTarget": {
      "id": "InAppNotificationTarget",
      "description": "How and where to send notifications to this person in other apps, and why the requester can do so. See go/reachability for more info. \"How\" and \"where\" identify the recipient in a P2P Bridge (glossary/p2p bridge), and \"why\" may be helpful in a UI to disambiguate which of several ways may be used to contact the recipient. How: Via a Google profile or a reachable-only phone number that the requester has access to. Specified in the target \"type\" and \"value\". Where: Apps in which the profile/phone number owner may receive notifications. Specified in the repeated \"app\". Why: Which fields in, e.g., a contact associated with this person make the notification target info visible to the requester. Specified in the repeated originating_field param. Example: Alice has a contact Bob, with: Email 0 = [redacted] Phone 0 = [redacted] Phone 1 = [redacted] Email 0 and Phone 0 let Alice see Bob's public profile (obfuscated gaia ID = 123). Public profiles are visible by email by default, and Bob has explicitly made it visible via Phone 0. Bob says people can send notifications to his public profile in YouTube. Phone 2 is associated with another Google profile that Bob owns, but he doesn't want others to see it. He is okay with people sending notifications to him in Who's Down if they have this phone number, however. There will be separate InAppNotificationTargets: one for Bob's public Google profile, and one for the second phone number, which is in his private profile. IANT #1 - targeting Bob's public profile (visible via Email 0 and Phone 0): app = [YOUTUBE] type = OBFUSCATED_GAIA_ID value = 123 originating_field: [ { field_type = EMAIL, field_index = 0 } // For Email 0 { field_type = PHONE, field_index = 0 } // For Phone 0 ] IANT #2 - targeting Bob's private profile phone number Phone 1: app = [WHOS_DOWN] type = PHONE value = [redacted] originating_field: [ { field_type = PHONE, field_index = 1 } // For Phone 1 ]",
...

Google later removed all comments from the staging discovery document (update dated 2025-02-06).

Secret visibility labels

Some Google Cloud projects have visibility labels enabled, which gives them more access than others. Endpoints hidden behind a visibility label do not appear in the discovery document unless the secret labels parameter is supplied. This was discovered by Ezequiel Pereira, who now works at Google.

Or watch on YouTube
From the original on brutecat.com

Using the API key [redacted], which can be found on console.cloud.google.com, the discovery document for servicemanagement.googleapis.com is fetched first without the label:

HTTP
GET /$discovery/rest HTTP/2
Host: servicemanagement.googleapis.com
Content-Type: application/json
X-Goog-Api-Key: [redacted]
Referer: https://console.cloud.google.com

That response is 214k bytes. Repeating the request with &labels=PANTHEON:

HTTP
GET /$discovery/rest?labels=PANTHEON HTTP/2
Host: servicemanagement.googleapis.com
Content-Type: application/json
X-Goog-Api-Key: [redacted]
Referer: https://console.cloud.google.com

The response grows to 329k bytes and reveals a lot more hidden documentation. Some APIs, such as the Internal People API, also grant extra permissions to specific API clients, which is why understanding Android authorisation opens up the context of many more Cloud projects.

Exploitation

Step 1: understand Android authentication

When you log into a Google account through Google Play Services on Android, every Google app can authenticate as that account without a separate login. The account's Android session is tied to a refresh token generated at first login. Where web internal APIs use cookies, Android and iOS use scoped bearer tokens generated from that refresh token. The same Internal People API request on Android looks like this:

HTTP
POST /$rpc/[redacted].people.v2.minimal.InternalPeopleMinimalService/GetPeople HTTP/2
Host: people-pa.clients6.google.com
Content-Type: application/json+protobuf
Authorization: ya29.<redacted>
...

No API key is needed, because the bearer token itself carries the context of the Google API project used to generate it. Requests made in the context of certain Cloud project IDs get extra functionality or permissions enabled on a given API, usually according to the needs of the client: the Google Chat app, for instance, may be able to fetch more information about other users from the Internal People API than Google Earth can.

Step 2: obtain an Android refresh token

Visit https://accounts.google.com/EmbeddedSetup, complete the authentication flow, and at the end a cookie named oauth_token is set. Exchange it for an Android refresh token:

HTTP
POST /auth HTTP/2
Host: android.googleapis.com
User-Agent: com.google.android.gms/243530022
Content-Type: application/x-www-form-urlencoded

androidId=fb213fefa471dcde&[redacted]&service=ac2dm&get_accountid=1&ACCESS_TOKEN=1&callerPkg=com.google.android.gms&add_account=1&callerSig=[redacted]

The androidId is any random 16-character hex string. It is not currently required to generate a bearer token, but that could change, so it is worth storing alongside the refresh token. Newer Android versions also send a DroidGuard token with this request, likely as an anti-abuse measure, but it cannot be enforced without breaking Play Services support for older devices, so it may change in future.

The response looks like this:

HTTP
HTTP/2 200 OK
Content-Type: text/plain; charset=utf-8

[redacted]
Auth=g.a000<redacted>
SID=BAD_COOKIE
LSID=BAD_COOKIE
services=mail,hist,dynamite,cl,youtube,jotspot,uif,multilogin,analytics
Email=<redacted>@gmail.com
GooglePlusUpdate=0
firstName=<redacted>
lastName=<redacted>
capabilities.canHaveUsername=1
capabilities.canHavePassword=1
...

The resulting Android device is visible at https://myaccount.google.com/device-activity.

Step 3: generate a bearer token in an app's project context

With the refresh token, a bearer token can be generated in the context of an Android app's Cloud project with the scopes you need. This example generates scopes for Google Play Games, to use with playgateway-pa.googleapis.com:

HTTP
POST /auth HTTP/2
Host: android.googleapis.com
User-Agent: GoogleAuth/1.4
Content-Length: 808
Content-Type: application/x-www-form-urlencoded

androidId=fb213fefa471dcde&app=com.google.android.play.games&service=oauth2:https://www.googleapis.com/auth/games.firstparty https://www.googleapis.com/auth/googleplay&client_sig=[redacted]&has_permission=1&[redacted]

The parameters break down as follows:

Parameter Explanation
android_id Not validated; any 16-character hex string
app Package name of the app whose Cloud project context you want
service Space-separated scopes
client_sig SHA1 hash in hex of the app's signature
has_permission Only required on a few Android clients that do not have auto mode enabled
Token Your Android refresh token

For certain scopes it is possible to omit client_sig and app, but then you lose the Cloud project context, and this does not work for most scopes.

Step 4: discover the required scopes from the error

To call https://people-pa.googleapis.com/v2/people, you need to know which scopes it requires. A public discovery document lists them, but many Google APIs require an API key to read their discovery document, and that key is not always available (for example gameswhitelisted.googleapis.com). Sending a request with a bearer token that has insufficient scopes makes the endpoint report every scope it needs:

Request

HTTP
GET /v2/people HTTP/2
Host: people-pa.googleapis.com
Authorization: Bearer ya29.<redacted>

Response

HTTP
HTTP/2 403 Forbidden
Www-Authenticate: Bearer realm="https://accounts.google.com/", error="insufficient_scope", scope="https://www.googleapis.com/auth/peopleapi.legacy.readwrite https://www.googleapis.com/auth/plus.peopleapi.readwrite https://www.googleapis.com/auth/peopleapi.readonly https://www.googleapis.com/auth/peopleapi.readwrite openid https://www.googleapis.com/auth/plus.me"
Content-Type: application/json; charset=UTF-8

{
  "error": {
    "code": 403,
    "message": "Request had insufficient authentication scopes.",
    ...
        "metadata": {
          "service": "people-pa.googleapis.com",
          "method": "[redacted].people.v2.InternalPeopleService.GetPeople"
        }
    ...
  }
}

The method value, [redacted].people.v2.InternalPeopleService.GetPeople, is the gRPC service name of the endpoint. The Go tool gapi-service, published as part of req2proto, automates this lookup:

Bash
$ export ANDROID_REFRESH_TOKEN="<redacted>"
$ git clone https://github.com/ddd/req2proto
$ cd tools/gapi-service
$ go build
$ ./gapi-service -e https://people-pa.googleapis.com/v2/people
scopes: https://www.googleapis.com/auth/peopleapi.legacy.readwrite https://www.googleapis.com/auth/plus.peopleapi.readwrite https://www.googleapis.com/auth/peopleapi.readwrite
method: [redacted].people.v2.InternalPeopleService.InsertPerson
service: people-pa.googleapis.com

Step 5: find a working client signature

To call the endpoint in the context of Google Chat, the package name com.google.android.apps.dynamite comes from the Play Store URL (https://play.google.com/store/apps/details?id=com.google.android.apps.dynamite), but the client_sig is still needed. The signature is not necessarily the SHA1 of the target app's own signature, so the researcher collected the package names and SHA1 client signatures of all Google apps and wrote a Rust program, aas-rs, that brute-forces all signature and package name combinations to find working ones. The output is published as android_clients.json. Searching it for com.google.android.apps.dynamite shows that the client signature [redacted] works for this app:

JSON
"com.google.android.apps.dynamite": [
    {
      "spatula": "[redacted]==",
      "sig": "[redacted]"
    }
  ],

Step 6: use X-Goog-Spatula for project context

Even with authentication in an app's project context, the discovery document cannot be fetched with it directly. X-Goog-Spatula fills that gap. It is a keyless authentication header that, like an API key, provides the context of a specific Cloud project. It is a base64-encoded protobuf, for example:

[redacted]==

Decoding it shows the structure:

PROTO
$ echo -n "[redacted]==" | base64 -d | protoc --decode_raw
1 {
  1: "com.google.android.play.games"
  3: "6Zi8TwQNyiOD+us24/5aYpwxt5A="
}
3: 3959931537119515576

This example comes from a Spatula header found on the internet. The DroidGuard value inside it is not validated, so any client can be impersonated by changing the package name and the SHA1 hash of the app signature. Because the header supplies Cloud project context, it can fetch discovery documents of Android APIs such as gameswhitelisted.googleapis.com:

Request

HTTP
GET /$discovery/rest
Host: gameswhitelisted.googleapis.com
X-Goog-Spatula: [redacted]==

Response

HTTP
HTTP/2 200 OK
Content-Type: application/json; charset=UTF-8

{
  "kind": "discovery#restDescription",
  "description": "Internal-only 1P access to the oneup APIs.",
  ...

The header can also be combined with web Cookie authentication as a direct replacement for X-Goog-Api-Key, giving access to the context of an Android app's Cloud project.

Step 7: leak parameters through error messages

Some APIs seem to offer no way to reach the discovery document at all: no working API key or Spatula, a 404, or something else. YouTube's Internal API is one example:

Request

HTTP
GET /$discovery/rest HTTP/2
Host: youtubei.googleapis.com

Response

HTTP
HTTP/2 405 Method Not Allowed
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
...

The researcher hints that two workaround methods exist for leaking the Innertube discovery document, without spelling them out. Both the production and staging discovery documents were later removed (update dated 2025-03-01).

A normal call to an Innertube endpoint such as /youtubei/v1/browse looks like this:

HTTP
POST /youtubei/v1/browse HTTP/2
Host: youtubei.googleapis.com
Content-Type: application/json
Content-Length: 164

{
  "context": {
    "client": {
      "clientName": "WEB",
      "clientVersion": "2.20241101.01.00",
    }
  },
  "browseId": "UCX6OQ3DkcsbYNE6H8uQQuVA"
}

The payload is JSON and browseId accepts a YouTube channel ID as a string. Changing it to a boolean:

Request

HTTP
POST /youtubei/v1/browse HTTP/2
Host: youtubei.googleapis.com
Content-Type: application/json
Content-Length: 141

{
  "context": {
    "client": {
      "clientName": "WEB",
      "clientVersion": "2.20241101.01.00",
    }
  },
  "browseId":true
}

Response

HTTP
HTTP/2 400 Bad Request
Content-Type: application/json; charset=UTF-8
Server: scaffolding on HTTPServer2

{
  "error": {
    "code": 400,
    "message": "Invalid value at 'browse_id' (TYPE_STRING), true",
    "errors": [
      {
        "message": "Invalid value at 'browse_id' (TYPE_STRING), true",
        "reason": "invalid"
      }
    ],
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "browse_id",
            "description": "Invalid value at 'browse_id' (TYPE_STRING), true"
          }
        ]
      }
    ]
  }
}

The error reveals that browse_id is a TYPE_STRING. That leaks the type of a parameter if you already know its name, but it can go further. Google supports four content types: application/json (JSON), application/json+protobuf (ProtoJson), application/x-protobuf (Proto over HTTP fallback) and application/grpc. All endpoints are defined in .proto files so they can be queried over gRPC, and an Extensible Service Proxy transcodes JSON, ProtoJson and Proto over HTTP into gRPC before the request reaches the microservice.

A JSON payload such as:

JSON
{
  "name": "John Smith",
  "age": 25,
  "favoriteColor": "orange"
}

corresponds to a protobuf message like:

PROTO
message Request {
  string name = 1;
  string age = 2;
  string favourite_color = 3;
}

Protobuf compresses the data by assigning every field an index instead of sending field names on every request. ProtoJson is similar, except the values are sent as an array rather than compressed to binary:

JSON
[
  "John Smith",
  25,
  "orange"
]

Sending an array of indices to the endpoint therefore probes each field by number:

Request

HTTP
POST /youtubei/v1/browse HTTP/2
Host: youtubei.googleapis.com
Content-Type: application/json+protobuf
Content-Length: 22

[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]

Response

HTTP
HTTP/2 400 Bad Request
Content-Type: application/json; charset=UTF-8
Server: scaffolding on HTTPServer2

{
  "error": {
    "code": 400,
    "message": "Invalid value at 'context' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.InnerTubeContext), 1\nInvalid value at 'browse_id' (TYPE_STRING), 2\nInvalid value at 'params' (TYPE_STRING), 3\nInvalid value at 'continuation' (TYPE_STRING), 7\nInvalid value at 'force_ad_format' (TYPE_STRING), 8\nInvalid value at 'player_request' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.PlayerRequest), 10\nInvalid value at 'query' (TYPE_STRING), 11\nInvalid value at 'has_external_ad_vars' (TYPE_BOOL), 12\nInvalid value at 'force_ad_parameters' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.ForceAdParameters), 13\nInvalid value at 'previous_ad_information' (TYPE_STRING), 14\nInvalid value at 'offline' (TYPE_BOOL), 15\nInvalid value at 'unplugged_sort_filter_options' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.UnpluggedSortFilterOptions), 16\nInvalid value at 'offline_mode_forced' (TYPE_BOOL), 17\nInvalid value at 'form_data' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.BrowseFormData), 18\nInvalid value at 'suggest_stats' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.SearchboxStats), 19\nInvalid value at 'lite_client_request_data' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.LiteClientRequestData), 20\nInvalid value at 'unplugged_browse_options' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.UnpluggedBrowseOptions), 22\nInvalid value at 'consistency_token' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.ConsistencyToken), 23\nInvalid value at 'intended_deeplink' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.DeeplinkData), 24\nInvalid value at 'android_extended_permissions' (TYPE_BOOL), 25\nInvalid value at 'browse_notification_params' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.BrowseNotificationsParams), 26\nInvalid value at 'recent_user_event_infos' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.RecentUserEventInfo), 28\nInvalid value at 'detected_activity_info' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.DetectedActivityInfo), 30",
    ...
}

This reveals every non-integer parameter. Sending only booleans instead finds all non-boolean parameters, including integer ones, and the process can be repeated for nested messages to recover the entire possible request payload. The Go tool req2proto automates it:

Bash
$ git clone https://github.com/ddd/req2proto
$ go build
$ ./req2proto -X POST -u https://youtubei.googleapis.com/youtubei/v1/browse -p youtube.api.pfiinnertube.GetBrowseRequest -o output -d 3 -v

The generated output/youtube/api/pfiinnertube/message.proto contains the full request proto for the endpoint:

PROTO
syntax = "proto3";

package youtube.api.pfiinnertube;

message GetBrowseRequest {
  InnerTubeContext context = 1;
  string browse_id = 2;
  string params = 3;
  string continuation = 7;
  string force_ad_format = 8;
  int32 debug_level = 9;
  PlayerRequest player_request = 10;
  string query = 11;
  bool has_external_ad_vars = 12;
  ForceAdParameters force_ad_parameters = 13;
  string previous_ad_information = 14;
  bool offline = 15;
  UnpluggedSortFilterOptions unplugged_sort_filter_options = 16;
  bool offline_mode_forced = 17;
  BrowseFormData form_data = 18;
  SearchboxStats suggest_stats = 19;
  LiteClientRequestData lite_client_request_data = 20;
  UnpluggedBrowseOptions unplugged_browse_options = 22;
  ConsistencyToken consistency_token = 23;
  DeeplinkData intended_deeplink = 24;
  bool android_extended_permissions = 25;
  BrowseNotificationsParams browse_notification_params = 26;
  int32 installed_sharing_service_ids = 27;
  RecentUserEventInfo recent_user_event_infos = 28;
  InlineSettingStatus inline_setting_status = 29;
  DetectedActivityInfo detected_activity_info = 30;
  BrowseRequestContext browse_request_context = 31;
  DeviceContextEvent device_context_info = 32;
  BrowseRequestSupportedMetadata browse_request_supported_metadata = 33;
  string target_id = 35;
  MySubsSettingsState subscription_settings_state = 36;
  MdxContext mdx_context = 37;
  CustomTabContext custom_tab_context = 38;
  ProducerAssetRequestData producer_asset_request_data = 39;
  LatestContainerItemEventsInfo latest_container_item_events_info = 40;
  ScrubContinuationClientData scrub_continuation_client_data = 41;
}
...

Root cause

Several design choices combine to expose the surface. Discovery documents for private APIs are reachable without authentication, and the staging variant carries internal comments. API keys found in web clients are bound to Google-owned Cloud projects, and those projects have particular APIs enabled, including staging environments under *.sandbox.googleapis.com. Visibility labels hide endpoints from the discovery document unless the secret labels parameter is supplied, so the document is not a complete inventory by default. On Android, bearer tokens carry the Cloud project context of the app that generated them, and some APIs grant extra permissions based on that project. X-Goog-Spatula provides the same project context without a key, and its DroidGuard value is not validated, so the client identity can be forged. Finally, the transcoding layer returns detailed field-level errors that name parameters, their types and their message types, which turns malformed requests into a schema oracle.

Impact

An attacker can enumerate private Google APIs, their endpoints, parameters and internal documentation, including hidden endpoints and parameters left over from developer testing, which are the most likely to contain security bugs. Access to staging environments and to the project context of Android apps widens the reachable surface. The parameter leak through error messages recovers the full request schema of endpoints whose discovery document cannot be obtained. The report does not quantify the impact beyond this reconnaissance value.

Fix

Google removed all comments from the staging discovery document (2025-02-06) and removed both the production and staging Innertube discovery documents (2025-03-01). The report does not describe any other remediation.

Variants to test

  1. Fetch /$discovery/rest on other private *-pa.googleapis.com hosts without authentication. A positive result is a JSON document with discoveryVersion and method listings.
  2. Replay API keys captured from web clients against staging-*.sandbox.googleapis.com with the matching Referer. A positive result is a 200 with a staging title and internal comments.
  3. Add ?labels= with candidate label values to discovery requests. A positive result is a larger response containing endpoints absent from the unlabelled document.
  4. Send a bearer token with insufficient scopes to an endpoint and read the Www-Authenticate header. A positive result is a scope= list and a gRPC method name in the error metadata.
  5. Forge X-Goog-Spatula values by changing the package name and signature hash in the decoded protobuf. A positive result is a 200 discovery document for an API that rejects keyless requests.
  6. Send application/json+protobuf arrays of sequential indices to JSON endpoints. A positive result is a 400 listing field names, types and message types by index.

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

What happened, in plain words

Google's websites and apps are built on top of many internal services that talk to each other over the internet. Each of those services exposes a set of addresses, called endpoints, that other software can send requests to. Normally you cannot see that list from the outside: it is a black box. This article is about turning that black box into a white box, meaning making the hidden list of endpoints and their settings visible, so that someone can look for mistakes in them.

The most interesting things to find are not the endpoints the real product uses every day. They are the leftovers: endpoints and settings that a developer added while testing and never removed. Those are rarely watched, and they are the most likely to contain security bugs.

To get there, the researcher used a few ideas in sequence. Google publishes machine-readable descriptions of its APIs, called discovery documents. Some of those documents are readable without logging in. Others are locked, and the way past the lock is to understand how Google decides who is allowed to call what, both in a web browser and on an Android phone. Along the way, the researcher found that some API keys unlock test versions of services, that a secret word can reveal hidden endpoints, that a header used by Android apps can be forged, and that error messages can be tricked into listing the names and types of every setting an endpoint accepts.

Nothing here required breaking encryption or guessing passwords. It required reading what Google's own software sends, and then asking the same questions in slightly different ways.

The starting point: discovery documents

An API (application programming interface) is a way for one piece of software to ask another piece of software to do something. When you open YouTube in your browser, your browser sends requests to YouTube's servers; those requests go to endpoints, which are specific addresses such as /youtubei/v1/browse. An endpoint is like a counter in a large building: the building is the service, and the counter is where you hand over your request.

Google publishes discovery documents for its public APIs. A discovery document is a file, usually in JSON (a text format for structured data), that lists the endpoints of an API, what each one does, and what inputs it accepts. The article compares them to Swagger documents, which is another common format for the same idea: a catalogue of an API written for machines to read.

For example, the YouTube Data API has a discovery document at https://youtube.googleapis.com/$discovery/rest. The path /$discovery/rest is the standard place where Google services put this catalogue.

The important discovery is that these catalogues are not only published for public APIs. They also exist for private, internal APIs, such as the Internal People API at https://people-pa.googleapis.com/$discovery/rest. That document needs no login to view. So a large part of Google's internal surface can be read by anyone who knows the address.

Not every private API is that open. When the researcher tried the same path on the Takeout Private API, the server refused:

HTTP
GET /$discovery/rest
Host: takeout-pa.googleapis.com
HTTP
HTTP/2 403 Forbidden
Content-Type: application/json; charset=UTF-8

{
  : {
    : 403,
    : ,
    :
  }
}

Line by line: the first block is a request. GET is the method, meaning "give me this thing". /$discovery/rest is the path being asked for. Host: takeout-pa.googleapis.com says which server the request is addressed to. The second block is the reply. HTTP/2 403 Forbidden means the server understood the request but refused to serve it. The body is a JSON error object, shown here with its values stripped out.

So the catalogue exists, but this particular service wants proof that the caller is allowed before it hands it over. The rest of the article is about producing that proof.

How Google knows who you are on the web

The researcher opened https://chat.google.com in a browser, opened the browser's developer tools (DevTools, the panel that shows every request a page makes), and looked at a request the page sent to the Internal People API to look up a Google user:

HTTP
POST /$rpc/[redacted].people.v2.minimal.InternalPeopleMinimalService/GetPeople HTTP/2
Host: people-pa.clients6.google.com
Cookie: <redacted>
Content-Type: application/json+protobuf
X-Goog-Api-Key: [redacted]
Origin: https://chat.google.com
Authorization: SAPISIDHASH <redacted>
...

Line by line:

  • POST means "here is some data, please act on it". The long path names the exact operation: a service called InternalPeopleMinimalService, method GetPeople.
  • Host: people-pa.clients6.google.com is the server. The article notes that clients6.google.com is an alias for googleapis.com, so this is the same family of servers as the discovery documents.
  • Cookie: <redacted> carries your browser cookies. A cookie is a small piece of data that a website stores in your browser and that your browser sends back on every request to that site. It is how a website recognises you between page loads. Here the cookie proves which Google account is asking.
  • Content-Type: application/json+protobuf says the body is in a particular JSON dialect used for Google's internal data format (more on that later).
  • X-Goog-Api-Key: [redacted] is an API key. An API key is a long string that identifies which piece of software is calling, a bit like a membership card for an application rather than for a person. It is not a secret password for a user; it is baked into the web page and visible to anyone who looks.
  • Origin: https://chat.google.com tells the server which website the request came from.
  • Authorization: SAPISIDHASH <redacted> is a second proof of identity, generated from a cookie called SAPISID. The article links to an explanation of how that value is computed. The point is that the cookie alone is not enough; the browser also computes a value from it.

So two separate things are being proved: the API key says which application is calling, and the cookie plus SAPISIDHASH says which human account is behind it.

API keys belong to projects

If you have used Google Cloud, you may know that cloud services are organised into projects. A project is a container that holds settings, permissions and enabled services. An API key belongs to one project, and a service must be enabled for that project before calls to it succeed.

The researcher took the same key and pointed it at a completely unrelated service, the Play Atoms Private API:

HTTP
GET /$discovery/rest
Host: playatoms-pa.googleapis.com
X-Goog-Api-Key: [redacted]
JSON
{
  "error": {
    "code": 403,
    "message": "Play Atoms Private API has not been used in project 576267593750 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/playatoms-pa.googleapis.com/overview?project=576267593750 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    ...
  }
}

The request asks for the discovery document of playatoms-pa.googleapis.com and presents the key. The reply is a 403 with a message that explains the refusal: this API has not been used in project 576267593750, or it is disabled there. The message even offers a link to enable it. In plain words: the key is valid, but it belongs to a project that has not switched this particular service on. The key is tied to a Google-owned project, not to the researcher's own.

The same key opens a staging environment

The key did work against something else: the staging environment of the Internal People API. Staging means a test copy of a service, used before changes go live. It is normally not reachable by the public. All staging and test endpoints live under *.sandbox.googleapis.com, and this key additionally requires the chat.google.com Referer header. A Referer header tells the server which page the request came from.

HTTP
GET /$discovery/rest
Host: staging-people-pa.sandbox.googleapis.com
Referer: https://chat.google.com
X-Goog-Api-Key: [redacted]
HTTP
HTTP/2 200 OK
Content-Type: application/json; charset=UTF-8

{
  "title": "Internal People API - Staging",
  "documentationLink": "http://boq/java/com/google/social/boq/release/socialgraphapiserver",
  "discoveryVersion": "v1",
  "id": "people_pa:v2",
  "revision": "20241031",
  ...
}

The request is the same as before, but the host is the staging host and the Referer says the request came from the Chat web page. The reply is a 200 OK, meaning success, and the body is a discovery document with the title Internal People API - Staging, a documentation link, a version and a revision date. The ... means the document continues with the full catalogue.

This staging document is more revealing than the public one: it contains comments for everything. In a discovery document, a comment is a description field attached to a definition, written by developers for other developers. Those descriptions leak how the system works behind the scenes.

One example is the description of InAppNotificationTarget, which explains how and where notifications can be sent to a person, with a worked example involving a contact's email addresses and phone numbers, obfuscated Gaia IDs (Google's internal numeric identifier for an account), and per-app targets such as YouTube and Who's Down:

JSON
...
    "InAppNotificationTarget": {
      "id": "InAppNotificationTarget",
      "description": "How and where to send notifications to this person in other apps, and why the requester can do so. See go/reachability for more info. \"How\" and \"where\" identify the recipient in a P2P Bridge (glossary/p2p bridge), and \"why\" may be helpful in a UI to disambiguate which of several ways may be used to contact the recipient. How: Via a Google profile or a reachable-only phone number that the requester has access to. Specified in the target \"type\" and \"value\". Where: Apps in which the profile/phone number owner may receive notifications. Specified in the repeated \"app\". Why: Which fields in, e.g., a contact associated with this person make the notification target info visible to the requester. Specified in the repeated originating_field param. Example: Alice has a contact Bob, with: Email 0 = [redacted] Phone 0 = [redacted] Phone 1 = [redacted] Email 0 and Phone 0 let Alice see Bob's public profile (obfuscated gaia ID = 123). Public profiles are visible by email by default, and Bob has explicitly made it visible via Phone 0. Bob says people can send notifications to his public profile in YouTube. Phone 2 is associated with another Google profile that Bob owns, but he doesn't want others to see it. He is okay with people sending notifications to him in Who's Down if they have this phone number, however. There will be separate InAppNotificationTargets: one for Bob's public Google profile, and one for the second phone number, which is in his private profile. IANT #1 - targeting Bob's public profile (visible via Email 0 and Phone 0): app = [YOUTUBE] type = OBFUSCATED_GAIA_ID value = 123 originating_field: [ { field_type = EMAIL, field_index = 0 } // For Email 0 { field_type = PHONE, field_index = 0 } // For Phone 0 ] IANT #2 - targeting Bob's private profile phone number Phone 1: app = [WHOS_DOWN] type = PHONE value = [redacted] originating_field: [ { field_type = PHONE, field_index = 1 } // For Phone 1 ]",
...

This is a JSON object with an id and a description. The description is a long string, and the backslashes are escapes that let quotation marks sit inside a string. Reading it in plain words: it defines a concept called an in-app notification target, which records how and where a person can be notified in other apps, and why the person asking is allowed to do so. It then walks through an example with two fictional people, Alice and Bob, showing which of Bob's contact details make which of his profiles visible, and how separate targets are created for his public profile and for a phone number in his private profile. This is exactly the kind of internal reasoning that a public document would not include.

Google later removed all comments from the staging discovery document, in an update dated 2025-02-06.

Secret visibility labels

Some Google Cloud projects have visibility labels enabled. A visibility label is a tag that marks a set of endpoints as visible only to callers who present that label. Endpoints hidden behind a label do not appear in the discovery document unless the secret labels parameter is supplied. In other words, the catalogue you get by default is not the complete inventory: it is the inventory for callers without the label.

This was discovered by Ezequiel Pereira, who now works at Google.

Or watch on YouTube
From the original on brutecat.com

The researcher used the API key [redacted], which can be found on console.cloud.google.com, and first fetched the discovery document for servicemanagement.googleapis.com without the label:

HTTP
GET /$discovery/rest HTTP/2
Host: servicemanagement.googleapis.com
Content-Type: application/json
X-Goog-Api-Key: [redacted]
Referer: https://console.cloud.google.com

Line by line: ask for the catalogue at the standard path on the service management host, declare that the reply is expected as JSON, present the API key found in the Cloud console, and say the request came from the Cloud console page. That response is 214k bytes, about the size of a short book in plain text.

Then the same request with &labels=PANTHEON added to the path:

HTTP
GET /$discovery/rest?labels=PANTHEON HTTP/2
Host: servicemanagement.googleapis.com
Content-Type: application/json
X-Goog-Api-Key: [redacted]
Referer: https://console.cloud.google.com

The only difference is the query string ?labels=PANTHEON. A query string is the part of a URL after the question mark, carrying extra settings for the request. The response grows to 329k bytes and reveals a lot more hidden documentation. The label acted like a back-room pass: same door, same key, but now the staff show you the rooms they keep for labelled visitors.

Some APIs, such as the Internal People API, also grant extra permissions to specific API clients. A client here means a particular application, identified by its key or token. That is why understanding how authorisation works on Android opens up the context of many more Cloud projects: each Android app carries its own project context, and some projects are treated more generously than others.

How Google knows who you are on Android

If you have logged into a Google account through Google Play Services on an Android phone, you may have noticed that every Google app can use that account without asking you to log in again. The account's Android session is tied to a refresh token, a long-lived credential generated the first time you log in. A token is a string that stands in for your identity, like a cloakroom ticket: you show the ticket, not your coat.

On the web, Google's internal APIs use cookies. On Android and iOS, they use scoped bearer tokens generated from the refresh token. A bearer token is a token that grants access to whoever bears it, like a concert wristband: no name check, the band is the proof. Scoped means it is limited to certain permissions, called scopes. A scope is a named permission, such as "read your contacts" or "read your profile".

The same Internal People API request on Android looks like this:

HTTP
POST /$rpc/[redacted].people.v2.minimal.InternalPeopleMinimalService/GetPeople HTTP/2
Host: people-pa.clients6.google.com
Content-Type: application/json+protobuf
Authorization: ya29.<redacted>
...

Same operation and same host as the web request, but no cookie and no API key. Instead, Authorization: ya29.<redacted> carries a bearer token. Authorization: ya29.<redacted> carries a bearer token. There is no need for an API key because the bearer token itself carries the context of the Google API project that was used to generate it. The project travels inside the token.

This matters because requests made in the context of certain Cloud project IDs get extra functionality or permissions enabled on a given API. The article explains that this usually follows the needs of the client: the Google Chat app, for instance, may be able to fetch more information about other users from the Internal People API than Google Earth can. Same API, different app, different level of trust.

Step 1: get an Android refresh token

The researcher visited https://accounts.google.com/EmbeddedSetup, completed the authentication flow, and at the end a cookie named oauth_token was set. Completing the flow sets a cookie named oauth_token.

That cookie was then exchanged for an Android refresh token:

HTTP
POST /auth HTTP/2
Host: android.googleapis.com
User-Agent: com.google.android.gms/243530022
Content-Type: application/x-www-form-urlencoded

androidId=fb213fefa471dcde&[redacted]&service=ac2dm&get_accountid=1&ACCESS_TOKEN=1&callerPkg=com.google.android.gms&add_account=1&callerSig=[redacted]

Line by line:

  • POST /auth on android.googleapis.com is the endpoint that trades one credential for another.
  • User-Agent: com.google.android.gms/243530022 tells the server which app is calling. com.google.android.gms is the package name of Google Play Services, and the number after the slash is its version.
  • Content-Type: application/x-www-form-urlencoded says the body is a list of name=value pairs joined by &, the same format a web form uses.
  • androidId=fb213fefa471dcde is a made-up device identifier. The article says it is any random 16-character hex string. It is not currently required to generate a bearer token, but that could change, so it is worth storing alongside the refresh token.
  • `[redacted] is the cookie obtained from the setup flow.
  • service=ac2dm names the service being requested.
  • get_accountid=1, ACCESS_TOKEN=1 and add_account=1 are additional parameters in the body.
  • callerPkg=com.google.android.gms says which package is making the call.
  • callerSig=[redacted] is another parameter in the body.

The article adds that newer Android versions also send a DroidGuard token with this request. DroidGuard is Google's system for checking whether a device is genuine. The researcher guesses it is an anti-abuse measure, but notes it cannot be enforced without breaking Play Services support for older Android devices, so it may change in future.

The reply looks like this:

HTTP
HTTP/2 200 OK
Content-Type: text/plain; charset=utf-8

[redacted]
Auth=g.a000<redacted>
SID=BAD_COOKIE
LSID=BAD_COOKIE
services=mail,hist,dynamite,cl,youtube,jotspot,uif,multilogin,analytics
Email=<redacted>@gmail.com
GooglePlusUpdate=0
firstName=<redacted>
lastName=<redacted>
capabilities.canHaveUsername=1
capabilities.canHavePassword=1
...

This is plain text, one name=value pair per line. [redacted] is the Android refresh token, recognisable by the aas_et/prefix.Auth=g.a000<redacted>is another value in the response.SIDandLSIDare set toBAD_COOKIE, which is a placeholder rather than a real session. services=lists a set of service names. The response also includesEmail, firstName, lastNameandcapabilitieslines. The...` means more lines follow.

The resulting Android device is visible at https://myaccount.google.com/device-activity, the page where Google lists the devices signed in to your account. In other words, this flow really does register a device on the account.

Step 2: turn the refresh token into a bearer token

With the refresh token, a bearer token can be generated in the context of an Android app's Cloud project, with the scopes you need. This example generates scopes for Google Play Games, to use with playgateway-pa.googleapis.com:

HTTP
POST /auth HTTP/2
Host: android.googleapis.com
User-Agent: GoogleAuth/1.4
Content-Length: 808
Content-Type: application/x-www-form-urlencoded

androidId=fb213fefa471dcde&app=com.google.android.play.games&service=oauth2:https://www.googleapis.com/auth/games.firstparty https://www.googleapis.com/auth/googleplay&client_sig=[redacted]&has_permission=1&[redacted]

Same endpoint as before, but the body now asks for something different. The parameters break down as follows:

Parameter Explanation
android_id Not validated; any 16-character hex string
app Package name of the app whose Cloud project context you want
service Space-separated scopes
client_sig SHA1 hash in hex of the app's signature
has_permission Only required on a few Android clients that do not have auto mode enabled
Token Your Android refresh token

In the request, app=com.google.android.play.games is the Play Games package, service=oauth2: is followed by two scopes separated by a space, client_sig is the signature hash, has_permission=1 is the flag, and Token is the refresh token from the previous step. The Content-Length: 808 is simply the size of the body in bytes.

For certain scopes it is possible to omit client_sig and app, but then you lose the Cloud project context, and this does not work for most scopes. The project context is the whole point: it is what makes the token carry the trust level of a particular app.

Step 3: ask the endpoint which scopes it needs

To call https://people-pa.googleapis.com/v2/people, you need to know which scopes it requires. A public discovery document lists them, but many Google APIs require an API key to read their discovery document, and that key is not always available. The article gives gameswhitelisted.googleapis.com as an example of such an API.

There is a shortcut. Send a request with a bearer token that has insufficient scopes, and the endpoint reports every scope it needs:

HTTP
GET /v2/people HTTP/2
Host: people-pa.googleapis.com
Authorization: Bearer ya29.<redacted>
HTTP
HTTP/2 403 Forbidden
Www-Authenticate: Bearer realm="https://accounts.google.com/", error="insufficient_scope", scope="https://www.googleapis.com/auth/peopleapi.legacy.readwrite https://www.googleapis.com/auth/plus.peopleapi.readwrite https://www.googleapis.com/auth/peopleapi.readonly https://www.googleapis.com/auth/peopleapi.readwrite openid https://www.googleapis.com/auth/plus.me"
Content-Type: application/json; charset=UTF-8

{
  "error": {
    "code": 403,
    "message": "Request had insufficient authentication scopes.",
    ...
        "metadata": {
          "service": "people-pa.googleapis.com",
          "method": "[redacted].people.v2.InternalPeopleService.GetPeople"
        }
    ...
  }
}

The request asks for /v2/people and presents a bearer token. The reply is a 403, a refusal, but a helpful one. The Www-Authenticate header is the standard place where a server explains how to authenticate. Here it says error="insufficient_scope", meaning the token is valid but lacks permissions, and then scope="..." lists the exact permissions required, separated by spaces. The JSON body repeats the message and adds metadata naming the service and the method.

The method value, [redacted].people.v2.InternalPeopleService.GetPeople, is the gRPC service name of the endpoint. gRPC is a framework for calling remote services, and every method in it has a name like this. Knowing the name is useful because it identifies the operation precisely.

The Go tool gapi-service, published as part of req2proto, automates this lookup:

Bash
$ export ANDROID_REFRESH_TOKEN="<redacted>"
$ git clone https://github.com/ddd/req2proto
$ cd tools/gapi-service
$ go build
$ ./gapi-service -e https://people-pa.googleapis.com/v2/people
scopes: https://www.googleapis.com/auth/peopleapi.legacy.readwrite https://www.googleapis.com/auth/plus.peopleapi.readwrite https://www.googleapis.com/auth/peopleapi.readwrite
method: [redacted].people.v2.InternalPeopleService.InsertPerson
service: people-pa.googleapis.com

Line by line: export stores the refresh token in an environment variable, a named value the shell keeps for programs to read. git clone downloads the tool's source code from GitHub. cd changes into the tool's folder. go build compiles the Go program into an executable. The last line runs it with -e followed by the endpoint URL. The output lists the scopes, the method name and the service. Note that the method shown here is InsertPerson, not GetPeople; the tool reports what it finds for the endpoint it was given.

Step 4: find a working client signature

To call the endpoint in the context of Google Chat, you need the app's package name and its client signature. The package name com.google.android.apps.dynamite comes from the Play Store URL (https://play.google.com/store/apps/details?id=com.google.android.apps.dynamite). A package name is the unique identifier of an Android app, like a surname.

The client_sig is still needed. The article warns that the signature is not necessarily the SHA1 of the target app's own signature. SHA1 is a hashing algorithm: it turns any input into a short fixed-length fingerprint, and the same input always gives the same fingerprint. So the researcher collected the package names and SHA1 client signatures of all Google apps and wrote a Rust program, aas-rs, that brute-forces all signature and package name combinations to find working ones. Brute-forcing means trying every combination systematically until one works, like trying every key on a keyring.

The output is published as android_clients.json. Searching it for com.google.android.apps.dynamite shows that the client signature [redacted] works for this app:

JSON
"com.google.android.apps.dynamite": [
    {
      "spatula": "[redacted]==",
      "sig": "[redacted]"
    }
  ],

This is a JSON object keyed by package name. The value is a list of entries, each with a spatula value and a sig value. The sig is the client signature to use. The spatula is a header value, explained in the next section.

Step 5: X-Goog-Spatula, a keyless pass

Even with authentication in an app's project context, the discovery document cannot be fetched with it directly. X-Goog-Spatula fills that gap. If you have ever looked at Android traffic to Google APIs, you may have noticed this header. It is a keyless authentication header: like an API key, it provides the context of a specific Cloud project, but it is not a key.

Spatula values are base64-encoded protobuf. Base64 is a way of writing binary data using only text characters, so it can travel in a header. Protobuf is Google's compact binary format for structured data, which the article explains in more detail later. An example value:

[redacted]==

Decoding it shows the structure:

PROTO
$ echo -n "[redacted]==" | base64 -d | protoc --decode_raw
1 {
  1: "com.google.android.play.games"
  3: "6Zi8TwQNyiOD+us24/5aYpwxt5A="
}
3: 3959931537119515576

Line by line: echo -n prints the string without a trailing newline. The | pipe sends that output into the next command. base64 -d decodes the base64 back into binary. protoc --decode_raw is the protobuf compiler's tool for reading binary data without knowing its schema, and it prints the fields it finds. The result shows a top-level field numbered 1, containing a nested message with field 1 set to the Play Games package name and field 3 set to a base64 value, plus a top-level field 3 holding a large number. The base64 value in field 3 is the DroidGuard value.

This example comes from a Spatula header found on the internet. The DroidGuard value inside it is not validated, so any client can be impersonated by changing the package name and the SHA1 hash of the app signature. In plain words: the header claims "I am this app", and nobody checks the claim.

Because the header supplies Cloud project context, it can fetch discovery documents of Android APIs such as gameswhitelisted.googleapis.com:

HTTP
GET /$discovery/rest
Host: gameswhitelisted.googleapis.com
X-Goog-Spatula: [redacted]==
HTTP
HTTP/2 200 OK
Content-Type: application/json; charset=UTF-8

{
  "kind": "discovery#restDescription",
  "description": "Internal-only 1P access to the oneup APIs.",
  ...

The request asks for the catalogue and presents the Spatula header instead of an API key. The reply is a 200 with a discovery document whose description says it is for internal-only first-party access. The header can also be combined with web Cookie authentication as a direct replacement for X-Goog-Api-Key, giving access to the context of an Android app's Cloud project.

Step 6: leak parameters through error messages

Some APIs seem to offer no way to reach the discovery document at all: no working API key or Spatula, a 404, or something else. YouTube's Internal API is one example:

HTTP
GET /$discovery/rest HTTP/2
Host: youtubei.googleapis.com
HTTP
HTTP/2 405 Method Not Allowed
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
...

The request asks for the catalogue, and the reply is a 405, meaning the server does not allow this method at this address. The body is HTML rather than JSON, so there is no catalogue here. The researcher notes two workaround methods for leaking the Innertube discovery document, without spelling them out. Both the production and staging discovery documents were later removed, in an update dated 2025-03-01.

So the researcher turned to a different trick. A normal call to an Innertube endpoint such as /youtubei/v1/browse looks like this:

HTTP
POST /youtubei/v1/browse HTTP/2
Host: youtubei.googleapis.com
Content-Type: application/json
Content-Length: 164

{
  "context": {
    "client": {
      "clientName": "WEB",
      "clientVersion": "2.20241101.01.00",
    }
  },
  "browseId": "UCX6OQ3DkcsbYNE6H8uQQuVA"
}

The body is JSON. context describes the client: clientName is WEB, meaning the web client, and clientVersion is a version string. browseId is the YouTube channel ID as a string. This is what the real page sends when it loads a channel.

What happens if browseId is changed to a boolean, true?

HTTP
POST /youtubei/v1/browse HTTP/2
Host: youtubei.googleapis.com
Content-Type: application/json
Content-Length: 141

{
  "context": {
    "client": {
      "clientName": "WEB",
      "clientVersion": "2.20241101.01.00",
    }
  },
  "browseId":true
}
HTTP
HTTP/2 400 Bad Request
Content-Type: application/json; charset=UTF-8
Server: scaffolding on HTTPServer2

{
  "error": {
    "code": 400,
    "message": "Invalid value at 'browse_id' (TYPE_STRING), true",
    "errors": [
      {
        "message": "Invalid value at 'browse_id' (TYPE_STRING), true",
        "reason": "invalid"
      }
    ],
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "browse_id",
            "description": "Invalid value at 'browse_id' (TYPE_STRING), true"
          }
        ]
      }
    ]
  }
}

The reply is a 400, meaning the request was malformed. The message says Invalid value at 'browse_id' (TYPE_STRING), true: the field is called browse_id and it expects a string, but it received true. The details section repeats this in a structured form, with a fieldViolations list naming the field and describing the problem. So the error leaks the type of a parameter, if you already know its name. How can this go further?

Four ways to send the same request

Google supports four content types for requests:

  • application/json (JSON)
  • application/json+protobuf (ProtoJson)
  • application/x-protobuf (Proto over HTTP fallback)
  • application/grpc

All endpoints are defined in .proto files so they can be queried over gRPC. A .proto file is a schema: it declares the messages an endpoint accepts and the fields inside them. To allow JSON, ProtoJson and Proto over HTTP, an Extensible Service Proxy (ESP) transcodes these requests into gRPC before they reach the actual microservice. Transcoding means translating from one format to another. The proxy is a translator standing at the door.

For instance, a JSON payload such as:

JSON
{
  "name": "John Smith",
  "age": 25,
  "favoriteColor": "orange"
}

corresponds to a protobuf message like:

PROTO
message Request {
  string name = 1;
  string age = 2;
  string favourite_color = 3;
}

This declares a message called Request with three fields. Each field has a type (string) and a number (1, 2, 3). The numbers are the field indices. Protobuf compresses data by sending only the index and the value, not the field name, because the server already knows the schema. Sending "name", "age" and "favoriteColor" on every request would waste bandwidth.

ProtoJson is similar, except the values are sent as an array rather than compressed to binary:

JSON
[
  "John Smith",
  25,
  "orange"
]

Here the position in the array is the field index: the first value is field 1, the second is field 2, and so on. So if you send an array of numbers to an endpoint that accepts ProtoJson, each number is interpreted as the value of the field with that index. If the type does not match, the server complains, and the complaint names the field.

That is the trick. Send an array of sequential indices:

HTTP
POST /youtubei/v1/browse HTTP/2
Host: youtubei.googleapis.com
Content-Type: application/json+protobuf
Content-Length: 22

[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
HTTP
HTTP/2 400 Bad Request
Content-Type: application/json; charset=UTF-8
Server: scaffolding on HTTPServer2

{
  "error": {
    "code": 400,
    "message": "Invalid value at 'context' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.InnerTubeContext), 1\nInvalid value at 'browse_id' (TYPE_STRING), 2\nInvalid value at 'params' (TYPE_STRING), 3\nInvalid value at 'continuation' (TYPE_STRING), 7\nInvalid value at 'force_ad_format' (TYPE_STRING), 8\nInvalid value at 'player_request' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.PlayerRequest), 10\nInvalid value at 'query' (TYPE_STRING), 11\nInvalid value at 'has_external_ad_vars' (TYPE_BOOL), 12\nInvalid value at 'force_ad_parameters' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.ForceAdParameters), 13\nInvalid value at 'previous_ad_information' (TYPE_STRING), 14\nInvalid value at 'offline' (TYPE_BOOL), 15\nInvalid value at 'unplugged_sort_filter_options' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.UnpluggedSortFilterOptions), 16\nInvalid value at 'offline_mode_forced' (TYPE_BOOL), 17\nInvalid value at 'form_data' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.BrowseFormData), 18\nInvalid value at 'suggest_stats' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.SearchboxStats), 19\nInvalid value at 'lite_client_request_data' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.LiteClientRequestData), 20\nInvalid value at 'unplugged_browse_options' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.UnpluggedBrowseOptions), 22\nInvalid value at 'consistency_token' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.ConsistencyToken), 23\nInvalid value at 'intended_deeplink' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.DeeplinkData), 24\nInvalid value at 'android_extended_permissions' (TYPE_BOOL), 25\nInvalid value at 'browse_notification_params' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.BrowseNotificationsParams), 26\nInvalid value at 'recent_user_event_infos' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.RecentUserEventInfo), 28\nInvalid value at 'detected_activity_info' (type.googleapis.com/youtube.api.pfiinnertube.YoutubeApiInnertube.DetectedActivityInfo), 30",
    ...
}

The request declares application/json+protobuf and sends an array of numbers from 1 to 30. The reply is a 400 whose message lists, for each index, the field name and its type. Index 1 is context, a message type. Index 2 is browse_id, a string. Index 3 is params, a string. Index 7 is continuation, and so on. The \n sequences are newlines inside the JSON string, so the message is really one line per field. Some indices, such as 4, 5, 6, 9, 21, 27 and 29, are not listed in the error.

This reveals every non-integer parameter. Sending only booleans instead finds all non-boolean parameters, including integer ones, because a boolean will fail against a string, a message or an integer alike. The process can be repeated for nested messages to recover the entire possible request payload. The Go tool req2proto automates it:

Bash
$ git clone https://github.com/ddd/req2proto
$ go build
$ ./req2proto -X POST -u https://youtubei.googleapis.com/youtubei/v1/browse -p youtube.api.pfiinnertube.GetBrowseRequest -o output -d 3 -v

Line by line: clone the repository, build it, then run it. -X POST sets the HTTP method. -u is the endpoint URL. The command runs the tool with the method, URL, message name, output folder, depth and verbose flags.

The generated output/youtube/api/pfiinnertube/message.proto contains the full request proto for the endpoint:

PROTO
syntax = "proto3";

package youtube.api.pfiinnertube;

message GetBrowseRequest {
  InnerTubeContext context = 1;
  string browse_id = 2;
  string params = 3;
  string continuation = 7;
  string force_ad_format = 8;
  int32 debug_level = 9;
  PlayerRequest player_request = 10;
  string query = 11;
  bool has_external_ad_vars = 12;
  ForceAdParameters force_ad_parameters = 13;
  string previous_ad_information = 14;
  bool offline = 15;
  UnpluggedSortFilterOptions unplugged_sort_filter_options = 16;
  bool offline_mode_forced = 17;
  BrowseFormData form_data = 18;
  SearchboxStats suggest_stats = 19;
  LiteClientRequestData lite_client_request_data = 20;
  UnpluggedBrowseOptions unplugged_browse_options = 22;
  ConsistencyToken consistency_token = 23;
  DeeplinkData intended_deeplink = 24;
  bool android_extended_permissions = 25;
  BrowseNotificationsParams browse_notification_params = 26;
  int32 installed_sharing_service_ids = 27;
  RecentUserEventInfo recent_user_event_infos = 28;
  InlineSettingStatus inline_setting_status = 29;
  DetectedActivityInfo detected_activity_info = 30;
  BrowseRequestContext browse_request_context = 31;
  DeviceContextEvent device_context_info = 32;
  BrowseRequestSupportedMetadata browse_request_supported_metadata = 33;
  string target_id = 35;
  MySubsSettingsState subscription_settings_state = 36;
  MdxContext mdx_context = 37;
  CustomTabContext custom_tab_context = 38;
  ProducerAssetRequestData producer_asset_request_data = 39;
  LatestContainerItemEventsInfo latest_container_item_events_info = 40;
  ScrubContinuationClientData scrub_continuation_client_data = 41;
}
...

This is the schema of the request, reconstructed from error messages alone. syntax = "proto3" declares the version of the protobuf language. package gives the namespace. message GetBrowseRequest lists every field with its type and index, including fields such as debug_level, offline and installed_sharing_service_ids.

Why this works

Several design choices combine to expose the surface:

  1. Discovery documents for private APIs are reachable without authentication, and the staging variant carries internal comments.
  2. API keys found in web clients are bound to Google-owned Cloud projects, and those projects have particular APIs enabled, including staging environments under *.sandbox.googleapis.com.
  3. Visibility labels hide endpoints from the discovery document unless the secret labels parameter is supplied, so the document is not a complete inventory by default.
  4. On Android, bearer tokens carry the Cloud project context of the app that generated them, and some APIs grant extra permissions based on that project.
  5. X-Goog-Spatula provides the same project context without a key, and its DroidGuard value is not validated, so the client identity can be forged.
  6. The transcoding layer returns detailed field-level errors that name parameters, their types and their message types, which turns malformed requests into a schema oracle.

What it means

An attacker can enumerate private Google APIs, their endpoints, parameters and internal documentation, including hidden endpoints and parameters left over from developer testing, which are the most likely to contain security bugs. Access to staging environments and to the project context of Android apps widens the reachable surface. The parameter leak through error messages recovers the full request schema of endpoints whose discovery document cannot be obtained. The report does not quantify the impact beyond this reconnaissance value.

What Google changed

Google removed all comments from the staging discovery document, in an update dated 2025-02-06, and removed both the production and staging Innertube discovery documents, in an update dated 2025-03-01. The report does not describe any other remediation.

Things to try yourself

  1. Fetch /$discovery/rest on other private *-pa.googleapis.com hosts without authentication. A positive result is a JSON document with discoveryVersion and method listings.
  2. Replay API keys captured from web clients against staging-*.sandbox.googleapis.com with the matching Referer. A positive result is a 200 with a staging title and internal comments.
  3. Add ?labels= with candidate label values to discovery requests. A positive result is a larger response containing endpoints absent from the unlabelled document.
  4. Send a bearer token with insufficient scopes to an endpoint and read the Www-Authenticate header. A positive result is a scope= list and a gRPC method name in the error metadata.
  5. Forge X-Goog-Spatula values by changing the package name and signature hash in the decoded protobuf. A positive result is a 200 discovery document for an API that rejects keyless requests.
  6. Send application/json+protobuf arrays of sequential indices to JSON endpoints. A positive result is a 400 listing field names, types and message types by index.

Glossary

  • API: a defined way for one piece of software to ask another to do something.
  • API key: a long string that identifies which application is calling a service; it is not a user password and is often visible in web pages.
  • Base64: a way of writing binary data using only text characters so it can travel in headers or URLs.
  • Bearer token: a token that grants access to whoever holds it, with no further identity check.
  • Brute-force: trying every possible combination systematically until one works.
  • Client: a particular application making requests, as opposed to the server answering them.
  • Client signature: a hash that identifies an app's build, used by Google to recognise the calling app.
  • Cloud project: a container in Google Cloud that holds settings, permissions and enabled services.
  • Cookie: a small piece of data stored by a website in your browser and sent back on every request to that site, used to recognise you.
  • Discovery document: a machine-readable catalogue of an API's endpoints, parameters and descriptions, usually served at /$discovery/rest.
  • DroidGuard: Google's system for checking whether an Android device is genuine.
  • Endpoint: a specific address on a service that accepts requests, such as /youtubei/v1/browse.
  • Extensible Service Proxy (ESP): a component that translates JSON, ProtoJson and Proto over HTTP requests into gRPC before they reach a service.
  • gRPC: a framework for calling remote services, where every method has a structured name.
  • Hash / SHA1: a function that turns any input into a short fixed-length fingerprint; the same input always gives the same fingerprint.
  • Header: an extra piece of information attached to an HTTP request or response, such as Host or Authorization.
  • JSON: a text format for structured data, built from objects, arrays, strings, numbers and booleans.
  • Method (HTTP): the verb of a request, such as GET (fetch) or POST (send data).
  • Microservice: a small, separately deployed service that handles one part of a larger system.
  • Obfuscated Gaia ID: Google's internal numeric identifier for an account, in a form that hides the real value.
  • Package name: the unique identifier of an Android app, such as com.google.android.apps.dynamite.
  • ProtoJson: a JSON dialect where values are sent as an array, with position standing in for the field index.
  • Protobuf: Google's compact binary format for structured data, where each field has a number instead of a name.
  • Query string: the part of a URL after the question mark, carrying extra settings for the request.
  • Referer: a header telling the server which page the request came from.
  • Refresh token: a long-lived credential used to obtain new access tokens without logging in again.
  • Scope: a named permission, such as reading a profile, that a token can be limited to.
  • Staging: a test copy of a service, used before changes go live.
  • Token: a string that stands in for an identity or permission.
  • Transcoding: translating a request from one format to another.
  • Visibility label: a tag that marks a set of endpoints as visible only to callers who present that label.
  • White box / black box: a system whose internals are visible, versus one whose internals are hidden.
  • X-Goog-Spatula: a keyless authentication header that supplies the Cloud project context of an Android app.

More by brutecat

View all

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

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.