Detection rules › Panther
StopInstance FOLLOWED BY ModifyInstanceAttributes
Identifies when StopInstance and ModifyInstanceAttributes CloudTrail events occur in a short period of time. Since EC2 startup scripts cannot be modified without first stopping the instance, StopInstances should be a signal.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1059 Command and Scripting Interpreter |
Rule body yaml
AnalysisType: correlation_rule
RuleID: "AWS.EC2.StopInstance.FOLLOWED.BY.ModifyInstanceAttributes"
DisplayName: "StopInstance FOLLOWED BY ModifyInstanceAttributes"
Enabled: true
Severity: High
Description: Identifies when StopInstance and ModifyInstanceAttributes CloudTrail events occur in a short period of time. Since EC2 startup scripts cannot be modified without first stopping the instance, StopInstances should be a signal.
Reference: https://unit42.paloaltonetworks.com/malicious-operations-of-exposed-iam-keys-cryptojacking/
Reports:
MITRE ATT&CK:
- TA0002:T1059
Detection:
- Sequence:
- ID: StopInstance
RuleID: AWS.EC2.StopInstances
- ID: StartupScriptChange
RuleID: AWS.EC2.Startup.Script.Change
Transitions:
- ID: StopInstance FOLLOWED BY StartupScriptChange
From: StopInstance
To: StartupScriptChange
WithinTimeFrameMinutes: 90
Match:
- On: p_alert_context.instance_ids
LookbackWindowMinutes: 2160
Schedule:
RateMinutes: 1440
TimeoutMinutes: 5
Tests:
- Name: Instance Stopped, Followed By Script Change
ExpectedResult: true
RuleOutputs:
- ID: StopInstance
Matches:
p_alert_context.instance_ids:
'i-abcdef0123456789a':
- "2024-06-01T10:00:01Z"
- ID: StartupScriptChange
Matches:
p_alert_context.instance_ids:
'i-abcdef0123456789a':
- "2024-06-01T10:01:01Z"
- Name: Instance Stopped, Not Followed By Script Change
ExpectedResult: false
RuleOutputs:
- ID: StopInstance
Matches:
p_alert_context.instance_ids:
'i-abcdef0123456789a':
- "2024-06-01T10:00:01Z"
Detection logic
Stage 1: step StopInstance ordered before $StartupScriptChange
References detection AWS.EC2.StopInstances.
Stage 2: step StartupScriptChange ordered after $StopInstance
References detection AWS.EC2.Startup.Script.Change.