Skip to content

Commit 5724e81

Browse files
committed
[Rule Tuning] AWS IAM Virtual MFA Device Rules
### AWS IAM Virtual MFA Device Registration Attempt with Session Token - rule change kql to eql so that I could use startsWith function instead of wildcard for the `ASIA*`, temporary session determination. - there is a known false positive for rules like this. When you login to the AWS console, a temporary session token is created in the back-end so in cloudtrail the token id looks the same (`ASIA*`) as temporary session tokens created by actions like `GetSessionToken` or `AssumeRole`, which is what this rule meant to capture. Our current data source does now allow us to distinguigh between these type of events. However, cloudtrail does provide a field `sessionCredentialFromConsole:true` that I am putting in a request for Integrations to include. This would allow us to exclude Console login sessions from rules like this that look for temporary token abuse. - reduced execution window - updated description, FP and IG - update MITRE mapping - added highlighted fields AWS IAM Deactivation of MFA Device - removed `DeleteVirtualMFADevice` from the scope of this rule. When Deleting an MFA device you must deactivate it first if it is associated with a user. You can also Create an MFA device and then Delete it without it being activated for a particular user. By capturing both Deactivation and Deletion events we have duplicate alerts for the same activity (This duplication of events is seen in telemetry.) We also capture benign instances where un-used MFA devices are deleted (which is a clean-up best practice). By reducing the scope to only `DeactivateMFADevice` actions, we capture the most threat-centric behavior which should be investigated. - reduced execution window - updated Description, FP and IG - added highlighted fields
1 parent f52aedf commit 5724e81

File tree

2 files changed

+196
-70
lines changed

2 files changed

+196
-70
lines changed

rules/integrations/aws/impact_iam_deactivate_mfa_device.toml

Lines changed: 84 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,94 @@
22
creation_date = "2020/05/26"
33
integration = ["aws"]
44
maturity = "production"
5-
updated_date = "2024/10/25"
5+
updated_date = "2025/11/03"
66

