AWS - CodeBuild Post Exploitation

Tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें

CodeBuild

For more information, check:

AWS - Codebuild Enum

Check Secrets

If credentials have been set in Codebuild to connect to Github, Gitlab or Bitbucket in the form of personal tokens, passwords or OAuth token access, these credentials are going to be stored as secrets in the secret manager.
यदि Codebuild में Github, Gitlab या Bitbucket से कनेक्ट करने के लिए personal tokens, passwords या OAuth token access के रूप में credentials सेट किए गए हैं, तो ये credentials secret manager में secrets के रूप में स्टोर किए जाएंगे।\

Therefore, if you have access to read the secret manager you will be able to get these secrets and pivot to the connected platform. इसलिए, यदि आपके पास secret manager पढ़ने की पहुँच है तो आप इन secrets को प्राप्त कर पाएंगे और connected platform पर pivot कर सकेंगे।

AWS - Secrets Manager Privesc

Abuse CodeBuild Repo Access

In order to configure CodeBuild, it will need access to the code repo that it’s going to be using. Several platforms could be hosting this code: CodeBuild को configure करने के लिए, इसे उस code repo तक access चाहिए होगा जिसे यह उपयोग करेगा। कई platforms यह code host कर सकते हैं:

The CodeBuild project must have access to the configured source provider, either via IAM role of with a github/bitbucket token or OAuth access. CodeBuild project का configured source provider तक access होना चाहिए, या तो IAM role के जरिए या github/bitbucket token या OAuth access के साथ।

An attacker with elevated permissions in over a CodeBuild could abuse this configured access to leak the code of the configured repo and others where the set creds have access.
In order to do this, an attacker would just need to change the repository URL to each repo the config credentials have access (note that the aws web will list all of them for you): एक attacker जिसके पास किसी CodeBuild पर elevated permissions हों, वह इस configured access का दुरुपयोग करके configured repo और उन अन्य repos का code leak कर सकता है जिन तक set creds की पहुँच है।
इसके लिए, attacker को बस repository URL को उन-उन repos पर बदलना होगा जिन तक config credentials की पहुँच है (ध्यान दें कि aws web इन्हें आपके लिए सूचीबद्ध करेगा):

And change the Buildspec commands to exfiltrate each repo. और Buildspec commands को बदलकर प्रत्येक repo को exfiltrate करने के लिए सेट करें।

Warning

However, this task is repetitive and tedious and if a github token was configured with write permissions, an attacker won’t be able to (ab)use those permissions as he doesn’t have access to the token.
Or does he? Check the next section हालाँकि, यह कार्य दोहरावदार और थकाऊ है और यदि कोई github token write permissions के साथ configure किया गया था, तो attacker उन permissions का (ab)use नहीं कर पाएगा क्योंकि उसके पास token की पहुँच नहीं है।
या क्या वह कर सकता है? अगले सेक्शन को देखें

Leaking Access Tokens from AWS CodeBuild

You can leak access given in CodeBuild to platforms like Github. Check if any access to external platforms was given with: आप CodeBuild में दिये गए access को Github जैसे platforms पर leak कर सकते हैं। जांचें कि क्या किसी external platform को access दिया गया है:

aws codebuild list-source-credentials

AWS Codebuild - Token Leakage

webhook filter misconfiguration के माध्यम से Untrusted PR का निष्पादन

यदि webhook filters कमजोर हैं, तो बाहरी हमलावर अपने PRs को privileged CodeBuild projects में build करा सकते हैं और फिर CI में arbitrary code execute कर सकते हैं।

AWS CodeBuild - Untrusted PR Webhook Bypass (CodeBreach-style)

codebuild:DeleteProject

एक हमलावर पूरे CodeBuild project को डिलीट कर सकता है, जिससे project configuration खो सकती है और उन applications पर प्रभाव पड़ेगा जो उस project पर निर्भर हैं।

aws codebuild delete-project --name <value>

Potential Impact: परियोजना कॉन्फ़िगरेशन का नुकसान और उन एप्लिकेशन के लिए सेवा में व्यवधान जो हटाए गए प्रोजेक्ट का उपयोग कर रही हैं।

codebuild:TagResource , codebuild:UntagResource

एक हमलावर CodeBuild संसाधनों पर टैग जोड़, संशोधित या हटा सकता है, जिससे आपके संगठन के लागत आवंटन, संसाधन ट्रैकिंग और टैग-आधारित एक्सेस कंट्रोल नीतियाँ प्रभावित हो सकती हैं।

aws codebuild tag-resource --resource-arn <value> --tags <value>
aws codebuild untag-resource --resource-arn <value> --tag-keys <value>

संभावित प्रभाव: लागत आवंटन, संसाधन ट्रैकिंग, और टैग-आधारित एक्सेस कंट्रोल नीतियों में व्यवधान।

codebuild:DeleteSourceCredentials

एक हमलावर Git रिपॉज़िटरी के लिए source credentials हटा सकता है, जिससे रिपॉज़िटरी पर निर्भर अनुप्रयोगों के सामान्य संचालन प्रभावित हो सकते हैं।

aws codebuild delete-source-credentials --arn <value>

संभावित प्रभाव: प्रभावित रिपॉज़िटरी पर निर्भर अनुप्रयोगों के सामान्य संचालन में स्रोत क्रेडेंशियल्स हटाए जाने के कारण व्यवधान।

Tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें