AWS - CodeBuild Acceso no autenticado

Tip

Aprende y practica Hacking en AWS:HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP: HackTricks Training GCP Red Team Expert (GRTE) Aprende y practica Hacking en Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Apoya a HackTricks

CodeBuild

Para más información consulta esta página:

AWS - Codebuild Enum

buildspec.yml

Si comprometes permisos de escritura sobre un repositorio que contiene un archivo llamado buildspec.yml, podrías backdoor este archivo, el cual especifica los comandos que se van a ejecutar dentro de un proyecto CodeBuild y exfiltrar los secrets, comprometer lo que se hace y también comprometer las CodeBuild IAM role credentials.

Ten en cuenta que, incluso si no existe ningún archivo buildspec.yml pero sabes que se está usando CodeBuild (o un CI/CD diferente), modificar código legítimo que se vaya a ejecutar también puede darte, por ejemplo, un reverse shell.

Para información relacionada, puedes consultar la página sobre cómo atacar Github Actions (similar a esto):

Abusing Github Actions

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

Esta nueva relación entre Github Actions y AWS crea otra forma de comprometer AWS desde Github, ya que el código en Github se ejecutará en un proyecto CodeBuild con un IAM role adjunto.

Tip

Aprende y practica Hacking en AWS:HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP: HackTricks Training GCP Red Team Expert (GRTE) Aprende y practica Hacking en Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Apoya a HackTricks