Skip to content

Commit 92e9580

Browse files
authored
Merge pull request #225 from JaimePolop/master
update
2 parents 83306f3 + 98e8a9c commit 92e9580

File tree

13 files changed

+560
-1
lines changed

13 files changed

+560
-1
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
- [AWS - Apigateway Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apigateway-privesc/README.md)
305305
- [AWS - AppRunner Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apprunner-privesc/README.md)
306306
- [AWS - Chime Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-chime-privesc/README.md)
307+
- [AWS - CloudFront](pentesting-cloud/aws-security/aws-privilege-escalation/aws-cloudfront-privesc/README.md)
307308
- [AWS - Codebuild Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc/README.md)
308309
- [AWS - Codepipeline Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codepipeline-privesc/README.md)
309310
- [AWS - Codestar Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/README.md)

src/pentesting-cloud/aws-security/aws-persistence/aws-lambda-persistence/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,54 @@ This is stealthier than exposing a Function URL and doesn’t change the primary
8787
aws-lambda-alias-version-policy-backdoor.md
8888
{{#endref}}
8989

90+
### Freezing AWS Lambda Runtimes
91+
92+
An attacker who has lambda:InvokeFunction, logs:FilterLogEvents, lambda:PutRuntimeManagementConfig, and lambda:GetRuntimeManagementConfig permissions can modify a function’s runtime management configuration. This attack is especially effective when the goal is to keep a Lambda function on a vulnerable runtime version or to preserve compatibility with malicious layers that might be incompatible with newer runtimes.
93+
94+
The attacker modifies the runtime management configuration to pin the runtime version:
95+
96+
```bash
97+
# Invoke the function to generate runtime logs
98+
aws lambda invoke \
99+
--function-name $TARGET_FN \
100+
--payload '{}' \
101+
--region us-east-1 /tmp/ping.json
102+
103+
sleep 5
104+
105+
# Freeze automatic runtime updates on function update
106+
aws lambda put-runtime-management-config \
107+
--function-name $TARGET_FN \
108+
--update-runtime-on FunctionUpdate \
109+
--region us-east-1
110+
```
111+
112+
Verify the applied configuration:
113+
```bash
114+
aws lambda get-runtime-management-config \
115+
--function-name $TARGET_FN \
116+
--region us-east-1
117+
```
118+
119+
Optional: Pin to a specific runtime version
120+
```bash
121+
# Extract Runtime Version ARN from INIT_START logs
122+
RUNTIME_ARN=$(aws logs filter-log-events \
123+
--log-group-name /aws/lambda/$TARGET_FN \
124+
--filter-pattern "INIT_START" \
125+
--query 'events[0].message' \
126+
--output text | grep -o 'Runtime Version ARN: [^,]*' | cut -d' ' -f4)
127+
```
128+
129+
Pin to a specific runtime version:
130+
131+
```bash
132+
aws lambda put-runtime-management-config \
133+
--function-name $TARGET_FN \
134+
--update-runtime-on Manual \
135+
--runtime-version-arn $RUNTIME_ARN \
136+
--region us-east-1
137+
```
90138

91139
{{#include ../../../../banners/hacktricks-training.md}}
92140

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-cloudfront-post-exploitation/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ For more information check:
1010
../../aws-services/aws-cloudfront-enum.md
1111
{{#endref}}
1212

13+
### `cloudfront:Delete*`
14+
An attacker granted cloudfront:Delete* can delete distributions, policies and other critical CDN configuration objects — for example distributions, cache/origin policies, key groups, origin access identities, functions/configs, and related resources. This can cause service disruption, content loss, and removal of configuration or forensic artifacts.
15+
16+
To delete a distribution an attacker could use:
17+
18+
```bash
19+
aws cloudfront delete-distribution \
20+
--id <DISTRIBUTION_ID> \
21+
--if-match <ETAG>
22+
```
23+
1324
### Man-in-the-Middle
1425

1526
This [**blog post**](https://medium.com/@adan.alvarez/how-attackers-can-misuse-aws-cloudfront-access-to-make-it-rain-cookies-acf9ce87541c) proposes a couple of different scenarios where a **Lambda** could be added (or modified if it's already being used) into a **communication through CloudFront** with the purpose of **stealing** user information (like the session **cookie**) and **modifying** the **response** (injecting a malicious JS script).

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-dynamodb-post-exploitation/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,51 @@ aws kinesis delete-stream --stream-name htx-ddb-exfil --enforce-consumer-deletio
588588
aws dynamodb delete-table --table-name HTXKStream --region us-east-1 || true
589589
```
590590

591+
### `dynamodb:UpdateTimeToLive`
592+
593+
An attacker with the dynamodb:UpdateTimeToLive permission can change a table’s TTL (time-to-live) configuration — enabling or disabling TTL. When TTL is enabled, individual items that contain the configured TTL attribute will be automatically deleted once their expiration time is reached. The TTL value is just another attribute on each item; items without that attribute are not affected by TTL-based deletion.
594+
595+
If items do not already contain the TTL attribute, the attacker would also need a permission that updates items (for example dynamodb:UpdateItem) to add the TTL attribute and trigger mass deletions.
596+
597+
First enable TTL on the table, specifying the attribute name to use for expiration:
598+
599+
```bash
600+
aws dynamodb update-time-to-live \
601+
--table-name <TABLE_NAME> \
602+
--time-to-live-specification "Enabled=true, AttributeName=<TTL_ATTRIBUTE_NAME>"
603+
```
604+
605+
Then update items to add the TTL attribute (epoch seconds) so they will expire and be removed:
606+
607+
```bash
608+
aws dynamodb update-item \
609+
--table-name <TABLE_NAME> \
610+
--key '<PRIMARY_KEY_JSON>' \
611+
--update-expression "SET <TTL_ATTRIBUTE_NAME> = :t" \
612+
--expression-attribute-values '{":t":{"N":"<EPOCH_SECONDS_VALUE>"}}'
613+
```
614+
615+
### `dynamodb:RestoreTableFromAwsBackup` & `dynamodb:RestoreTableToPointInTime`
616+
617+
An attacker with dynamodb:RestoreTableFromAwsBackup or dynamodb:RestoreTableToPointInTime permissions can create new tables restored from backups or from point-in-time recovery (PITR) without overwriting the original table. The restored table contains a full image of the data at the selected point, so the attacker can use it to exfiltrate historical information or obtain a complete dump of the database’s past state.
618+
619+
Restore a DynamoDB table from an on-demand backup:
620+
621+
```bash
622+
aws dynamodb restore-table-from-backup \
623+
--target-table-name <NEW_TABLE_NAME> \
624+
--backup-arn <BACKUP_ARN>
625+
```
626+
627+
Restore a DynamoDB table to a point in time (create a new table with the restored state):
628+
629+
```bash
630+
aws dynamodb restore-table-to-point-in-time \
631+
--source-table-name <SOURCE_TABLE_NAME> \
632+
--target-table-name <NEW_TABLE_NAME> \
633+
--use-latest-restorable-time
634+
````
635+
591636
</details>
592637

593638
**Potential Impact:** Continuous, near real-time exfiltration of table changes to an attacker-controlled Kinesis stream without direct read operations on the table.

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,36 @@ Create gateway or interface VPC endpoints to regain outbound access from isolate
114114
aws-vpc-endpoint-egress-bypass.md
115115
{{#endref}}
116116

117+
### `ec2:AuthorizeSecurityGroupIngress`
118+
119+
An attacker with the ec2:AuthorizeSecurityGroupIngress permission can add inbound rules to security groups (for example, allowing tcp:80 from 0.0.0.0/0), thereby exposing internal services to the public Internet or to otherwise unauthorized networks.
120+
121+
```bash
122+
aws ec2 authorize-security-group-ingress --group-id <sg-id> --protocol tcp --port 80 --cidr 0.0.0.0/0
123+
```
124+
125+
# `ec2:ReplaceNetworkAclEntry`
126+
An attacker with ec2:ReplaceNetworkAclEntry (or similar) permissions can modify a subnet’s Network ACLs (NACLs) to make them very permissive — for example allowing 0.0.0.0/0 on critical ports — exposing the entire subnet range to the Internet or to unauthorized network segments. Unlike Security Groups, which are applied per-instance, NACLs are applied at the subnet level, so changing a restrictive NACL can have a much larger blast radius by enabling access to many more hosts.
127+
128+
```bash
129+
aws ec2 replace-network-acl-entry \
130+
--network-acl-id <ACL_ID> \
131+
--rule-number 100 \
132+
--protocol <PROTOCOL> \
133+
--rule-action allow \
134+
--egress <true|false> \
135+
--cidr-block 0.0.0.0/0
136+
```
137+
138+
### `ec2:Delete*`
139+
140+
An attacker with ec2:Delete* and iam:Remove* permissions can delete critical infrastructure resources and configurations — for example key pairs, launch templates/versions, AMIs/snapshots, volumes or attachments, security groups or rules, ENIs/network endpoints, route tables, gateways, or managed endpoints. This can cause immediate service disruption, data loss, and loss of forensic evidence.
141+
142+
One example is deleting a security group:
143+
144+
aws ec2 delete-security-group \
145+
--group-id <SECURITY_GROUP_ID>
146+
117147
### VPC Flow Logs Cross-Account Exfiltration
118148

119149
Point VPC Flow Logs to an attacker-controlled S3 bucket to continuously collect network metadata (source/destination, ports) outside the victim account for long-term reconnaissance.

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-iam-post-exploitation/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,36 @@ aws iam update-server-certificate \
181181
--new-path /prod/
182182
```
183183

184+
### `iam:Delete*`
185+
186+
The IAM wildcard iam:Delete* grants the ability to remove many kinds of IAM resources—users, roles, groups, policies, keys, certificates, MFA devices, policy versions, etc. —and therefore has a very high blast radius: an actor granted iam:Delete* can permanently destroy identities, credentials, policies and related artifacts, remove audit/evidence, and cause service or operational outages. Some examples are
187+
188+
```bash
189+
# Delete a user
190+
aws iam delete-user --user-name <Username>
191+
192+
# Delete a role
193+
aws iam delete-role --role-name <RoleName>
194+
195+
# Delete a managed policy
196+
aws iam delete-policy --policy-arn arn:aws:iam::<ACCOUNT_ID>:policy/<PolicyName>
197+
```
198+
199+
### `iam:EnableMFADevice`
200+
201+
An actor granted the iam:EnableMFADevice action can register an MFA device on an identity in the account, provided the user did not already have one enabled. This can be used to interfere with a user’s access: once an attacker registers an MFA device, the legitimate user may be prevented from signing in because they do not control the attacker-registered MFA.
202+
203+
This denial-of-access attack only works if the user had no MFA registered; if the attacker registers an MFA device for that user, the legitimate user will be locked out of any flows that require that new MFA. If the user already has one or more MFA devices under their control, adding an attacker-controlled MFA does not block the legitimate user — they can continue to authenticate using any MFA they already have.
204+
205+
To enable (register) an MFA device for a user an attacker could run:
206+
```bash
207+
aws iam enable-mfa-device \
208+
--user-name <Username> \
209+
--serial-number arn:aws:iam::111122223333:mfa/alice \
210+
--authentication-code1 123456 \
211+
--authentication-code2 789012
212+
```
213+
184214
## References
185215

186216
- [https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ Lambda uses environment variables to inject credentials at runtime. If you can g
1616

1717
By default, these will have access to write to a cloudwatch log group (the name of which is stored in `AWS_LAMBDA_LOG_GROUP_NAME`), as well as to create arbitrary log groups, however lambda functions frequently have more permissions assigned based on their intended use.
1818

19+
### `lambda:Delete*`
20+
An attacker granted lambda:Delete* can delete Lambda functions, versions/aliases, layers, event source mappings and other associated configurations.
21+
22+
```bash
23+
aws lambda delete-function \
24+
--function-name <LAMBDA_NAME>
25+
```
26+
1927
### Steal Others Lambda URL Requests
2028

2129
If an attacker somehow manage to get RCE inside a Lambda he will be able to steal other users HTTP requests to the lambda. If the requests contain sensitive information (cookies, credentials...) he will be able to steal them.

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-rds-post-exploitation/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,48 @@ aws rds modify-db-instance \
4040
# Connect to the new DB after a few mins
4141
```
4242

43+
### `rds:StopDBCluster` & `rds:StopDBInstance`
44+
An attacker with rds:StopDBCluster or rds:StopDBInstance can force an immediate stop of an RDS instance or an entire cluster, causing database unavailability, broken connections, and interruption of processes that depend on the database.
45+
46+
To stop a single DB instance (example):
47+
48+
```bash
49+
aws rds stop-db-instance \
50+
--db-instance-identifier <DB_INSTANCE_IDENTIFIER>
51+
```
52+
53+
To stop an entire DB cluster (example):
54+
55+
```bash
56+
aws rds stop-db-cluster \
57+
--db-cluster-identifier <DB_CLUSTER_IDENTIFIER>
58+
```
59+
60+
### `rds:Delete*`
61+
62+
An attacker granted rds:Delete* can remove RDS resources, deleting DB instances, clusters, snapshots, automated backups, subnet groups, parameter/option groups and related artifacts, causing immediate service outage, data loss, destruction of recovery points and loss of forensic evidence.
63+
64+
```bash
65+
# Delete a DB instance (creates a final snapshot unless you skip it)
66+
aws rds delete-db-instance \
67+
--db-instance-identifier <DB_INSTANCE_ID> \
68+
--final-db-snapshot-identifier <FINAL_SNAPSHOT_ID> # omit or replace with --skip-final-snapshot to avoid snapshot
69+
70+
# Delete a DB instance and skip final snapshot (more destructive)
71+
aws rds delete-db-instance \
72+
--db-instance-identifier <DB_INSTANCE_ID> \
73+
--skip-final-snapshot
74+
75+
# Delete a manual DB snapshot
76+
aws rds delete-db-snapshot \
77+
--db-snapshot-identifier <DB_SNAPSHOT_ID>
78+
79+
# Delete an Aurora DB cluster (creates a final snapshot unless you skip)
80+
aws rds delete-db-cluster \
81+
--db-cluster-identifier <DB_CLUSTER_ID> \
82+
--final-db-snapshot-identifier <FINAL_CLUSTER_SNAPSHOT_ID> # or use --skip-final-snapshot
83+
```
84+
4385
### `rds:ModifyDBSnapshotAttribute`, `rds:CreateDBSnapshot`
4486

4587
An attacker with these permissions could **create an snapshot of a DB** and make it **publicly** **available**. Then, he could just create in his own account a DB from that snapshot.

src/pentesting-cloud/aws-security/aws-post-exploitation/aws-s3-post-exploitation/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,43 @@ To add further pressure, the attacker schedules the deletion of the KMS key used
3333

3434
Finally, the attacker could upload a final file, usually named "ransom-note.txt," which contains instructions for the target on how to retrieve their files. This file is uploaded without encryption, likely to catch the target's attention and make them aware of the ransomware attack.
3535

36+
### `s3:RestoreObject`
37+
38+
An attacker with the s3:RestoreObject permission can reactivate objects archived in Glacier or Deep Archive, making them temporarily accessible. This enables recovery and exfiltration of historically archived data (backups, snapshots, logs, certifications, old secrets) that would normally be out of reach. If the attacker combines this permission with read permissions (e.g., s3:GetObject), they can obtain full copies of sensitive data.
39+
40+
```bash
41+
aws s3api restore-object \
42+
--bucket <BUCKET_NAME> \
43+
--key <OBJECT_KEY> \
44+
--restore-request '{
45+
"Days": <NUMBER_OF_DAYS>,
46+
"GlacierJobParameters": { "Tier": "Standard" }
47+
}'
48+
```
49+
50+
### `s3:Delete*`
51+
52+
An attacker with the s3:Delete* permission can delete objects, versions, and entire buckets, disrupt backups, and cause immediate and irreversible data loss, destruction of evidence, and compromise of backup or recovery artifacts.
53+
54+
```bash
55+
# Delete an object from a bucket
56+
aws s3api delete-object \
57+
--bucket <BUCKET_NAME> \
58+
--key <OBJECT_KEY>
59+
60+
# Delete a specific version
61+
aws s3api delete-object \
62+
--bucket <BUCKET_NAME> \
63+
--key <OBJECT_KEY> \
64+
--version-id <VERSION_ID>
65+
66+
# Delete a bucket
67+
aws s3api delete-bucket \
68+
--bucket <BUCKET_NAME>
69+
```
70+
71+
72+
3673
**For more info** [**check the original research**](https://rhinosecuritylabs.com/aws/s3-ransomware-part-1-attack-vector/)**.**
3774

3875
{{#include ../../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)