You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pentesting-cloud/aws-security/aws-post-exploitation/aws-s3-post-exploitation/README.md
+41-3Lines changed: 41 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,47 @@ To add further pressure, the attacker schedules the deletion of the KMS key used
33
33
34
34
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.
Another variant is abusing **SSE-C** (S3 server-side encryption with **customer-provided keys**). With SSE-C, the **client provides the encryption key on every request** and **AWS does not store the key**. This means that if an attacker rewrites objects using **their own SSE-C key**, the victim's data becomes unreadable unless the victim can provide that attacker-controlled key.
39
+
40
+
-**Preconditions:** Compromised AWS credentials (or any principal with the right permissions) and the ability to **rewrite objects** (e.g., `s3:PutObject` on the target keys/prefixes). This is often paired with the ability to set destructive lifecycle policies (see below), e.g. `s3:PutLifecycleConfiguration`.
41
+
-**Attack chain:**
42
+
1. Attacker generates a random 256-bit key (AES-256) and keeps it.
43
+
2. Attacker **rewrites** existing objects (same object keys) using SSE-C headers so the stored object is now encrypted with the attacker key.
44
+
3. Victim cannot download/decrypt without providing the SSE-C key (even if IAM permissions are fine).
45
+
4. Attacker can delete the key (or simply never provide it) to make data unrecoverable.
46
+
47
+
Example (conceptual) CLI usage:
48
+
49
+
```bash
50
+
# Upload/overwrite an object encrypted with attacker-provided SSE-C key
51
+
aws s3 cp ./file s3://<BUCKET>/<KEY> \
52
+
--sse-c AES256 \
53
+
--sse-c-key <BASE64_32_BYTES>
54
+
55
+
# Download requires providing the same key again
56
+
aws s3 cp s3://<BUCKET>/<KEY> ./file \
57
+
--sse-c AES256 \
58
+
--sse-c-key <BASE64_32_BYTES>
59
+
```
60
+
61
+
##### Adding Pressure: Lifecycle "Timer" Abuse
62
+
63
+
To remove recovery options (like old versions), attackers can pair SSE-C rewrites with **lifecycle rules** that expire objects and/or delete noncurrent versions after a short period:
64
+
65
+
-`s3:PutLifecycleConfiguration` on the bucket lets an attacker schedule deletions without issuing explicit delete operations for every object/version.
66
+
- This is especially impactful when **versioning is enabled**, because it can remove the "previous good version" that would otherwise allow recovery.
67
+
68
+
##### Detection & Mitigations
69
+
70
+
- Prefer **SSE-KMS** (or SSE-S3) over SSE-C unless you have a strong operational reason to allow SSE-C.
71
+
- Monitor/alert on `PutObject` requests using SSE-C headers (CloudTrail data events for S3).
72
+
- Monitor/alert on unexpected `PutBucketLifecycleConfiguration` (lifecycle changes).
73
+
- Monitor/alert on sudden spikes in overwrite activity (same keys updated rapidly) and delete-marker/version deletions.
74
+
- Restrict high-risk permissions: Limit `s3:PutObject` to necessary prefixes; strongly restrict `s3:PutLifecycleConfiguration` and `s3:PutBucketVersioning`; consider requiring MFA for sensitive admin actions (where applicable) and use separate admin roles with approvals.
75
+
- Recovery posture: Use **versioning**, **backups**, and immutable/offline copies (S3 replication to protected account, backup vaults, etc.); protect noncurrent versions from aggressive deletion and guard lifecycle changes with SCPs / guardrails.
76
+
36
77
### `s3:RestoreObject`
37
78
38
79
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.
0 commit comments