AWS - CodeBuild Unauthenticated Access
Reading time: 2 minutes
tip
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the 💬 Discord group or the telegram group or follow us on Twitter 🐦 @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
CodeBuild
For more info check this page:
buildspec.yml
If you compromise write access over a repository containing a file named buildspec.yml
, you could backdoor this file, which specifies the commands that are going to be executed inside a CodeBuild project and exfiltrate the secrets, compromise what is done and also compromise the CodeBuild IAM role credentials.
Note that even if there isn't any buildspec.yml
file but you know Codebuild is being used (or a different CI/CD) modifying some legit code that is going to be executed can also get you a reverse shell for example.
For some related information you could check the page about how to attack Github Actions (similar to this):
Self-hosted GitHub Actions runners in AWS CodeBuild
As indicated in the docs, It's possible to configure CodeBuild to run self-hosted Github actions when a workflow is triggered inside a Github repo configured. This can be detected checking the CodeBuild project configuration because the Event type
needs to contain: WORKFLOW_JOB_QUEUED
and in a Github Workflow because it will select a self-hosted runner like this:
runs-on: codebuild-<project-name>-${{ github.run_id }}-${{ github.run_attempt }}
This new relationship between Github Actions and AWS creates another way to compromise AWS from Github as the code in Github will be running in a CodeBuild project with an IAM role attached.
tip
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the 💬 Discord group or the telegram group or follow us on Twitter 🐦 @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.