In this long‑form article, we’ll decode that cryptic keyword, explain every component, show you how to fetch the URL using various tools, and walk through practical examples of using service account metadata to call Google APIs securely – without ever storing a JSON key file.
If you perform a GET request to this endpoint, you receive a list of service account associated with the current instance. For example, an instance with a default service account and an additional custom account might return:
Make it long, detailed, informative. Use the exact keyword naturally in the article, e.g., "when you need to fetch-url-http-3A-2F-2Fmetadata.google.internal-2FcomputeMetadata-2Fv1-2Finstance-2Fservice accounts-2F" but properly formatted. We'll write it as a string literal.
However, the string you provided ( fetch-url-http-3A-2F-2Fmetadata... ) appears to be URL-encoded. Here’s what’s happening:
In Google Compute Engine, instances can be configured to have service accounts associated with them. These service accounts provide a way to authenticate and authorize access to Google Cloud resources. The metadata server provides a way for instances to fetch information about their environment and configuration, including details about the service accounts.
Zero wasn't looking for a brute-force entry; they were looking for logic flaws. They found the update_inventory.py script exposed via a misconfigured API endpoint. They realized the script would fetch any URL they gave it and return the result.
⚠️ This token grants access to Google Cloud APIs with the permissions of the service account. Never log, store, or transmit this token outside the instance. The token typically expires in 1 hour.
In this example, the response indicates that the instance has a single service account associated with it, identified by its email address. The aliases field provides alternative names for the service account, while the scope field specifies the scope of the service account.
from google.auth import compute_engine credentials = compute_engine.Credentials() request = google.auth.transport.requests.Request() credentials.refresh(request) access_token = credentials.token print(f"Access token (first 20 chars): access_token[:20]...")
url = 'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts-/' headers = 'Metadata-Flavor': 'Google'
– Enable Cloud Audit Logs for service account token generation.