AWS - CodeBuild Post Exploitation
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
For more information, check:
AWS - Codebuild EnumIf 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. Therefore, if you have access to read the secret manager you will be able to get these secrets and pivot to the connected platform.
AWS - Secrets Manager PrivescIn 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:
The CodeBuild project must have access to the configured source provider, either via IAM role of with a github/bitbucket token or 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):
And change the Buildspec commands to exfiltrate each repo.
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
You can leak access given in CodeBuild to platforms like Github. Check if any access to external platforms was given with:
codebuild:DeleteProject
Mshambuliaji anaweza kufuta mradi mzima wa CodeBuild, na kusababisha kupoteza usanidi wa mradi na kuathiri programu zinazotegemea mradi huo.
Madhara Yanayoweza Kutokea: Kupoteza usanidi wa mradi na usumbufu wa huduma kwa programu zinazotumia mradi uliofutwa.
codebuild:TagResource
, codebuild:UntagResource
Mshambuliaji anaweza kuongeza, kubadilisha, au kuondoa lebo kutoka kwa rasilimali za CodeBuild, akisababisha usumbufu katika ugawaji wa gharama wa shirika lako, ufuatiliaji wa rasilimali, na sera za udhibiti wa ufikiaji kulingana na lebo.
Madhara Yanayoweza Kutokea: Kuingiliwa kwa ugawaji wa gharama, ufuatiliaji wa rasilimali, na sera za udhibiti wa ufikiaji kulingana na lebo.
codebuild:DeleteSourceCredentials
Mshambuliaji anaweza kufuta akiba za chanzo kwa ajili ya hazina ya Git, ikihusisha na utendaji wa kawaida wa programu zinazotegemea hazina hiyo.
Madhara Yanayoweza Kutokea: Kuingiliwa kwa utendaji wa kawaida wa programu zinazotegemea hazina iliyoathirika kutokana na kuondolewa kwa akreditivu za chanzo.
Jifunze & fanya mazoezi ya AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Jifunze & fanya mazoezi ya GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)