AWS Cloud Trail AWS User MFA Modified
Query
AWSCloudTrail
| where EventName in ("CreateVirtualMFADevice", "EnableMFADevice", "DeleteVirtualMFADevice", "DeactivateMFADevice")
| extend
UserName = tostring(todynamic(RequestParameters)["userName"]),
Device = tostring(todynamic(RequestParameters)["serialNumber"])
| invoke AWSIdentityRole()
| project
TimeGenerated,
UserIdentityType,
Identity,
ActorRole,
UserIdentityAccountId,
UserIdentityAccountName,
RecipientAccountId,
RecipientAccountName,
AWSRegion,
SessionCreationDate,
UserIdentityPrincipalid,
UserIdentityArn,
SourceIpAddress,
EventSource,
EventTypeName,
EventName,
ManagementEvent,
ReadOnly,
ErrorCode,
ErrorMessage,
UserName,
Device,
RequestParameters,
ResponseElements,
Resources,
SessionMfaAuthenticated,
UserAgent,
AwsEventIdExplanation
This KQL query is designed to analyze AWS CloudTrail logs, specifically focusing on events related to Multi-Factor Authentication (MFA) devices. Here's a simplified breakdown of what the query does:
-
Data Source: It starts by accessing the
AWSCloudTraillogs. -
Filter Events: It filters the logs to only include events where the
EventNameis one of the following: "CreateVirtualMFADevice", "EnableMFADevice", "DeleteVirtualMFADevice", or "DeactivateMFADevice". These events are related to the creation, enabling, deletion, or deactivation of virtual MFA devices. -
Extract Information: The query extracts additional details from the
RequestParametersfield:UserName: The name of the user involved in the event.Device: The serial number of the MFA device involved.
-
Invoke Function: It uses the
AWSIdentityRole()function to enrich the data with identity-related information. -
Select Columns: Finally, it selects and displays a wide range of columns, including:
TimeGenerated: The time the event was logged.UserIdentityType,Identity,ActorRole, etc.: Various details about the user identity and roles.AWSRegion: The AWS region where the event occurred.EventSource,EventTypeName,EventName: Information about the event type and source.ErrorCode,ErrorMessage: Any error details if applicable.UserName,Device: The extracted user and device information.- Other metadata fields related to the event.
In summary, this query is used to monitor and analyze activities related to MFA devices in AWS, providing detailed information about each relevant event.
Details

Jose Sebastián Canós
Released: March 11, 2024
Tables
Keywords
Operators