AWS - CodeBuild Post Exploitation
Tip
Apprenez et pratiquez le hacking AWS :
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP :HackTricks Training GCP Red Team Expert (GRTE)
Apprenez et pratiquez le hacking Azure :
HackTricks Training Azure Red Team Expert (AzRTE)
Soutenir HackTricks
- Vérifiez les plans d’abonnement !
- Rejoignez le 💬 groupe Discord ou le groupe telegram ou suivez-nous sur Twitter 🐦 @hacktricks_live.
- Partagez des astuces de hacking en soumettant des PR au HackTricks et HackTricks Cloud dépôts github.
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 et pratiquez le hacking AWS :
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP :HackTricks Training GCP Red Team Expert (GRTE)
Apprenez et pratiquez le hacking Azure :
HackTricks Training Azure Red Team Expert (AzRTE)
Soutenir HackTricks
- Vérifiez les plans d’abonnement !
- Rejoignez le 💬 groupe Discord ou le groupe telegram ou suivez-nous sur Twitter 🐦 @hacktricks_live.
- Partagez des astuces de hacking en soumettant des PR au HackTricks et HackTricks Cloud dépôts github.
HackTricks Cloud

