AWS - CodeBuild Post Exploitation
Tip
Apprenez & pratiquez AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Soutenez HackTricks
- Consultez les subscription plans!
- Rejoignez le đŹ Discord group ou le telegram group ou suivez-nous sur Twitter đŠ @hacktricks_live.
- Partagez des hacking tricks en soumettant des PRs aux HackTricks et HackTricks Cloud github repos.
CodeBuild
For more information, check:
Vérifier les 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.
Therefore, if you have access to read the secret manager you will be able to get these secrets and pivot to the connected platform.
Abuser de lâaccĂšs au repo CodeBuild
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:
.png)
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):
.png)
And change the Buildspec commands to exfiltrate each repo.
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
Leaking Access Tokens from AWS CodeBuild
Vous pouvez leak access given in CodeBuild to platforms like Github. Check if any access to external platforms was given with:
aws codebuild list-source-credentials
Exécution de PR non approuvées via une mauvaise configuration des webhook filters
Si les webhook filters sont faibles, des attaquants externes peuvent faire en sorte que leurs PRs soient construits dans des projets CodeBuild privilégiés, puis exécuter du code arbitraire dans le CI.
AWS CodeBuild - Untrusted PR Webhook Bypass (CodeBreach-style)
codebuild:DeleteProject
Un attaquant pourrait supprimer un projet CodeBuild entier, provoquant la perte de la configuration du projet et affectant les applications qui dépendent de ce projet.
aws codebuild delete-project --name <value>
Impact potentiel : Perte de la configuration du projet et interruption du service pour les applications utilisant le projet supprimé.
codebuild:TagResource , codebuild:UntagResource
Un attaquant pourrait ajouter, modifier ou supprimer des tags sur les ressources CodeBuild, perturbant la rĂ©partition des coĂ»ts de votre organisation, le suivi des ressources et les politiques de contrĂŽle dâaccĂšs basĂ©es sur les tags.
aws codebuild tag-resource --resource-arn <value> --tags <value>
aws codebuild untag-resource --resource-arn <value> --tag-keys <value>
Impact potentiel : Perturbation de lâallocation des coĂ»ts, du suivi des ressources et des politiques de contrĂŽle dâaccĂšs basĂ©es sur les tags.
codebuild:DeleteSourceCredentials
Un attaquant pourrait supprimer les identifiants source dâun dĂ©pĂŽt Git, affectant le fonctionnement normal des applications qui dĂ©pendent de ce dĂ©pĂŽt.
aws codebuild delete-source-credentials --arn <value>
Impact potentiel : Perturbation du fonctionnement normal des applications sâappuyant sur le dĂ©pĂŽt affectĂ© en raison de la suppression des identifiants source.
Tip
Apprenez & pratiquez AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Soutenez HackTricks
- Consultez les subscription plans!
- Rejoignez le đŹ Discord group ou le telegram group ou suivez-nous sur Twitter đŠ @hacktricks_live.
- Partagez des hacking tricks en soumettant des PRs aux HackTricks et HackTricks Cloud github repos.
HackTricks Cloud

