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

Techniques

Sample rules

EC2 Instance Started With Previously Unseen User

Description

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

Detection logic

`cloudtrail` eventName=RunInstances [search `cloudtrail` eventName=RunInstances 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_launches_by_user.csv 
| stats min(firstTime) as firstTime, max(lastTime) as lastTime by arn 
| outputlookup previously_seen_ec2_launches_by_user.csv 
| 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] 
| rename requestParameters.instanceType as instanceType, responseElements.instancesSet.items{}.instanceId as dest, userIdentity.arn as user 
| table _time, user, dest, instanceType 
| `ec2_instance_started_with_previously_unseen_user_filter`