Skip to content

Commit 9e39e77

Browse files
committed
f
1 parent 53d29a8 commit 9e39e77

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-kms-post-exploitation.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ gcloud kms import-jobs create [IMPORT_JOB] --location [LOCATION] --keyring [KEY_
8282
- **Delete the KMS key**
8383
- Now only the attacker, who has the original key material could be able to decrypt the encrypted data
8484

85+
#### Cloud Storage + CMEK permission model
86+
87+
When objects in Cloud Storage are encrypted with CMEK, the decrypt/encrypt calls to KMS are done by the project's **Cloud Storage service agent whose email is service-${BUCKET_PROJECT_NUMBER}@gs-project-accounts.iam.gserviceaccount.com)**, not directly by the end user reading the object.
88+
89+
This means that to read something encrypted by a CMEK:
90+
91+
- The project's cloud storage service agent must have KMS permissions over the used KMS key (typically `roles/cloudkms.cryptoKeyEncrypterDecrypter`).
92+
- The user only needs object read permissions (for example `storage.objects.get`). He doesn't need permissions over the KMS key.
93+
94+
Thsi means that to control acces to encrypted data with the KMS key it's needed to add/rmeove KMS permissions to the projects cloud storage service agent.
95+
96+
Note that there is a project-level binding like `roles/cloudkms.cryptoKeyEncrypterDecrypter` for the Storage service agent will still allow decrypt with the keys in the same project.
97+
98+
8599
#### Here are the steps to import a new version and disable/delete the older data:
86100

87101
<details>
@@ -317,4 +331,3 @@ gcloud kms keys versions enable <VERSION_ID> \
317331
{{#include ../../../banners/hacktricks-training.md}}
318332

319333

320-

src/pentesting-cloud/gcp-security/gcp-services/gcp-kms-enum.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ The "Programmed for destruction" period is the **time since the user ask for del
3535

3636
Each KMS key can have several versions, one of them must be the **default** one, this will be the one used when a **version is not specified when interacting with the KMs key**.
3737

38+
### CMEK permission model
39+
40+
When objects in Cloud Storage are encrypted with CMEK, the decrypt/encrypt calls to KMS are done by the project's **Cloud Storage service agent whose email is service-${BUCKET_PROJECT_NUMBER}@gs-project-accounts.iam.gserviceaccount.com)**, not directly by the end user reading the object.
41+
42+
This means that to read something encrypted by a CMEK:
43+
44+
- The project's cloud storage service agent must have KMS permissions over the used KMS key (typically `roles/cloudkms.cryptoKeyEncrypterDecrypter`).
45+
- The user only needs object read permissions (for example `storage.objects.get`). He doesn't need permissions over the KMS key.
46+
47+
Thsi means that to control acces to encrypted data with the KMS key it's needed to add/rmeove KMS permissions to the projects cloud storage service agent.
48+
49+
Note that there is a project-level binding like `roles/cloudkms.cryptoKeyEncrypterDecrypter` for the Storage service agent will still allow decrypt with the keys in the same project.
50+
3851
### Enumeration
3952

4053
Having **permissions to list the keys** this is how you can access them:

0 commit comments

Comments
 (0)