From 495b105c5cd1cc8874fe0280defd8ae131c21cdc Mon Sep 17 00:00:00 2001 From: Translator Date: Sat, 15 Nov 2025 11:49:03 +0000 Subject: [PATCH] Translated ['', 'src/pentesting-cloud/gcp-security/gcp-privilege-escalat --- .../gcp-misc-perms-privesc.md | 23 ++++++++++----- .../gcp-orgpolicy-privesc.md | 29 +++++++++++++++++-- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-misc-perms-privesc.md b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-misc-perms-privesc.md index 822df37c3..d21561437 100644 --- a/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-misc-perms-privesc.md +++ b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-misc-perms-privesc.md @@ -1,25 +1,32 @@ -# GCP - 一般的な権限昇格 +# GCP - 汎用パーミッション Privesc {{#include ../../../banners/hacktricks-training.md}} -## 一般的に興味深い権限 +## 汎用の注目すべき権限 ### \*.setIamPolicy -あなたが**`setIamPolicy`**権限を持つユーザーを所有している場合、そのリソース内で**権限を昇格させる**ことができます。なぜなら、そのリソースのIAMポリシーを変更して、より多くの権限を与えることができるからです。\ -この権限は、リソースがコードを実行できる場合に**他のプリンシパルに昇格する**ことも可能です。iam.ServiceAccounts.actAsが必要ない場合です。 +もしユーザーがリソースに対して **`setIamPolicy`** 権限を持っている場合、そのリソースのIAMポリシーを変更して自身により多くの権限を付与できるため、そのリソース内で**権限を昇格**できます。\ +この権限は、リソースがコードの実行を許可しており `iam.ServiceAccounts.actAs` が不要な場合に、**他のプリンシパルへ昇格**するためにも利用され得ます。 - _cloudfunctions.functions.setIamPolicy_ -- Cloud Functionのポリシーを変更して、自分自身がそれを呼び出せるようにします。 +- Cloud Function のポリシーを変更して、自分が呼び出せるようにする。 -この種の権限を持つリソースタイプは数十種類あり、[https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference)でsetIamPolicyを検索することで、すべて見つけることができます。 +この種の権限を持つリソースタイプは数十種類あり、[https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference) で setIamPolicy を検索するとすべて確認できます。 ### \*.create, \*.update -これらの権限は、**新しいリソースを作成するか、既存のリソースを更新することによって権限を昇格させる**ために非常に便利です。この種の権限は、サービスアカウントに対して**iam.serviceAccounts.actAs**権限を持っている場合、特に有用です。また、あなたが.create/.update権限を持つリソースがサービスアカウントをアタッチできる場合にも有効です。 +これらの権限は、リソースを**新しく作成したり更新したりすることで**権限昇格を試みる際に非常に有用です。特に、Service Account に対して **iam.serviceAccounts.actAs** 権限を持っていて、あなたが .create/.update を持つリソースが Service Account をアタッチできる場合に有効です。 ### \*ServiceAccount\* -この権限は通常、**特定のリソース内のサービスアカウントにアクセスまたは変更する**ことを許可します(例:compute.instances.setServiceAccount)。これは**権限昇格**のベクトルにつながる可能性がありますが、ケースバイケースで異なります。 +この権限は通常、あるリソース内の Service Account に**アクセスまたは変更**を行えるようにします(例: compute.instances.setServiceAccount)。これは**特権昇格の経路**につながる可能性がありますが、ケースごとに依存します。 + +### iam.ServiceAccounts.actAs + +この権限があれば、Service Account をそれをサポートするリソースにアタッチできます(例: Compute Engine VM, Cloud Function, Cloud Run, 等)。\ +もし自分のユーザーより多くの権限を持つ Service Account をコード実行可能なリソースにアタッチできれば、その Service Account でコードを実行することで権限を昇格できます。 + +Cloud Hacktricks で `iam.ServiceAccounts.actAs` を検索すると、この権限を使った複数の権限昇格例が見つかります。 {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-orgpolicy-privesc.md b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-orgpolicy-privesc.md index df06326db..01d5d50ec 100644 --- a/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-orgpolicy-privesc.md +++ b/src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-orgpolicy-privesc.md @@ -6,7 +6,7 @@ ### `orgpolicy.policy.set` -攻撃者は**orgpolicy.policy.set**を利用することで、組織のポリシーを操作でき、特定の操作を妨げる制限を取り除くことができます。例えば、制約**appengine.disableCodeDownload**は通常、App Engineのソースコードのダウンロードをブロックします。しかし、**orgpolicy.policy.set**を使用することで、攻撃者はこの制約を無効にし、最初は保護されていたにもかかわらず、ソースコードのダウンロードにアクセスできるようになります。 +**orgpolicy.policy.set** を利用する攻撃者は組織のポリシーを操作でき、特定の操作を妨げる制限を解除することができます。例えば、制約 **appengine.disableCodeDownload** は通常 App Engine のソースコードのダウンロードをブロックします。しかし **orgpolicy.policy.set** を使うことでこの制約を無効化でき、当初は保護されていたソースコードをダウンロードできるようになります。 ```bash # Get info gcloud resource-manager org-policies describe [--folder | --organization | --project ] @@ -14,9 +14,32 @@ gcloud resource-manager org-policies describe [--folder | --or # Disable gcloud resource-manager org-policies disable-enforce [--folder | --organization | --project ] ``` -このメソッドのためのPythonスクリプトは[こちら](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/orgpolicy.policy.set.py)で見つけることができます。 +A python スクリプトはこの方法のために [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/orgpolicy.policy.set.py) にあります。 -## 参考文献 +### `orgpolicy.policy.set`, `iam.serviceAccounts.actAs` + +通常、異なるプロジェクトのサービスアカウントをリソースに紐付けることはできません。なぜなら **`iam.disableCrossProjectServiceAccountUsage`** というポリシー制約が適用されており、この操作を防止するためです。 + +この制約が適用されているかどうかは、以下のコマンドを実行して確認できます: +```bash +gcloud resource-manager org-policies describe \ +constraints/iam.disableCrossProjectServiceAccountUsage \ +--project= \ +--effective + +booleanPolicy: +enforced: true +constraint: constraints/iam.disableCrossProjectServiceAccountUsage +``` +これは attacker が **`iam.serviceAccounts.actAs`** 権限を悪用して、例えば新しい VM を起動するために必要な追加のインフラ権限なしに別のプロジェクトのサービスアカウントを偽装し、privilege escalation を招くのを防ぎます。 + +しかし、**`orgpolicy.policy.set`** の権限を持つ attacker は、制約 **`iam.disableServiceAccountProjectWideAccess`** を無効化することでこの制限を回避できます。これにより attacker は別のプロジェクトのサービスアカウントを自分のプロジェクト内のリソースにアタッチでき、effectively escalating his privileges。 +```bash +gcloud resource-manager org-policies disable-enforce \ +iam.disableCrossProjectServiceAccountUsage \ +--project= +``` +## 参考 - [https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/](https://rhinosecuritylabs.com/cloud-security/privilege-escalation-google-cloud-platform-part-2/)