1. Resources
  2. Detection rules
  3. Exposed Access Key Quarantined by AWS, or the Quarantine Removed

Exposed Access Key Quarantined by AWS, or the Quarantine Removed detection rules

When AWS learns that an IAM user's access key is exposed, it attaches a quarantine policy to the user. The attachment means the key has leaked, and whoever detaches the policy gives a key that is still exposed its full permissions back.

Platform
AWS
Severity
Medium
Log source
AWS CloudTrail
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
A long-term access key of an IAM user that was published or leaked, and for the removal a second identity that may detach policies from that user.
Impact
Use of the exposed key for everything the quarantine policy does not deny, and the user's full permissions again once the policy is detached.
Response
Set every access key of the user to inactive and leave the quarantine policy attached until the keys are replaced and the activity has been reviewed.
Mitigation
Replace long-term access keys with roles and temporary credentials, and deny the detachment of the quarantine policies to everyone except the response team.
CloudTrail events
AttachUserPolicyAttachGroupPolicyAttachRolePolicyDetachUserPolicyDetachGroupPolicyDetachRolePolicy

How the attack works

Long-term access keys end up in public code repositories, container images and shared files, where anyone can find and use them. When AWS learns that the credentials of an IAM user are compromised or publicly exposed, it attaches an AWS managed policy named AWSCompromisedKeyQuarantineV2 or AWSCompromisedKeyQuarantineV3 to that user and opens a support case with instructions. The policy denies a fixed list of actions, among them launching EC2 instances and the IAM calls that create users, access keys, roles and policy attachments. AWS describes its aim as limiting the damage from fraud that leads to unauthorized charges without affecting existing resources. It is a brake and not containment, because actions that are not on the list stay possible with the leaked key.

The attachment is one of the clearest signals an account can get that a key is in the wrong hands. It arrives in CloudTrail as an AttachUserPolicy event with the policy ARN in requestParameters.policyArn. The opposite event matters as much. The quarantine policy denies iam:DetachUserPolicy, so the quarantined user cannot remove it with the exposed key. An attacker who has reached a second identity with IAM write access can, and so can an administrator who only wants a broken application to work again. In both cases a key that is still exposed gets its full permissions back.

What an attacker needs

  • A long-term access key of an IAM user that was published or leaked, for example in a public code repository.
  • To use the key in full again after the quarantine, a second identity that is allowed to call iam:DetachUserPolicy on the quarantined user.

Impact

Until the key is deactivated, whoever found it can act as the IAM user with everything the quarantine policy does not deny. Once the policy is detached, the user's full permissions are back, including the calls AWS blocked to prevent new credentials and new compute at the owner's expense.

Detection rules

AWS Compromised Key Quarantine Policy Attached

Detects AttachUserPolicy, AttachGroupPolicy and AttachRolePolicy calls whose requestParameters.policyArn names an AWS managed policy that starts with AWSCompromisedKeyQuarantine (V2, V3 and later versions with the same name). AWS describes these policies as applied by AWS when the credentials of an IAM user have been compromised or exposed publicly, so the event means that an access key of the user named in requestParameters.userName has leaked. The policy denies a list of actions and leaves the rest possible: deactivate the keys of the user and follow the support case AWS opened. AWS does not document which identity appears as the caller, so the rule does not depend on it. A response team that attaches the policy by hand produces the same event. It also matches attempts that failed (errorCode present): check errorCode.

LevelHighStatusExperimentalLog sourceAWS CloudTrail
title: AWS Compromised Key Quarantine Policy Attached
id: 19bd3dad-fe94-489c-becd-2dc80d951a24
status: experimental
description: >-
  Detects AttachUserPolicy, AttachGroupPolicy and AttachRolePolicy calls
  whose requestParameters.policyArn names an AWS managed policy that starts
  with AWSCompromisedKeyQuarantine (V2, V3 and later versions with the same
  name). AWS describes these policies as applied by AWS when the credentials
  of an IAM user have been compromised or exposed publicly, so the event
  means that an access key of the user named in requestParameters.userName
  has leaked. The policy denies a list of actions and leaves the rest
  possible: deactivate the keys of the user and follow the support case AWS
  opened. AWS does not document which identity appears as the caller, so the
  rule does not depend on it. A response team that attaches the policy by
  hand produces the same event.
  It also matches attempts that failed (errorCode present): check errorCode.
