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 5dc9d8e48..92e9c9591 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 - Generic Permissions Privesc {{#include ../../../banners/hacktricks-training.md}} -## 일반 흥미로운 권한 +## 일반적으로 흥미로운 권한 ### \*.setIamPolicy -사용자가 **`setIamPolicy`** 권한을 가진 경우, 해당 리소스의 IAM 정책을 변경하여 **해당 리소스에서 권한을 상승시킬 수 있습니다**.\ -이 권한은 코드 실행을 허용하는 리소스에서 **다른 주체로 권한을 상승시킬 수 있게** 해줄 수 있으며, iam.ServiceAccounts.actAs가 필요하지 않습니다. +리소스에서 **`setIamPolicy`** 권한을 가진 사용자를 소유하고 있다면 그 리소스의 IAM 정책을 변경할 수 있으므로 해당 리소스에서 **escalate privileges in that resource** 할 수 있습니다.\ +이 권한은 리소스가 코드를 실행할 수 있고 `iam.ServiceAccounts.actAs`가 필요하지 않을 경우 **escalate to other principals** 하는 데도 사용될 수 있습니다. - _cloudfunctions.functions.setIamPolicy_ -- Cloud Function의 정책을 수정하여 자신이 호출할 수 있도록 허용합니다. +- Modify the policy of a Cloud Function to allow yourself to invoke it. -이러한 종류의 권한을 가진 리소스 유형이 수십 개 있으며, [https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference)에서 setIamPolicy를 검색하여 모두 찾을 수 있습니다. +이와 같은 권한을 가진 리소스 유형이 수십 가지 있으므로, setIamPolicy를 검색해 [https://cloud.google.com/iam/docs/permissions-reference](https://cloud.google.com/iam/docs/permissions-reference)에서 모두 확인할 수 있습니다. ### \*.create, \*.update -이 권한은 **새 리소스를 생성하거나 기존 리소스를 업데이트하여 권한을 상승시키는 데** 매우 유용할 수 있습니다. 이러한 권한은 서비스 계정에 대해 **iam.serviceAccounts.actAs** 권한이 있는 경우 특히 유용하며, .create/.update 권한이 있는 리소스는 서비스 계정을 연결할 수 있습니다. +이 권한들은 새로운 리소스를 **생성하거나 업데이트**하여 리소스에서 권한을 상승시키려 할 때 매우 유용할 수 있습니다. 특히 해당 리소스에 대해 .create/.update 권한을 갖고 있고, 동시에 특정 Service Account에 대해 **iam.serviceAccounts.actAs** 권한도 가지고 있으며 해당 리소스가 Service Account를 연결(attach)할 수 있다면 더욱 유용합니다. ### \*ServiceAccount\* -이 권한은 일반적으로 **어떤 리소스에서 서비스 계정에 접근하거나 수정할 수 있게** 해줍니다 (예: compute.instances.setServiceAccount). 이는 **권한 상승** 벡터로 이어질 수 있지만, 각 경우에 따라 다릅니다. +이 권한은 보통 일부 리소스에서 Service Account에 **접근하거나 수정(access or modify)** 할 수 있게 해줍니다(예: compute.instances.setServiceAccount). 이는 경우에 따라 **could lead to a privilege escalation** 벡터가 될 수 있지만, 각 사례에 따라 달라집니다. + +### iam.ServiceAccounts.actAs + +이 권한은 지원하는 리소스(예: Compute Engine VM, Cloud Function, Cloud Run 등)에 Service Account를 연결할 수 있게 해줍니다.\ +만약 자신의 사용자보다 더 많은 권한을 가진 Service Account를 코드 실행이 가능한 리소스에 연결할 수 있다면, 해당 Service Account로 코드를 실행하여 권한을 상승(escalate your privileges)시킬 수 있습니다. + +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 327d2ccc4..d3364837e 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 ] ``` -이 방법에 대한 파이썬 스크립트는 [여기](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/orgpolicy.policy.set.py)에서 찾을 수 있습니다. +A python script for this method can be found [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 +``` +이는 공격자가 추가적인 인프라 권한(예: 새 VM을 시작할 권한) 없이 다른 프로젝트의 서비스 계정으로 가장하기 위해 권한 **`iam.serviceAccounts.actAs`**를 악용하는 것을 방지하며, 그렇지 않으면 권한 상승으로 이어질 수 있습니다. + +그러나 권한 **`orgpolicy.policy.set`**를 가진 공격자는 제약 조건 **`iam.disableServiceAccountProjectWideAccess`**를 비활성화하여 이 제한을 우회할 수 있습니다. 이렇게 하면 공격자는 다른 프로젝트의 서비스 계정을 자신의 프로젝트 내 리소스에 연결할 수 있어 실질적으로 권한을 상승시킬 수 있습니다. +```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/)