# AWS - CodeBuild 未認証アクセス {{#include ../../../../banners/hacktricks-training.md}} ## CodeBuild 詳細は次のページを参照してください: {{#ref}} ../../aws-services/aws-codebuild-enum.md {{#endref}} ### buildspec.yml リポジトリ内に **`buildspec.yml`** というファイルがあり、そのリポジトリへの書き込み権を奪取できる場合、当該ファイルを**backdoor**することで、CodeBuild プロジェクト内で実行される **実行されるコマンド** を変更し、シークレットを exfiltrate したり、処理自体を侵害したり、**CodeBuild IAM role credentials** を奪取したりできます。 たとえ **`buildspec.yml`** が存在しなくても、Codebuild が使われている(または別の CI/CD)が分かっている場合、実行されるコードを**正規コードの改変**することで、例えば reverse shell を取得できることがあります。 関連情報として、Github Actions を攻撃する方法(本件と類似)についてのページも参照してください: {{#ref}} ../../../../pentesting-ci-cd/github-security/abusing-github-actions/ {{#endref}} ## AWS CodeBuild における self-hosted GitHub Actions ランナー As [**indicated in the docs**](https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html), 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: ```bash runs-on: codebuild--${{ github.run_id }}-${{ github.run_attempt }} ``` Github ActionsとAWSのこの新しい関係により、Github上のコードはIAM roleがアタッチされたCodeBuildプロジェクトで実行されるため、GithubからAWSを侵害する別の経路が生まれます。 {{#include ../../../../banners/hacktricks-training.md}}