references:
  - https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCompromisedKeyQuarantineV3.html
  - https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCompromisedKeyQuarantineV2.html
  - https://docs.aws.amazon.com/IAM/latest/APIReference/API_AttachUserPolicy.html
  - https://attack.mitre.org/techniques/T1078/004/
author: Forestall
date: 2026-11-18
tags:
  - attack.initial-access
  - attack.t1078.004
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: iam.amazonaws.com
    eventName:
      - AttachUserPolicy
      - AttachGroupPolicy
      - AttachRolePolicy
    requestParameters.policyArn|contains: ':policy/AWSCompromisedKeyQuarantine'
  condition: selection
falsepositives:
  - A response team that attaches the quarantine policy to a user on its own initiative, for example during an exercise or after finding a leaked key before AWS did. The key is exposed in that case as well, so the alert stands.
level: high

False positives

  • A response team that attaches the quarantine policy to a user on its own initiative, for example during an exercise or after finding a leaked key before AWS did. The key is exposed in that case as well, so the alert stands.

AWS Compromised Key Quarantine Policy Detached

Detects DetachUserPolicy, DetachGroupPolicy and DetachRolePolicy calls whose requestParameters.policyArn names an AWS managed policy that starts with AWSCompromisedKeyQuarantine. Detaching the policy gives the identity its full permissions back. AWS writes in the description of the policy that it must not be removed and that the instructions in the support case are to be followed instead. The quarantine policy denies iam:DetachUserPolicy to the quarantined user, so the call comes from another identity: check the caller in userIdentity.arn, and whether every access key of the user in requestParameters.userName had been deactivated or deleted before the policy was removed. It also matches attempts that failed (errorCode present): a denied attempt made with the exposed key itself is worth seeing.

LevelHighStatusExperimentalLog sourceAWS CloudTrail
title: AWS Compromised Key Quarantine Policy Detached
id: 9e2f2829-1ef6-41cb-bc9d-7ef7dd0f1d0b
status: experimental
description: >-
  Detects DetachUserPolicy, DetachGroupPolicy and DetachRolePolicy calls
  whose requestParameters.policyArn names an AWS managed policy that starts
  with AWSCompromisedKeyQuarantine. Detaching the policy gives the identity
  its full permissions back. AWS writes in the description of the policy
  that it must not be removed and that the instructions in the support case
  are to be followed instead. The quarantine policy denies
  iam:DetachUserPolicy to the quarantined user, so the call comes from
  another identity: check the caller in userIdentity.arn, and whether every
  access key of the user in requestParameters.userName had been deactivated
  or deleted before the policy was removed.
  It also matches attempts that failed (errorCode present): a denied attempt
  made with the exposed key itself is worth seeing.
references:
  - https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCompromisedKeyQuarantineV3.html
  - https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCompromisedKeyQuarantineV2.html
  - https://docs.aws.amazon.com/IAM/latest/APIReference/API_DetachUserPolicy.html
  - https://attack.mitre.org/techniques/T1078/004/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.persistence
  - attack.t1078.004
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: iam.amazonaws.com
    eventName:
      - DetachUserPolicy
      - DetachGroupPolicy
      - DetachRolePolicy
    requestParameters.policyArn|contains: ':policy/AWSCompromisedKeyQuarantine'
  condition: selection
falsepositives:
  - The response team removing the policy at the end of an incident, after the exposed keys were deleted and the activity was reviewed. Confirm that this happened in that order.
level: high

False positives

  • The response team removing the policy at the end of an incident, after the exposed keys were deleted and the activity was reviewed. Confirm that this happened in that order.

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.

Quarantined user still active from an address its keys never used

