mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-25 20:34:33 -08:00
Translated ['', 'src/pentesting-cloud/gcp-security/gcp-privilege-escalat
This commit is contained in:
@@ -6,20 +6,27 @@
|
||||
|
||||
### \*.setIamPolicy
|
||||
|
||||
As jy 'n gebruiker besit wat die **`setIamPolicy`** toestemming in 'n hulpbron het, kan jy **privileges in daardie hulpbron verhoog** omdat jy die IAM-beleid van daardie hulpbron kan verander en vir jouself meer privileges kan gee.\
|
||||
Hierdie toestemming kan ook toelaat om **na ander principals te verhoog** as die hulpbron toelaat om kode uit te voer en die iam.ServiceAccounts.actAs nie nodig is nie.
|
||||
If you owns a user that has the **`setIamPolicy`** permission in a resource you can **escalate privileges in that resource** because you will be able to change the IAM policy of that resource and give you more privileges over it.\
|
||||
This permission can also allow to **escalate to other principals** if the resource allow to execute code and the `iam.ServiceAccounts.actAs` is not necessary.
|
||||
|
||||
- _cloudfunctions.functions.setIamPolicy_
|
||||
- Wysig die beleid van 'n Cloud Funksie om jouself toe te laat om dit aan te roep.
|
||||
- Pas die beleid van 'n Cloud Function aan om jouself toe te laat dit aan te roep.
|
||||
|
||||
Daar is tientalle hulpbron tipes met hierdie soort toestemming, jy kan al hulle vind in [https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference) deur te soek na setIamPolicy.
|
||||
Daar is baie soorte resources met hierdie tipe toestemming; jy kan al hulle vind by [https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference) deur te soek na setIamPolicy.
|
||||
|
||||
### \*.create, \*.update
|
||||
|
||||
Hierdie toestemmings kan baie nuttig wees om te probeer om privileges in hulpbronne te verhoog deur **'n nuwe een te skep of 'n nuwe een op te dateer**. Hierdie soort toestemmings is veral nuttig as jy ook die toestemming **iam.serviceAccounts.actAs** oor 'n Service Account het en die hulpbron waaroor jy .create/.update het, 'n diensrekening kan aanheg.
|
||||
These permissions can be very useful to try to escalate privileges in resources by **creating a new one or updating a new one**. These can of permissions are specially useful if you also has the permission **iam.serviceAccounts.actAs** over a Service Account and the resource you have .create/.update over can attach a service account.
|
||||
|
||||
### \*ServiceAccount\*
|
||||
|
||||
Hierdie toestemming sal gewoonlik toelaat dat jy **toegang tot of 'n Service Account in 'n hulpbron wysig** (bv.: compute.instances.setServiceAccount). Dit **kan lei tot 'n privilege verhoging** vektor, maar dit sal van elke geval afhang.
|
||||
This permission will usually let you **access or modify a Service Account in some resource** (e.g.: compute.instances.setServiceAccount). This **could lead to a privilege escalation** vector, but it will depend on each case.
|
||||
|
||||
### iam.ServiceAccounts.actAs
|
||||
|
||||
This permission will let you attach a Service Account to a resource that supports it (e.g.: Compute Engine VM, Cloud Function, Cloud Run, etc).\
|
||||
If you can attach a Service Account that has more privileges than your user to a resource that can execute code, you will be able to escalate your privileges by executing code with that Service Account.
|
||||
|
||||
Search in Cloud Hacktricks for `iam.ServiceAccounts.actAs` to find several examples of how to escalate privileges with this permission.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
### `orgpolicy.policy.set`
|
||||
|
||||
'n Aanvaller wat **orgpolicy.policy.set** benut, kan organisatoriese beleid manipuleer, wat hom in staat sal stel om sekere beperkings wat spesifieke operasies belemmer, te verwyder. Byvoorbeeld, die beperking **appengine.disableCodeDownload** blokkeer gewoonlik die aflaai van App Engine-bronkode. egter, deur **orgpolicy.policy.set** te gebruik, kan 'n aanvaller hierdie beperking deaktiveer, en sodoende toegang verkry om die bronkode af te laai, ten spyte daarvan dat dit aanvanklik beskerm was.
|
||||
'n aanvaller wat **orgpolicy.policy.set** misbruik, kan organisatoriese beleide manipuleer, wat hom in staat sal stel om sekere beperkings wat spesifieke operasies belemmer te verwyder. Byvoorbeeld, die beperking **appengine.disableCodeDownload** blokkeer gewoonlik die aflaai van App Engine-bronkode. Deur egter **orgpolicy.policy.set** te gebruik, kan 'n aanvaller hierdie beperking deaktiveer en sodoende toegang kry om die bronkode af te laai, al was dit aanvanklik beskerm.
|
||||
```bash
|
||||
# Get info
|
||||
gcloud resource-manager org-policies describe <org-policy> [--folder <id> | --organization <id> | --project <id>]
|
||||
@@ -14,8 +14,31 @@ gcloud resource-manager org-policies describe <org-policy> [--folder <id> | --or
|
||||
# Disable
|
||||
gcloud resource-manager org-policies disable-enforce <org-policy> [--folder <id> | --organization <id> | --project <id>]
|
||||
```
|
||||
'n Python-skrip vir hierdie metode kan [hier] (https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/orgpolicy.policy.set.py) gevind word.
|
||||
'n python-skrip vir hierdie metode is beskikbaar [hier](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/orgpolicy.policy.set.py).
|
||||
|
||||
### `orgpolicy.policy.set`, `iam.serviceAccounts.actAs`
|
||||
|
||||
Gewoonlik is dit nie moontlik om 'n service account van 'n ander project aan 'n resource te koppel nie, omdat daar 'n beleidsbeperking met die naam **`iam.disableCrossProjectServiceAccountUsage`** afgedwing word wat hierdie aksie verhoed.
|
||||
|
||||
Dit is moontlik om te verifieer of hierdie beperking afgedwing word deur die volgende kommando uit te voer:
|
||||
```bash
|
||||
gcloud resource-manager org-policies describe \
|
||||
constraints/iam.disableCrossProjectServiceAccountUsage \
|
||||
--project=<project-id> \
|
||||
--effective
|
||||
|
||||
booleanPolicy:
|
||||
enforced: true
|
||||
constraint: constraints/iam.disableCrossProjectServiceAccountUsage
|
||||
```
|
||||
Dit voorkom dat 'n aanvaller misbruik maak van die toestemming **`iam.serviceAccounts.actAs`** om 'n service account van 'n ander projek na te boots sonder die verdere nodige infra-toestemmings om byvoorbeeld 'n nuwe VM te begin, wat tot privilege escalation kan lei.
|
||||
|
||||
Echter, 'n aanvaller met die toestemmings **`orgpolicy.policy.set`** kan hierdie beperking omseil deur die constraint **`iam.disableServiceAccountProjectWideAccess`** te deaktiveer. Dit stel die aanvaller in staat om 'n service account van 'n ander projek aan 'n resource in sy eie projek te koppel, waardeur hy sy privileges effektief kan verhoog.
|
||||
```bash
|
||||
gcloud resource-manager org-policies disable-enforce \
|
||||
iam.disableCrossProjectServiceAccountUsage \
|
||||
--project=<project-id>
|
||||
```
|
||||
## Verwysings
|
||||
|
||||
- [https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/](https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/)
|
||||
|
||||
Reference in New Issue
Block a user