Detection: Detect AWS Console Login by User from New Country

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.

 1
 2| tstats earliest(_time) as firstTime latest(_time) as lastTime from datamodel=Authentication where Authentication.signature=ConsoleLogin by Authentication.user Authentication.src 
 3| iplocation Authentication.src 
 4| `drop_dm_object_name(Authentication)` 
 5| rename Country as justSeenCountry 
 6| table firstTime lastTime user justSeenCountry 
 7| join user type=outer [
 8| inputlookup previously_seen_users_console_logins 
 9| rename Country as previouslySeenCountry 
10| stats min(firstTime) AS earliestseen by user previouslySeenCountry 
11| fields earliestseen user previouslySeenCountry] 
12| eval userCountry=if(firstTime >= relative_time(now(), "-24h@h"), "New Country","Previously Seen Country") 
13| where userCountry = "New Country" 
14| `security_content_ctime(firstTime)` 
15| `security_content_ctime(lastTime)` 
16| table firstTime lastTime user previouslySeenCountry justSeenCountry userCountry 
17| `detect_aws_console_login_by_user_from_new_country_filter`

Data Source

Name Platform Sourcetype Source Supported App
AWS CloudTrail AWS icon AWS 'aws:cloudtrail' 'aws_cloudtrail' N/A

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
detect_aws_console_login_by_user_from_new_country_filter search *
detect_aws_console_login_by_user_from_new_country_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1586 Compromise Accounts Resource Development
T1586.003 Cloud Accounts Resource Development
T1535 Unused/Unsupported Cloud Regions Defense Evasion
KillChainPhase.EXPLOITAITON
KillChainPhase.WEAPONIZATION
NistCategory.DE_AE
Cis18Value.CIS_10
APT29

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Risk Event False
This configuration file applies to all detections of type hunting.

Implementation

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.

Associated Analytic Story

Risk Based Analytics (RBA)

Risk Message Risk Score Impact Confidence
User $user$ is logging into the AWS console from Country $Country$ for the first time 42 70 60
The Risk Score is calculated by the following formula: Risk Score = (Impact * Confidence/100). Initial Confidence and Impact is set by the analytic author.

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset aws_cloudtrail aws:cloudtrail
Integration ✅ Passing Dataset aws_cloudtrail aws:cloudtrail

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub | Version: 3