#43555·grpc

UrlExternalAccountCredentials drops the credential_source URL's query string

Author: crawlinsCreated Sep 29, 2026Updated Sep 29, 2026
Labelsunassigned

What version of gRPC and what language are you using?

gRPC C-core 1.71.0, used from C++ (via google-cloud-cpp's Certificate Authority Service client) in Kythira, a Raft implementation whose CI exercises real cloud providers. The same code is present unchanged in v1.78.1.

What operating system (Linux, Windows,...) and version?

Linux, Ubuntu 24.04 (GitHub Actions ubuntu-24.04 runners).

What runtime / compiler are you using (e.g. python version or version of gcc)

g++-13 and g++-14, C++23.

What did you do?

Used a url-sourced external_account credential whose credential_source.url carries a query string. This is exactly what google-github-actions/auth writes for GitHub Actions Workload Identity Federation:

json
{
  "type": "external_account",
  "audience": "//iam.googleapis.com/projects/…/providers/…",
  "subject_token_type": "urn:ietf:params:oauth:token-type:jwt",
  "credential_source": {
    "url": "https://…/actions/oidc/token?api-version=2.0&audience=https%3A%2F%2Fiam.googleapis.com%2F…",
    "headers": { "Authorization": "Bearer <ACTIONS_ID_TOKEN_REQUEST_TOKEN>" },
    "format": { "type": "json", "subject_token_field_name": "value" }
  }
}

Then made any RPC that needs the credential to fetch a subject token.

What did you expect to see?

The GET to issue with the query string intact, so the server receives api-version and audience as query parameters — as it does when the identical URL and headers are replayed with curl, which returns HTTP 200 and a token.

What did you see instead?

HTTP 403 from the server, surfaced as:

external_account_credentials.cc:394] Fetch external account credentials access
token: UNAVAILABLE: Call to HTTP server ended with status 403
[{"source":"actions-run-service",
  "errorMessage":"runner does not have permissions to generate id token"}]

The request arrives with no query parameters at all, because the query string is percent-encoded into the path.

Root cause

In src/core/credentials/call/external/url_external_account_credentials.cc (1.71.0: src/core/lib/security/credentials/external/…):

Line 86 splits the URL on / and keeps everything after the host — including the query string — as a "path":

cpp
std::vector<absl::string_view> v =
    absl::StrSplit(it->second.string(), absl::MaxSplits('/', 3));
url_full_path_ = absl::StrCat("/", v[3]);   // "/…?api-version=2.0&audience=…"

Line 149 then passes that whole string to URI::Create as the path, with query parameters explicitly empty:

cpp
auto url_for_request =
    URI::Create(url_.scheme(), url_.user_info(), url_.host_port(),
                url_full_path_, {} /* query params */, "" /* fragment */);

The request target is built from that URI — src/core/util/http_client/httpcli.cc uses uri.EncodedPathAndQueryParams(), not request.path — so ?, & and % inside the "path" are percent-encoded and the server sees one opaque path segment.

Suggested fix

url_ is already URI::Parse of the same string, so its path and query parameters are available and correctly split:

diff
-  auto url_for_request =
-      URI::Create(url_.scheme(), url_.authority(), url_full_path_,
-                  {} /* query params */, "" /* fragment */);
+  auto url_for_request =
+      URI::Create(url_.scheme(), url_.authority(), url_.path(),
+                  url_.query_parameter_pairs(), "" /* fragment */);

(1.71.0 signature shown; adjust for the user_info/host_port form on master.)

request.path should keep url_full_path_ — that is the raw path-and-query, and is correct for the occasions the HTTP layer consults it.

Anything else we should know about your project / environment?

Why this is easy to misdiagnose, in case it helps triage:

  • It is 403, not 401. The Authorization header is sent and is valid. A control request with no Authorization header against the same endpoint returns 401 {"errorMessage":"No token found in request"}. So the error text points at permissions and the credential looks guilty.
  • Only gRPC-backed clients are affected. Callers that reach the same endpoint through libcurl — google-cloud-cpp's REST path — succeed with the same credential file, the same token, in the same process. In Kythira's CI the GCS and Compute Engine bundles passed in the same job while the gRPC-backed Certificate Authority Service client failed, which made it look service-specific for months.
  • A minimal discriminator, if you want to confirm without a GCP project: point credential_source.url at any endpoint that echoes its query string, and compare what gRPC sends against curl with the same URL and headers.

Any url-sourced external account credential whose URL carries a query string is affected, which includes every GitHub Actions Workload Identity Federation setup produced by google-github-actions/auth.

Kythira is carrying this as a vcpkg overlay patch against 1.71.0 (crawlins/kythira#363) with the diagnostic that found it — a probe that replays the credential file's own URL and headers with curl, which is what separated "the configuration is wrong" from "the caller transmits it wrongly" after five other hypotheses had been eliminated. A PR against master follows.