How the attack works
A customer managed KMS key protects whatever is encrypted under it: EBS and RDS snapshots, S3 objects, secrets, parameters. Who may use the key is decided by its key policy, by IAM policies and by grants. PutKeyPolicy replaces the key policy, and a statement in it can name a principal in another account, because cross-account use of a key needs permission in the key policy and an IAM policy in the other account. CreateGrant adds a grant, which AWS describes as a policy instrument that lets a principal use the key in cryptographic operations without any change to the key policy or to IAM policies. A grant has one grantee, and the grantee can be an IAM identity in a different account.
For an attacker this is the step that makes encrypted data usable outside the account. A shared encrypted snapshot or a copied object is worthless without the key, and a principal that has been given Decrypt on the key can read it from anywhere. Because a grant leaves the key policy untouched, it is also the quieter of the two ways.
KMS logs both calls as CloudTrail management events, and AWS publishes example records for them. A PutKeyPolicy event carries the whole policy as a JSON string in requestParameters.policy. A CreateGrant event carries the grantee in requestParameters.granteePrincipal and the permitted operations in requestParameters.operations, and a grant made out to an AWS service with the service principal parameter shows granteeServicePrincipal instead. AWS services create grants all day on behalf of users, so the grant rule here keeps only grants to IAM principals that were not requested through a service. No public incident report was used for this page: it follows what AWS documents about key policies and grants.
What an attacker needs
- Credentials for a principal allowed kms:PutKeyPolicy on the key, or kms:CreateGrant on it. A key administrator role usually has the first, and many workload roles have the second.
- For use from another account, an identity in that account whose own IAM policy allows the KMS operations, which an attacker controls in their own account.
Impact
The admitted principal can use the key for the operations it was given, typically Decrypt and GenerateDataKey, from outside the account. Encrypted snapshots, images and objects that are shared or copied out become readable. The access does not depend on the compromised identity any more and stays until the policy statement is removed or the grant is retired or revoked.
Detection rules
KMS Grant Created Directly for an IAM Principal
Detects CreateGrant events whose grantee is an IAM principal and that were not requested through an AWS service. A grant lets its grantee use the key for the listed operations without any change to the key policy, and the grantee can be an identity in another account. AWS's example record carries the grantee in requestParameters.granteePrincipal, and the KMS API reference says an IAM grantee is given as an ARN, so the rule keeps grantees that start with arn. Grants made out to a service (a service name in granteePrincipal, or the granteeServicePrincipal field) are not matched. Calls that a service made on behalf of a user carry userIdentity.invokedBy and are excluded, because services that encrypt data at rest create such grants all day. The rule cannot tell whether the grantee is in another account: compare the account ID in the grantee ARN with the account that owns the key, and read requestParameters.operations. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.
title: KMS Grant Created Directly for an IAM Principal
id: 67cff064-9664-4bcf-b73f-14cc63d27bd7
status: experimental
description: >-
Detects CreateGrant events whose grantee is an IAM principal and that were
not requested through an AWS service. A grant lets its grantee use the key
for the listed operations without any change to the key policy, and the
grantee can be an identity in another account. AWS's example record
carries the grantee in requestParameters.granteePrincipal, and the KMS API
reference says an IAM grantee is given as an ARN, so the rule keeps
grantees that start with arn. Grants made out to a service (a service name
in granteePrincipal, or the granteeServicePrincipal field) are not
matched. Calls that a service made on behalf of a user carry
userIdentity.invokedBy and are excluded, because services that encrypt
data at rest create such grants all day. The rule cannot tell whether the
grantee is in another account: compare the account ID in the grantee ARN
with the account that owns the key, and read
requestParameters.operations.
It also matches attempts that failed (errorCode present): check errorCode,
because an unauthorized attempt is worth seeing.
references:
- https://docs.aws.amazon.com/kms/latest/developerguide/ct-creategrant.html
- https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateGrant.html
- https://docs.aws.amazon.com/kms/latest/developerguide/grants.html
- https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html
- https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098.003
logsource:
product: aws
service: cloudtrail
detection:
selection:
eventSource: kms.amazonaws.com
eventName: CreateGrant
requestParameters.granteePrincipal|startswith: 'arn:'
filter_service_request:
userIdentity.invokedBy|exists: true
condition: selection and not filter_service_request
falsepositives:
- Applications and scripts that create grants directly as part of their design, for example to hand a worker temporary use of a key. They do it from the same role every time, so add those roles to a filter_* selection on userIdentity.arn once confirmed.
- Grants to an identity in the same account. Compare the account ID in the grantee ARN with the account of the key.
level: medium
False positives
- Applications and scripts that create grants directly as part of their design, for example to hand a worker temporary use of a key. They do it from the same role every time, so add those roles to a filter_* selection on userIdentity.arn once confirmed.
- Grants to an identity in the same account. Compare the account ID in the grantee ARN with the account of the key.
KMS Key Policy Replaced
Detects PutKeyPolicy events, which replace the key policy of a KMS key. A new statement can let a principal in another account use the key, because cross-account use needs permission in the key policy. AWS's example record carries the whole policy as a JSON string in requestParameters.policy and the key in requestParameters.keyId. The rule cannot tell who the new policy admits: read the policy and compare it with the previous one. AWS also documents that sharing a key through AWS Resource Access Manager writes a PutKeyPolicy entry whose requestParameters.policyName is AWS_RAM, and those entries match as well. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.
title: KMS Key Policy Replaced
id: 32ab8bc4-9e1d-4ad4-8f39-f6182c7d47ec
status: experimental
description: >-
Detects PutKeyPolicy events, which replace the key policy of a KMS key. A
new statement can let a principal in another account use the key, because
cross-account use needs permission in the key policy. AWS's example record
carries the whole policy as a JSON string in requestParameters.policy and
the key in requestParameters.keyId. The rule cannot tell who the new
policy admits: read the policy and compare it with the previous one. AWS
also documents that sharing a key through AWS Resource Access Manager
writes a PutKeyPolicy entry whose requestParameters.policyName is AWS_RAM,
and those entries match as well.
It also matches attempts that failed (errorCode present): check errorCode,
because an unauthorized attempt is worth seeing.
references:
- https://docs.aws.amazon.com/kms/latest/developerguide/ct-put-key-policy.html
- https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying-external-accounts.html
- https://aws.amazon.com/blogs/security/how-to-use-aws-iam-access-analyzer-api-to-automate-detection-of-public-access-to-aws-kms-keys/
- https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098.003
logsource:
product: aws
service: cloudtrail
detection:
selection:
eventSource: kms.amazonaws.com
eventName: PutKeyPolicy
condition: selection
falsepositives:
- Infrastructure-as-code pipelines and key administrators that set the policy when a key is created or when a new workload needs it. Add the deployment roles to a filter_* selection on userIdentity.arn and review calls made by anyone else.
- Policies that only remove access or add deny statements also match.
level: medium
False positives
- Infrastructure-as-code pipelines and key administrators that set the policy when a key is created or when a new workload needs it. Add the deployment roles to a filter_* selection on userIdentity.arn and review calls made by anyone else.
- Policies that only remove access or add deny statements also match.
KMS Key Policy Set with a Wildcard Principal
Detects PutKeyPolicy events whose policy, logged as a JSON string in requestParameters.policy, names a wildcard principal ("Principal": "*" or "AWS": "*"). A wildcard principal with an Allow effect and no condition lets any AWS principal use the key for the actions of the statement. The rule reads the policy as text with a regular expression that allows for whitespace around the colon, as in AWS's example record, and for a list of principals that starts with the wildcard. It does not read the Condition element: a wildcard that is narrowed by a condition also matches. A policy that names one specific outside account is not matched, because that needs a list of your own accounts (see the detection logic on the page). It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.
title: KMS Key Policy Set with a Wildcard Principal
id: 04d3b393-2767-4376-b67a-ccc22d28e113
status: experimental
description: >-
Detects PutKeyPolicy events whose policy, logged as a JSON string in
requestParameters.policy, names a wildcard principal ("Principal": "*" or
"AWS": "*"). A wildcard principal with an Allow effect and no condition
lets any AWS principal use the key for the actions of the statement. The
rule reads the policy as text with a regular expression that allows for
whitespace around the colon, as in AWS's example record, and for a list of
principals that starts with the wildcard. It does not read the Condition
element: a wildcard that is narrowed by a condition also matches. A policy
that names one specific outside account is not matched, because that needs
a list of your own accounts (see the detection logic on the page).
It also matches attempts that failed (errorCode present): check errorCode,
because an unauthorized attempt is worth seeing.
references:
- https://docs.aws.amazon.com/kms/latest/developerguide/ct-put-key-policy.html
- https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html
- https://aws.amazon.com/blogs/security/how-to-use-aws-iam-access-analyzer-api-to-automate-detection-of-public-access-to-aws-kms-keys/
- https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
- attack.persistence
- attack.privilege-escalation
- attack.t1098.003
logsource:
product: aws
service: cloudtrail
detection:
selection_event:
eventSource: kms.amazonaws.com
eventName: PutKeyPolicy
selection_wildcard:
requestParameters.policy|re: '"(AWS|Principal)"\s*:\s*\[?\s*"\*"'
condition: selection_event and selection_wildcard
falsepositives:
- Key policies whose wildcard principal is limited by a condition, for example to the caller's account or to requests that come through one AWS service. Read the Condition element of the statement before closing the alert, and add the roles that deploy such policies to a filter_* selection on userIdentity.arn if they do this routinely.
level: high
False positives
- Key policies whose wildcard principal is limited by a condition, for example to the caller's account or to requests that come through one AWS service. Read the Condition element of the statement before closing the alert, and add the roles that deploy such policies to a filter_* selection on userIdentity.arn if they do this routinely.
Detection logic
Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.
Grant or key policy names an account that is not yours
Giving another account the use of a key is one ordinary call, and the event shows the grantee or the whole policy. Whether that account is an attacker's or one of yours is not in the event: it needs your own account list.
- Collect
CreateGrantandPutKeyPolicyevents fromkms.amazonaws.com. The grantee is inrequestParameters.granteePrincipal, and the policy is a JSON string inrequestParameters.policy. - Extract the 12-digit account ID from the grantee ARN, and every account ID from the principals of the policy.
- Compare each ID with the accounts of your organization and the third parties you have approved, and alert when an ID is on neither list.
EventsCreateGrantPutKeyPolicy
LimitsIt needs a current list of your accounts and approved partners. Grants to service principals carry no account ID to compare. A wildcard principal names no account and is covered by a rule on this page.
Triage
- Identify the caller (userIdentity.arn), the source IP address and the user agent, and the key in requestParameters.keyId. Which data is encrypted under this key?
- For PutKeyPolicy, read requestParameters.policy and compare it with the previous policy of the key. Look for new principals, for account IDs that are not yours and for a wildcard principal, and read the Condition of each new statement.
- A PutKeyPolicy event whose requestParameters.policyName is AWS_RAM was written because the key is shared through AWS Resource Access Manager. Find the resource share and who created it.
- For CreateGrant, compare the account ID in requestParameters.granteePrincipal with the account that owns the key, and read requestParameters.operations and requestParameters.constraints.
- Look for what makes the key useful outside the account around the same time, such as a snapshot or image shared with the same account ID.
Response
Once the attack is confirmed:
- Remove the access first. Retire or revoke the grant, or put back a key policy without the statement that admits the outside principal.
- Contain the identity that made the change by deactivating its access keys or revoking its role sessions, and take away its kms:PutKeyPolicy and kms:CreateGrant permissions.
- List the remaining grants and the policy of every key the identity could change, and remove what nobody can explain.
- Find the data that left under this key, such as shared snapshots, shared images and copied objects, and stop the sharing. Treat data that the outside principal could already decrypt as disclosed.
- Re-encrypt sensitive data under a new key when you cannot rule out that copies exist outside the account, and rotate the secrets that were encrypted under the old one.
Mitigation
- Allow kms:PutKeyPolicy only to a small set of key administration roles, and keep key administration separate from key use.
- Allow kms:CreateGrant only where a service integration needs it, and limit it with the condition key
kms:GrantIsForAWSResourceso that principals can create grants only through AWS services. - Do not use a wildcard principal in a key policy without a condition that limits it to your account or organization.
- Review external access to keys with IAM Access Analyzer, which analyzes the key policies and grants applied to a key and reports those that admit an external entity.
Frequently asked questions
Why does the grant rule ignore most CreateGrant events?
AWS services that encrypt data at rest create grants on behalf of users all day, for example when a volume is attached or a repository is created. Those events carry the `userIdentity.invokedBy` field, or name the service as grantee. The rule keeps grants to an IAM principal that were not requested through a service, which is how a person or a script creates one directly.
Does the grant rule tell me that the grantee is in another account?
No. A rule on one event cannot compare the account in the grantee ARN with the account of the key. It fires on every direct grant to an IAM principal. Compare the account ID in `requestParameters.granteePrincipal` with the account that owns the key, or build the comparison described under detection logic.
Is a wildcard principal in a key policy always a public key?
No. Some key policies use a wildcard principal together with a condition that limits the statement to one account or to requests that come through one AWS service. The wildcard rule reads the policy as text and does not read the Condition element, so it also fires on those. Read the conditions of the statement before closing the alert.
Has this been seen in real intrusions?
This page was not written from an incident report. No public report that describes key policy or grant abuse at the audit event level was used. The page follows what AWS documents about key policies, grants and cross-account use of keys, and AWS itself publishes a pattern that watches these two events to find keys with public access.
References
- MITRE ATT&CK T1098.003: Account Manipulation: Additional Cloud Roles
- AWS KMS: PutKeyPolicy CloudTrail log entry
- AWS KMS: CreateGrant CloudTrail log entry
- Grants in AWS KMS
- Allowing users in other accounts to use a KMS key
- AWS KMS API Reference: CreateGrant
- AWS KMS condition keys (kms:GrantIsForAWSResource)
- AWS Security Blog: detect public access to AWS KMS keys with IAM Access Analyzer
- CloudTrail userIdentity element (invokedBy)