# GCP - Secretmanager Privesc

{{#include ../../../banners/hacktricks-training.md}}

## secretmanager

Vir meer inligting oor secretmanager:

{{#ref}}
../gcp-services/gcp-secrets-manager-enum.md
{{#endref}}

### `secretmanager.versions.access`

Dit gee jou toegang om die secrets van die secret manager te lees en kan dalk help om escalate privileges (afhangend van watter inligting in die secret stored is):

<details><summary>Kry clear-text secret version</summary>
```bash
# Get clear-text of version 1 of secret: "<secret name>"
gcloud secrets versions access 1 --secret="<secret_name>"
```
</details>

Aangesien dit ook 'n post exploitation technique is, kan dit gevind word in:

{{#ref}}
../gcp-post-exploitation/gcp-secretmanager-post-exploitation.md
{{#endref}}

### `secretmanager.secrets.setIamPolicy`

Dit gee jou toegang om die secrets uit die secret manager te lees, byvoorbeeld deur:

<details><summary>Add IAM policy binding to secret</summary>
```bash
gcloud secrets add-iam-policy-binding <scret-name> \
--member="serviceAccount:<sa-name>@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
```
Of herroep beleide met:
```bash
gcloud secrets remove-iam-policy-binding <secret-name> \
--member="serviceAccount:<sa-name>@<PROJECT_ID>.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
```
</details>

{{#include ../../../banners/hacktricks-training.md}}
