Detection rules › Splunk
Detect AWS Console Login by User from New Country
The following analytic identifies AWS console login events by users from a new country. It leverages AWS CloudTrail events and compares them against a lookup file of previously seen users and their login locations. This activity is significant because logins from new countries can indicate potential unauthorized access or compromised accounts. If confirmed malicious, this could lead to unauthorized access to AWS resources, data exfiltration, or further exploitation within the AWS environment.
Known false positives
- When a legitimate new user logins for the first time, this activity will be detected. Check how old the account is and verify that the user activity is legitimate.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Resource Development | |
| Stealth |
Rule body
name: Detect AWS Console Login by User from New Country
id: 67bd3def-c41c-4bf6-837b-ae196b4257c6
version: 9
creation_date: '2020-04-29'
modification_date: '2026-05-13'
author: Bhavin Patel, Eric McGinnis Splunk
status: production
type: Hunting
description: The following analytic identifies AWS console login events by users from a new country. It leverages AWS CloudTrail events and compares them against a lookup file of previously seen users and their login locations. This activity is significant because logins from new countries can indicate potential unauthorized access or compromised accounts. If confirmed malicious, this could lead to unauthorized access to AWS resources, data exfiltration, or further exploitation within the AWS environment.
data_source:
- AWS CloudTrail
search: |-
| tstats earliest(_time) as firstTime latest(_time) as lastTime FROM datamodel=Authentication
WHERE Authentication.signature=ConsoleLogin
BY Authentication.user Authentication.src
| iplocation Authentication.src
| `drop_dm_object_name(Authentication)`
| rename Country as justSeenCountry
| table firstTime lastTime user justSeenCountry
| join user type=outer [
| inputlookup previously_seen_users_console_logins
| rename Country as previouslySeenCountry
| stats min(firstTime) AS earliestseen
BY user previouslySeenCountry
| fields earliestseen user previouslySeenCountry]
| eval userCountry=if(firstTime >= relative_time(now(), "-24h@h"), "New Country","Previously Seen Country")
| where userCountry = "New Country"
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| table firstTime lastTime user previouslySeenCountry justSeenCountry userCountry
| `detect_aws_console_login_by_user_from_new_country_filter`
how_to_implement: You must install and configure the Splunk Add-on for AWS (version 5.1.0 or later) and Enterprise Security 6.2, which contains the required updates to the Authentication data model for cloud use cases. Run the `Previously Seen Users in AWS CloudTrail - Initial` support search only once to create a baseline of previously seen IAM users within the last 30 days. Run `Previously Seen Users in AWS CloudTrail - Update` hourly (or more frequently depending on how often you run the detection searches) to refresh the baselines. You can also provide additional filtering for this search by customizing the `detect_aws_console_login_by_user_from_new_country_filter` macro.
known_false_positives: When a legitimate new user logins for the first time, this activity will be detected. Check how old the account is and verify that the user activity is legitimate.
references: []
analytic_story:
- Suspicious AWS Login Activities
- Suspicious Cloud Authentication Activities
- AWS Identity and Access Management Account Takeover
- Compromised User Account
asset_type: AWS Instance
mitre_attack_id:
- T1535
- T1586.003
product:
- Splunk Enterprise
- Splunk Enterprise Security
- Splunk Cloud
category: cloud
security_domain: threat
baselines:
- Previously Seen Users in CloudTrail - Initial
- Previously Seen Users In CloudTrail - Update
Stages and Predicates
Stage 1: tstats
| tstats earliest(_time) as firstTime latest(_time) as lastTime FROM datamodel=Authentication
WHERE Authentication.signature=ConsoleLogin
BY Authentication.user Authentication.src
Stage 2: search
| iplocation Authentication.src
Stage 3: search
| `drop_dm_object_name(Authentication)`
Stage 4: rename
| rename Country as justSeenCountry
Stage 5: table
| table firstTime lastTime user justSeenCountry
Stage 6: join
| join user type=outer [
| inputlookup previously_seen_users_console_logins
| rename Country as previouslySeenCountry
| stats min(firstTime) AS earliestseen
BY user previouslySeenCountry
| fields earliestseen user previouslySeenCountry]
Stage 7: eval
| eval userCountry=if(firstTime >= relative_time(now(), "-24h@h"), "New Country","Previously Seen Country")
userCountry =1.
"New Country"-
"Previously Seen Country"Stage 8: where
| where userCountry = "New Country"
Stage 9: search
| `security_content_ctime(firstTime)`
Stage 10: search
| `security_content_ctime(lastTime)`
Stage 11: table
| table firstTime lastTime user previouslySeenCountry justSeenCountry userCountry
Stage 12: search
| `detect_aws_console_login_by_user_from_new_country_filter`
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
Authentication.signature | eq |
| field:"signature" kind:eq value:"ConsoleLogin" |
userCountry | eq |
| field:"userCountry" kind:eq |
Search terms
These SPL tokens match against raw event text.
| Stage | Term |
|---|---|
| 2 | iplocation |
| 2 | Authentication.src |