LoFP LoFP / it's possible that a new user will start to modify ec2 instances when they haven't before for any number of reasons. verify with the user that is modifying instances that this is the intended behavior.

Techniques

Sample rules

EC2 Instance Modified With Previously Unseen User

Description

This search looks for EC2 instances being modified by users who have not previously modified them. This search is deprecated and have been translated to use the latest Change Datamodel.

Detection logic

`cloudtrail` `ec2_modification_api_calls` [search `cloudtrail` `ec2_modification_api_calls` errorCode=success 
| stats earliest(_time) as firstTime latest(_time) as lastTime by userIdentity.arn 
| rename userIdentity.arn as arn 
| inputlookup append=t previously_seen_ec2_modifications_by_user 
| stats min(firstTime) as firstTime, max(lastTime) as lastTime by arn 
| outputlookup previously_seen_ec2_modifications_by_user 
| eval newUser=if(firstTime >= relative_time(now(), "-70m@m"), 1, 0) 
| where newUser=1 
| `security_content_ctime(firstTime)` 
| `security_content_ctime(lastTime)` 
| rename arn as userIdentity.arn 
| table userIdentity.arn] 
| spath output=dest responseElements.instancesSet.items{}.instanceId 
| spath output=user userIdentity.arn 
| table _time, user, dest 
| `ec2_instance_modified_with_previously_unseen_user_filter`

Cloud Instance Modified By Previously Unseen User

Description

The following analytic identifies cloud instances being modified by users who have not previously modified them. It leverages data from the Change data model, focusing on successful modifications of EC2 instances. This activity is significant because it can indicate unauthorized or suspicious changes by potentially compromised or malicious users. If confirmed malicious, this could lead to unauthorized access, configuration changes, or potential disruption of cloud services, posing a significant risk to the organization’s cloud infrastructure.

Detection logic


| tstats `security_content_summariesonly` count earliest(_time) as firstTime, latest(_time) as lastTime values(All_Changes.object_id) as object_id values(All_Changes.command) as command from datamodel=Change where All_Changes.action=modified All_Changes.change_type=EC2 All_Changes.status=success by All_Changes.user 
| `drop_dm_object_name("All_Changes")` 
| lookup previously_seen_cloud_instance_modifications_by_user user as user OUTPUTNEW firstTimeSeen, enough_data 
| eventstats max(enough_data) as enough_data 
| where enough_data=1 
| eval firstTimeSeenUser=min(firstTimeSeen) 
| where isnull(firstTimeSeenUser) OR firstTimeSeenUser > relative_time(now(), "-24h@h") 
| table firstTime user command object_id count 
| `security_content_ctime(firstTime)` 
| `cloud_instance_modified_by_previously_unseen_user_filter`