Detecting S3 Ransomware via Cross-Account KMS Encryption
Adversaries leverage S3 CopyObject API calls to encrypt data within victim buckets using external, attacker-controlled KMS keys, effectively denying access to the bucket owner.
What's new
- 1. new product Sep 19, 13:27 via elastic
This threat involves the exploitation of S3 bucket permissions where an adversary performs a CopyObject operation on objects in a target bucket while applying server-side encryption using an AWS KMS key located in a different AWS account. By forcing the encryption of these objects with an external key that the bucket owner cannot access, the attacker effectively renders the data unusable, mirroring traditional ransomware tactics within a cloud-native environment. This technique is often a precursor to further destructive activity or extortion. Defenders must differentiate these malicious events from legitimate cross-account data governance or migration workflows, which may involve centralized encryption accounts. The activity is particularly dangerous if object versioning is disabled, as the original unencrypted or differently encrypted data may be overwritten during the copy process.
Attack Chain
- Attacker performs reconnaissance to identify S3 buckets with overly permissive bucket policies or IAM roles with
s3:PutObjectpermissions. - Attacker enumerates accessible objects using
ListObjectsV2orGetObjectcalls. - Attacker gains access to an external AWS account and creates or identifies a target-ready KMS key.
- Attacker executes the
CopyObjectAPI call targeting the victim bucket, specifying the external KMS key via thex-amz-server-side-encryption-aws-kms-key-idrequest parameter. - S3 processes the
CopyObjectrequest, re-encrypting the data with the attacker-controlled KMS key. - Victim bucket owner attempts to access the object but fails due to lack of decrypt permissions on the external KMS key.
- Attacker potentially proceeds to delete original object versions (if versioning is enabled) or demands ransom for the KMS key access.
Impact
The impact of this activity is the complete loss of data availability for the targeted S3 objects. If applied at scale, this technique can effectively neutralize entire buckets of data. If object versioning is disabled, the original data is overwritten and potentially unrecoverable, leading to significant operational disruption and data loss. This technique targets organizations using misconfigured cross-account IAM or S3 bucket policies.
Recommendation
- Enable S3 data event logging in AWS CloudTrail to capture
CopyObjectoperations for all critical buckets. - Implement monitoring to alert on
CopyObjectevents where thekms_key_account_iddoes not match the bucket owner'scloud.account.id. - Audit IAM roles and S3 bucket policies for overly permissive
s3:PutObjectaccess and ensure no unnecessary external accounts have write access. - Enforce AWS Service Control Policies (SCPs) that restrict KMS usage to explicitly approved AWS accounts.
- Enable S3 bucket versioning to ensure that objects can be restored if they are overwritten by malicious
CopyObjectoperations.
Immediate actions
Enable S3 data event logging for CopyObject in CloudTrail
Threat Hunt
Search for CopyObject events where the KMS key account ID differs from the bucket account ID
Data: CloudTrail S3 data events
Mitigations
Enable S3 bucket versioning for critical buckets
T1486