AWS - CodeBuild Accesso non autenticato

Reading time: 3 minutes

tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks

CodeBuild

Per maggiori informazioni consulta questa pagina:

AWS - Codebuild Enum

buildspec.yml

Se ottieni accesso in scrittura a un repository che contiene un file chiamato buildspec.yml, potresti inserire una backdoor in questo file, che specifica i comandi che verranno eseguiti all'interno di un progetto CodeBuild e exfiltrate i segreti, compromettere ciò che viene eseguito e anche compromettere le CodeBuild IAM role credentials.

Nota che anche se non esiste alcun file buildspec.yml, ma sai che CodeBuild viene utilizzato (o un diverso CI/CD), modificare del codice legittimo che verrà eseguito può anche darti, per esempio, una reverse shell.

Per informazioni correlate puoi consultare la pagina su come attaccare Github Actions (simile a questo):

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:

bash
runs-on: codebuild-<project-name>-${{ github.run_id }}-${{ github.run_attempt }}

Questa nuova relazione tra Github Actions e AWS crea un altro modo per compromettere AWS da Github, poiché il codice su Github verrà eseguito in un progetto CodeBuild con un ruolo IAM associato.

tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks