Detection: Detect AWS Console Login by User from New Region

Description

The following analytic identifies AWS console login attempts by users from a new region. It leverages AWS CloudTrail events and compares current login regions against a baseline of previously seen regions for each user. This activity is significant as it may indicate unauthorized access attempts or compromised credentials. If confirmed malicious, an attacker could gain unauthorized access to AWS resources, potentially leading to data breaches, resource manipulation, or further lateral movement within the cloud 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 Region as justSeenRegion 
 6| table firstTime lastTime user justSeenRegion 
 7| join user type=outer [
 8| inputlookup previously_seen_users_console_logins 
 9| rename Region as previouslySeenRegion 
10| stats min(firstTime) AS earliestseen by user previouslySeenRegion 
11| fields earliestseen user previouslySeenRegion] 
12| eval userRegion=if(firstTime >= relative_time(now(), "-24h@h"), "New Region","Previously Seen Region") 
13| where userRegion= "New Region" 
14| `security_content_ctime(firstTime)` 
15| `security_content_ctime(lastTime)` 
16| table firstTime lastTime user previouslySeenRegion justSeenRegion userRegion 
17| `detect_aws_console_login_by_user_from_new_region_filter`

Data Source

Name Platform Sourcetype Source
AWS CloudTrail AWS icon AWS 'aws:cloudtrail' 'aws_cloudtrail'

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_region_filter search *
detect_aws_console_login_by_user_from_new_region_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_region_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 Region $Region$ for the first time 36 60 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: 4