AWS - S3 Post Exploitation
Reading time: 4 minutes
tip
AWS 해킹 배우기 및 연습하기:
HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기:
HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
S3
For more information check:
AWS - S3, Athena & Glacier Enum
Sensitive Information
버킷에서 읽을 수 있는 상태로 민감한 정보를 발견할 수 있습니다. 예를 들어, terraform state secrets.
Pivoting
Different platforms could be using S3 to store sensitive assets.
For example, airflow could be storing DAGs code in there, or web pages could be directly served from S3. An attacker with write permissions could modify the code from the bucket to pivot to other platforms, or takeover accounts modifying JS files.
S3 Ransomware
In this scenario, the attacker creates a KMS (Key Management Service) key in their own AWS account or another compromised account. They then make this key accessible to anyone in the world, allowing any AWS user, role, or account to encrypt objects using this key. However, the objects cannot be decrypted.
공격자는 대상 S3 bucket에 대한 쓰기 권한을 획득하기 위해 다양한 방법을 사용합니다. 이는 버킷 설정이 잘못되어 공개되어 있거나 공격자가 AWS 환경 자체에 접근했기 때문일 수 있습니다. 공격자는 보통 PII, PHI, 로그, 백업 등 민감한 정보를 포함한 버킷을 목표로 삼습니다.
버킷이 랜섬웨어 표적이 될 수 있는지 확인하기 위해 공격자는 구성 상태를 점검합니다. 여기에는 S3 Object Versioning이 활성화되어 있는지, **multi-factor authentication delete (MFA delete)**가 활성화되어 있는지 확인하는 것이 포함됩니다. Object Versioning이 활성화되어 있지 않으면 공격자는 진행할 수 있습니다. Object Versioning은 활성화되어 있지만 MFA delete가 비활성화되어 있으면 공격자는 Object Versioning을 비활성화할 수 있습니다. Object Versioning과 MFA delete가 둘 다 활성화되어 있으면 해당 버킷을 랜섬웨어화하기가 더 어려워집니다.
Using the AWS API, the attacker replaces each object in the bucket with an encrypted copy using their KMS key. This effectively encrypts the data in the bucket, making it inaccessible without the key.
더 큰 압박을 위해 공격자는 공격에 사용한 KMS 키의 삭제를 예약할 수 있습니다. 이는 키가 삭제되어 데이터가 영구적으로 손실되기 전에 대상에게 복구할 수 있는 7-day 창을 제공합니다.
마지막으로, 공격자는 보통 "ransom-note.txt"라는 이름의 최종 파일을 업로드하여 대상에게 파일을 되찾는 방법에 대한 지침을 제공할 수 있습니다. 이 파일은 주의를 끌고 랜섬웨어 공격 사실을 알리기 위해 암호화 없이 업로드됩니다.
s3:RestoreObject
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.
aws s3api restore-object \
--bucket <BUCKET_NAME> \
--key <OBJECT_KEY> \
--restore-request '{
"Days": <NUMBER_OF_DAYS>,
"GlacierJobParameters": { "Tier": "Standard" }
}'
s3:Delete*
s3:Delete* 권한을 가진 공격자는 객체, 버전, 전체 버킷을 삭제하고 백업을 중단시켜 즉각적이고 되돌릴 수 없는 데이터 손실을 초래하며 증거를 파괴하고 백업 또는 복구 아티팩트를 손상시킬 수 있습니다.
# Delete an object from a bucket
aws s3api delete-object \
--bucket <BUCKET_NAME> \
--key <OBJECT_KEY>
# Delete a specific version
aws s3api delete-object \
--bucket <BUCKET_NAME> \
--key <OBJECT_KEY> \
--version-id <VERSION_ID>
# Delete a bucket
aws s3api delete-bucket \
--bucket <BUCKET_NAME>
자세한 정보 원본 연구를 확인하세요.
tip
AWS 해킹 배우기 및 연습하기:
HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기:
HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
HackTricks Cloud