AWS KMS Key Policy Updated via PutKeyPolicy
Detection of successful PutKeyPolicy calls on AWS KMS keys to identify potential privilege escalation or unauthorized access by adversaries modifying key policies to decrypt or exfiltrate data.
This rule detects the successful execution of the PutKeyPolicy API call within Amazon Web Services Key Management Service (AWS KMS). The PutKeyPolicy action replaces the entire key policy associated with a KMS key, potentially granting new or expanded permissions to principals. An adversary who gains the ability to modify KMS key policies (kms:PutKeyPolicy) can escalate privileges by adding external accounts or roles, allowing them to decrypt data protected by the key or maintain persistent access even after credential rotation. This activity is crucial to monitor, as it can lead to significant data breaches and unauthorized access to sensitive information. The rule focuses on identifying deviations from expected KMS key policy management practices to detect potentially malicious activity.
Attack Chain
- An attacker compromises an AWS account or obtains IAM credentials with sufficient permissions, including
kms:PutKeyPolicyon a target KMS key. - The attacker uses the compromised credentials to call the
PutKeyPolicyAPI, replacing the existing key policy with a modified version. - The modified key policy grants the attacker’s AWS account, or an external account, permissions to perform cryptographic operations on the key, such as
kms:Decryptorkms:GenerateDataKey. - The attacker utilizes the newly granted permissions to decrypt data encrypted with the KMS key, such as data stored in S3 buckets or EBS volumes.
- The attacker may also grant administrative actions to new identities.
- The attacker exfiltrates the decrypted data to an external location.
- The attacker attempts to cover their tracks by deleting CloudTrail logs or modifying other security configurations.
Impact
Successful exploitation can lead to unauthorized access to sensitive data encrypted with the KMS key, potentially resulting in data breaches, financial loss, and reputational damage. The severity depends on the sensitivity of the data protected by the key and the scope of access granted to the attacker. This can impact organizations across various sectors that rely on AWS KMS for data encryption, potentially affecting millions of records and causing significant operational disruption.
Recommendation
- Deploy the Sigma rule “AWS KMS Key Policy Updated via PutKeyPolicy” to your SIEM and tune for your environment to detect unauthorized modifications to KMS key policies.
- Review the policy document diff in
aws.cloudtrail.request_parametersandaws.cloudtrail.response_elementsto identify unauthorized changes to principals. - Restrict the
kms:PutKeyPolicypermission to break-glass roles only, limiting the potential for unauthorized modifications. - Monitor
iam:AttachRolePolicyandsts:AssumeRoleevents to correlate with potential privilege escalation attempts related to KMS key access. - Restore a known-good KMS policy from backup or IAM/KMS change history to remediate unauthorized modifications.
Detection coverage 2
AWS KMS Key Policy Updated via PutKeyPolicy
mediumDetects successful PutKeyPolicy calls on AWS KMS keys, indicating potential privilege escalation or unauthorized access.
AWS KMS Key Policy Updated with External Principal
highDetects PutKeyPolicy calls that add an external AWS account as a principal with decrypt permissions.
Detection queries are kept inside the platform. Get full rules →