AWS - CodeBuild 未認証アクセス

Tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする

CodeBuild

詳細は次のページを参照してください:

AWS - Codebuild Enum

buildspec.yml

リポジトリ内に buildspec.yml というファイルがあり、そのリポジトリへの書き込み権を奪取できる場合、当該ファイルをbackdoorすることで、CodeBuild プロジェクト内で実行される 実行されるコマンド を変更し、シークレットを exfiltrate したり、処理自体を侵害したり、CodeBuild IAM role credentials を奪取したりできます。

たとえ buildspec.yml が存在しなくても、Codebuild が使われている(または別の CI/CD)が分かっている場合、実行されるコードを正規コードの改変することで、例えば reverse shell を取得できることがあります。

関連情報として、Github Actions を攻撃する方法(本件と類似)についてのページも参照してください:

Abusing Github Actions

AWS CodeBuild における self-hosted GitHub Actions ランナー

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 }}

Github ActionsとAWSのこの新しい関係により、Github上のコードはIAM roleがアタッチされたCodeBuildプロジェクトで実行されるため、GithubからAWSを侵害する別の経路が生まれます。

Tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする