EXPLORE
← Back to Explore
elasticmediumTTP

AWS IAM Virtual MFA Device Registration Attempt with Session Token

Detects attempts to create or enable a Virtual MFA device (CreateVirtualMFADevice, EnableMFADevice) using temporary AWS credentials (access keys beginning with ASIA). Session credentials are short-lived and tied to existing authenticated sessions, so using them to register or enable MFA devices is unusual. Adversaries who compromise temporary credentials may abuse this behavior to establish persistence by attaching new MFA devices to maintain access to high-privilege accounts despite key rotation or password resets.

Detection Query

iam where data_stream.dataset == "aws.cloudtrail"
  and event.provider == "iam.amazonaws.com"
  and event.outcome == "success"
  and event.action in ("CreateVirtualMFADevice", "EnableMFADevice")
  and startsWith (aws.cloudtrail.user_identity.access_key_id, "ASIA")
  and not aws.cloudtrail.session_credential_from_console == "true"

Author

Elastic

Created

2025/04/11

Data Sources

AWSAmazon Web ServicesAWS CloudTrailAWS IAMlogs-aws.cloudtrail-*

Tags

Domain: CloudData Source: AWSData Source: Amazon Web ServicesData Source: AWS CloudTrailData Source: AWS IAMTactic: PersistenceUse Case: Identity and Access AuditResources: Investigation Guide
Raw Content
[metadata]
creation_date = "2025/04/11"
integration = ["aws"]
maturity = "production"
min_stack_version = "9.2.0"
min_stack_comments = "aws.cloudtrail.session_credential_from_console field introduced in AWS integration version 4.6.0"
updated_date = "2026/04/10"

[rule]
author = ["Elastic"]
description = """
Detects attempts to create or enable a Virtual MFA device (CreateVirtualMFADevice, EnableMFADevice) using temporary AWS
credentials (access keys beginning with ASIA). Session credentials are short-lived and tied to existing authenticated
sessions, so using them to register or enable MFA devices is unusual. Adversaries who compromise temporary credentials
may abuse this behavior to establish persistence by attaching new MFA devices to maintain access to high-privilege
accounts despite key rotation or password resets.
"""
false_positives = [
    """
    Some legitimate administrative workflows or CI/CD automation pipelines may temporarily configure or re-enable MFA
    devices using session-based credentials. Validate the calling identity’s purpose, source IP, and user agent to
    confirm whether this activity was authorized. This rule automatically excludes console login sessions, which filters out expected MFA operations performed via the
    AWS Management Console.
    """,
]
from = "now-6m"
index = ["logs-aws.cloudtrail-*"]
language = "eql"
license = "Elastic License v2"
name = "AWS IAM Virtual MFA Device Registration Attempt with Session Token"
note = """## Triage and Analysis

### Investigating AWS IAM Virtual MFA Device Registration Attempt with Session Token

Temporary credentials that start with the prefix `ASIA` are generated by the AWS Security Token Service (STS). These
session tokens are used for short-lived operations and should not be used to modify or register IAM
authentication mechanisms. This rule detects cases where an IAM user or role uses such temporary credentials to invoke either `CreateVirtualMFADevice` or `EnableMFADevice`.

### Possible investigation steps

- **Identify the actor and session context**
  - Review `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.access_key_id` to determine the identity and confirm the `ASIA` prefix.  
  - This rule automatically filters out console login sessions using `aws.cloudtrail.session_credential_from_console`, so alerts indicate non-console temporary credential usage.
  - Check `user_agent.original`, `source.ip`, and `cloud.region` to determine if this activity originated from an expected host, VPN, or location.
  - Cross-reference with prior activity by this identity—especially `GetSessionToken`, `AssumeRole`, or `GetCallerIdentity` calls.

- **Correlate related IAM events**
  - Search for subsequent or preceding calls to:
    - `EnableMFADevice` (after `CreateVirtualMFADevice`)
    - `DeactivateMFADevice` or `DeleteVirtualMFADevice`
    - `ListMFADevices`, `ListUsers`, or `UpdateLoginProfile`
  - Review whether new MFA devices were successfully enabled (`event.outcome:success`).

- **Assess session scope and privileges**
  - Identify what IAM policies are attached to the user or role that issued this request.  
  - If the temporary credentials were created via `AssumeRole` or `GetSessionToken`, check the originating principal’s permissions.

- **Investigate possible persistence**
  - Look for new MFA devices listed for privileged users (e.g., account root or admin roles).  
  - Review login history for those accounts following the MFA change. 

### False positive analysis

- **Legitimate Administrative or Automated Actions**  
  Certain IAM administrative workflows or CI/CD automation tools may register or enable MFA devices using temporary
  session credentials. Confirm whether the calling principal is part of an authorized automation process or a known
  identity performing account configuration tasks.

- **Expected Console Behavior**  
  Console-based MFA operations are automatically filtered out by this rule using the `aws.cloudtrail.session_credential_from_console` field.
  Alerts from this rule indicate MFA operations performed with temporary credentials obtained outside of console login sessions.

### Response and remediation

- **Immediate containment**
  - Revoke or expire the temporary credentials (`aws sts revoke-session` if applicable).  
  - Disable or delete any newly created virtual MFA devices using `DeleteVirtualMFADevice`.  
  - Rotate passwords and long-term access keys for the associated IAM users.

- **Investigation and scoping**
  - Review CloudTrail logs for related IAM modifications (`UpdateLoginProfile`, `AttachUserPolicy`, `CreateAccessKey`).  
  - Identify any new API keys or tokens created after the MFA registration.  
  - Cross-check whether the attacker leveraged the new MFA binding for session persistence or login.

- **Recovery and hardening**
  - Enforce the `iam:EnableMFADevice` and `iam:CreateVirtualMFADevice` permissions only for trusted admin roles.  
  - Implement `aws:MultiFactorAuthPresent` conditions in IAM policies.  
  - Monitor for any future `ASIA` credential–based IAM configuration changes.

### Additional information
- **[AWS IR Playbooks](https://github.com/aws-samples/aws-incident-response-playbooks/blob/c151b0dc091755fffd4d662a8f29e2f6794da52c/playbooks/)** 
- **[AWS Customer Playbook Framework](https://github.com/aws-samples/aws-customer-playbook-framework/tree/a8c7b313636b406a375952ac00b2d68e89a991f2/docs)** 
- **[Managing MFA Devices in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa.html)** 
"""
references = ["https://www.sygnia.co/blog/sygnia-investigation-bybit-hack/"]
risk_score = 47
rule_id = "e4feea34-3b62-4c83-b77f-018fbef48c00"
severity = "medium"
tags = [
    "Domain: Cloud",
    "Data Source: AWS",
    "Data Source: Amazon Web Services",
    "Data Source: AWS CloudTrail",
    "Data Source: AWS IAM",
    "Tactic: Persistence",
    "Use Case: Identity and Access Audit",
    "Resources: Investigation Guide",
]
timestamp_override = "event.ingested"
type = "eql"

query = '''
iam where data_stream.dataset == "aws.cloudtrail"
  and event.provider == "iam.amazonaws.com"
  and event.outcome == "success"
  and event.action in ("CreateVirtualMFADevice", "EnableMFADevice")
  and startsWith (aws.cloudtrail.user_identity.access_key_id, "ASIA")
  and not aws.cloudtrail.session_credential_from_console == "true"
'''


[[rule.threat]]
framework = "MITRE ATT&CK"

[[rule.threat.technique]]
id = "T1078"
name = "Valid Accounts"
reference = "https://attack.mitre.org/techniques/T1078/"

[[rule.threat.technique.subtechnique]]
id = "T1078.004"
name = "Cloud Accounts"
reference = "https://attack.mitre.org/techniques/T1078/004/"

[[rule.threat.technique]]
id = "T1098"
name = "Account Manipulation"
reference = "https://attack.mitre.org/techniques/T1098/"

[[rule.threat.technique.subtechnique]]
id = "T1098.005"
name = "Device Registration"
reference = "https://attack.mitre.org/techniques/T1098/005/"

[[rule.threat.technique]]
id = "T1556"
name = "Modify Authentication Process"
reference = "https://attack.mitre.org/techniques/T1556/"

[[rule.threat.technique.subtechnique]]
id = "T1556.006"
name = "Multi-Factor Authentication"
reference = "https://attack.mitre.org/techniques/T1556/006/"

[rule.threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"
[rule.investigation_fields]
field_names = [
    "@timestamp",
    "user.name",
    "user_agent.original",
    "source.ip",
    "aws.cloudtrail.user_identity.arn",
    "aws.cloudtrail.user_identity.type",
    "aws.cloudtrail.user_identity.access_key_id",
    "event.action",
    "event.outcome",
    "cloud.account.id",
    "cloud.region",
    "aws.cloudtrail.request_parameters",
    "aws.cloudtrail.response_elements",
]