77
[rule]
88
author = ["Elastic", "Austin Songer"]
99
description = """
10-
Identifies the deactivation of a specified multi-factor authentication (MFA) device and removes it from association with
11-
the user name for which it was originally enabled. In AWS Identity and Access Management (IAM), a device must be
12-
deactivated before it can be deleted.
10+
Detects the deactivation of a Multi-Factor Authentication (MFA) device in AWS Identity and Access Management (IAM). MFA
11+
provides critical protection against unauthorized access by requiring a second factor for authentication. Adversaries or
12+
compromised administrators may deactivate MFA devices to weaken account protections, disable strong authentication, or
13+
prepare for privilege escalation or persistence. This rule monitors successful DeactivateMFADevice API calls, which
14+
represent the point at which MFA protection is actually removed.
1315
"""
1416
false_positives = [
1517
"""
16-
A MFA device may be deactivated by a system or network administrator. Verify whether the user identity, user agent,
17-
and/or hostname should be making changes in your environment. MFA device deactivations from unfamiliar users or
18-
hosts should be investigated. If known behavior is causing false positives, it can be exempted from the rule.
18+
MFA device deactivation may occur legitimately during device rotation, user offboarding, or troubleshooting. For
19+
example, AWS requires deactivation of an existing MFA device before adding a replacement. These actions are often
20+
performed by administrators following approved change-control processes. To reduce false positives, validate whether
21+
the deactivation aligns with a documented workflow, known device replacement, or expected maintenance window. If
22+
performed outside of expected operational hours, by an unexpected user, or from an unfamiliar source IP, this event
23+
should be investigated for potential credential compromise or unauthorized tampering.
1924
""",
2025
]
21-
from = "now-60m"
26+
from = "now-6m"
2227
index = ["filebeat-*", "logs-aws.cloudtrail-*"]
23-
interval = "10m"
2428
language = "kuery"
2529
license = "Elastic License v2"
2630
name = "AWS IAM Deactivation of MFA Device"
2731
note = """## Triage and analysis
2832
33+
> **Disclaimer**:
34+
> This investigation guide was created using generative AI technology and validated for accuracy and relevance. Always
35+
> tailor the steps to your organization's environment and operational context.
36+
2937
### Investigating AWS IAM Deactivation of MFA Device
3038
31-
Multi-factor authentication (MFA) in AWS is a simple best practice that adds an extra layer of protection on top of your user name and password. With MFA enabled, when a user signs in to an AWS Management Console, they will be prompted for their user name and password (the first factor—what they know), as well as for an authentication code from their AWS MFA device (the second factor—what they have). Taken together, these multiple factors provide increased security for your AWS account settings and resources.
39+
This rule detects successful deactivation of a Virtual MFA device in AWS IAM.
40+
Deactivation removes MFA enforcement from an IAM user, significantly lowering account resilience against credential theft or unauthorized access.
41+
Since MFA devices must be deactivated before deletion, this represents the earliest and most critical opportunity to detect potential account compromise or persistence activity.
3242
3343
For more information about using MFA in AWS, access the [official documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa.html).
3444
35-
This rule looks for the deactivation or deletion of AWS MFA devices. These modifications weaken account security and can lead to the compromise of accounts and other assets.
36-
3745
#### Possible investigation steps
3846
39-
- Identify the user account that performed the action and whether it should perform this kind of action.
40-
- Investigate other alerts associated with the user account during the past 48 hours.
41-
- Contact the account and resource owners and confirm whether they are aware of this activity.
42-
- Check if this operation was approved and performed according to the organization's change management policy.
43-
- If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.
47+
- **Identify the actor and context**
48+
- Review `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.access_key_id` to determine who initiated the deactivation.
49+
- Check whether the actor typically manages MFA or has the IAM permissions to perform such actions.
50+
- Review `user_agent.original` to confirm if the operation was performed via the AWS Console, CLI, or SDK.
51+
52+
- **Review the source and location**
53+
- Investigate `source.ip` and `source.geo` fields for unusual origins or unrecognized locations.
54+
- Determine if this request originated from known automation infrastructure, internal IP ranges, or a personal endpoint.
55+
56+
- **Correlate with other related activity**
57+
- Look for preceding API calls such as `ListMFADevices`, `GetSessionToken`, or `ListUsers`, which may indicate reconnaissance or IAM enumeration.
58+
- Search for subsequent `DeleteVirtualMFADevice` calls to confirm whether the deactivated device was later deleted — a common follow-up action.
59+
- Check for any privilege changes, credential creations (`CreateAccessKey`, `AttachUserPolicy`), or unexpected login attempts following the deactivation.
60+
61+
- **Validate authorization**
62+
- Confirm with IAM or security administrators whether the action was part of an authorized device rotation or remediation.
63+
- If not documented or approved, escalate as a potential credential compromise or persistence attempt.
4464
4565
### False positive analysis
4666
47-
- While this activity can be done by administrators, all users must use MFA. The security team should address any potential benign true positive (B-TP), as this configuration can risk the user and domain.
67+
- **Legitimate device rotation**
68+
- When replacing an MFA device, AWS requires deactivation of the existing device before the new one can be enabled.
69+
- **Administrative maintenance**
70+
- IAM administrators or automation pipelines may deactivate MFA as part of account management or recovery workflows.
4871
4972
### Response and remediation
5073
51-
- Initiate the incident response process based on the outcome of the triage.
52-
- Disable or limit the account during the investigation and response.
53-
- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
54-
- Identify the account role in the cloud environment.
55-
- Assess the criticality of affected services and servers.
56-
- Work with your IT team to identify and minimize the impact on users.
57-
- Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
58-
- Identify any regulatory or legal ramifications related to this activity.
59-
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
60-
- Reactivate multi-factor authentication for the user.
61-
- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
62-
- Implement security best practices [outlined](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
63-
- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
64-
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
65-
66-
## Setup
67-
68-
The AWS Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule."""
74+
- **Containment**
75+
- Re-enable MFA for the affected IAM user (`EnableMFADevice`) or temporarily disable their login access until legitimacy is confirmed.
76+
- Revoke temporary credentials or tokens associated with the actor to prevent further misuse.
77+
78+
- **Investigation and scoping**
79+
- Review CloudTrail history for additional IAM configuration changes or access key creation events tied to the same principal.
80+
- Determine whether sensitive resources were accessed after MFA removal.
81+
- Identify whether multiple users had MFA devices deactivated in a short timeframe — an indicator of broader compromise.
82+
83+
- **Recovery and hardening**
84+
- Require MFA for all privileged IAM users and enforce it using service control policies (SCPs).
85+
- Enable GuardDuty or Security Hub findings for IAM anomaly detection related to account takeover or configuration changes.
86+
87+
### Additional information
88+
- **[AWS IR Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/)**
89+
- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/tree/a8c7b313636b406a375952ac00b2d68e89a991f2/docs)**
90+
- **[DeactivateMFADevice API Reference](https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeactivateMFADevice.html)**
91+
- **[Managing MFA Devices in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa.html)**
92+
"""
6993
references = [
7094
"https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/deactivate-mfa-device.html",
7195
"https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeactivateMFADevice.html",
@@ -77,6 +101,7 @@ tags = [
77101
"Domain: Cloud",
78102
"Data Source: AWS",
79103
"Data Source: Amazon Web Services",
104+
"Data Source: AWS CloudTrail",
80105
"Data Source: AWS IAM",
81106
"Resources: Investigation Guide",
82107
"Tactic: Impact",
@@ -86,7 +111,10 @@ timestamp_override = "event.ingested"
86111
type = "query"
87112

88113
query = '''
89-
event.dataset:aws.cloudtrail and event.provider:iam.amazonaws.com and event.action:(DeactivateMFADevice or DeleteVirtualMFADevice) and event.outcome:success
114+
event.dataset: aws.cloudtrail
115+
and event.provider: iam.amazonaws.com
116+
and event.action: DeactivateMFADevice
117+
and event.outcome: success
90118
'''
91119

92120

@@ -114,7 +142,26 @@ name = "Multi-Factor Authentication"
114142
reference = "https://attack.mitre.org/techniques/T1556/006/"
115143

116144

145+
117146
[rule.threat.tactic]
118147
id = "TA0003"
119148
name = "Persistence"
120149
reference = "https://attack.mitre.org/tactics/TA0003/"
150+
151+
[rule.investigation_fields]
152+
field_names = [
153+
"@timestamp",
154+
"user.name",
155+
"user_agent.original",
156+
"source.ip",
157+
"aws.cloudtrail.user_identity.arn",
158+
"aws.cloudtrail.user_identity.type",
159+
"aws.cloudtrail.user_identity.access_key_id",
160+
"target.entity.id",
161+
"event.action",
162+
"event.outcome",
163+
"cloud.account.id",
164+
"cloud.region",
165+
"aws.cloudtrail.request_parameters",
166+
]
167+

0 commit comments

Comments
 (0)