Detection hypothesisSequence of eventsNeeds a baseline

The attachment says that the key leaked. Whether someone is using it shows in what the user does next: calls that are denied, and calls from addresses the keys of the user never came from before.

  1. An AttachUserPolicy event from iam.amazonaws.com whose requestParameters.policyArn contains AWSCompromisedKeyQuarantine. Note the user in requestParameters.userName.
  2. From that moment on, collect the events whose userIdentity.userName is that user, with userIdentity.accessKeyId, sourceIPAddress and errorCode.
  3. Alert on events that carry an access denied errorCode, and on any event from a source address that the keys of the user did not use in the weeks before the attachment.

EventsAttachUserPolicy

LimitsThe application that owns the key keeps calling until the key is replaced, and its own calls can be denied by the quarantine as well, so compare the source addresses before you conclude. The search shows nothing once the key is deactivated, which is the reason to deactivate it first.

Triage

  • Identify the user in requestParameters.userName and list its access keys with their last-used data. The policy is attached to the user, and the event does not say which key leaked.
  • Find the support case AWS opened for the event and follow its instructions, as the description of the policy says.
  • Review CloudTrail for what the user's keys did in the days before the attachment, with priority on calls from unfamiliar source addresses and on IAM, EC2 and data access calls.
  • For a detachment, identify the caller (userIdentity.arn). A detachment before the exposed key was deactivated or deleted is premature whoever made it, and a caller outside the response team is a second compromised identity until shown otherwise.

Response

Once the attack is confirmed:

  1. Set every access key of the user to inactive, and delete the keys once you know which applications need a replacement. Leave the quarantine policy attached until that is done, as AWS instructs.
  2. Deny the sessions that were opened with the key. Temporary credentials requested with it stay valid until they expire, so attach a policy to the user that denies requests made with credentials issued before the time of containment (condition key aws:TokenIssueTime).
  3. Review what the user did while the key was exposed and remove what was created, with priority on new users, access keys, roles, login profiles and running resources in every Region.
  4. If the quarantine policy was detached, attach it again, contain the principal that detached it and review what the user did after the detachment.
  5. Find where the key was published, remove it there, and treat every other secret in the same place as exposed.
  6. Issue a new key only if the workload cannot use a role, and confirm in CloudTrail that the old key is no longer used.

Mitigation

  • Replace long-term access keys with roles and temporary credentials wherever possible, and remove the keys that are not used.
  • Scan code repositories, build logs and images for credentials before they are published, and switch on the secret scanning of your code hosting platform.
  • Restrict iam:DetachUserPolicy to identity administrators, and deny the detachment of the quarantine policies with a service control policy for everyone except the response team.
  • Keep the contact details of the account current, so that the support case AWS opens about an exposed key reaches people who act on it.

Frequently asked questions

Is the account safe once AWS has attached the quarantine policy?

No. The policy denies a fixed list of actions, and AWS describes its aim as limiting the damage from fraud that leads to unauthorized charges without affecting existing resources. Actions that are not on the list stay possible with the exposed key. Deactivate the key and follow the instructions in the support case.

Does the CloudTrail event show that AWS made the change?

AWS does not document which identity appears as the caller when it attaches the policy, so the rule does not depend on the caller. It matches the name of the policy in `requestParameters.policyArn`. Treat every attachment of a quarantine policy as real, whoever the caller is, until the key has been dealt with.

Can the quarantined user remove the policy with its own key?

The policy is written to prevent that. Both published versions of the policy deny `iam:DetachUserPolicy` among other IAM actions, so a detachment has to come from another identity. A `DetachUserPolicy` event that names a quarantine policy therefore means that the response team removed it on purpose, or that a second identity is in the wrong hands.

Do the rules cover later versions of the quarantine policy?

Yes, as long as AWS keeps the naming. The rules match policy ARNs that contain `:policy/AWSCompromisedKeyQuarantine`, which covers `AWSCompromisedKeyQuarantineV2`, `AWSCompromisedKeyQuarantineV3` and any later version whose name starts in the same way.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.