-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/edyesed/box_helpers_caseimmutable' of https://githu…
…b.com/panther-labs/panther-analysis into fix/edyesed/box_helpers_caseimmutable
- Loading branch information
Showing
15 changed files
with
1,130 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
rules/aws_cloudtrail_rules/aws_ec2_startup_script_change.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from panther_base_helpers import aws_rule_context, deep_get | ||
|
||
|
||
def rule(event): | ||
if event.get("eventName") == "ModifyInstanceAttribute" and deep_get( | ||
event, "requestParameters", "userData" | ||
): | ||
return True | ||
return False | ||
|
||
|
||
def title(event): | ||
return ( | ||
"Startup script for instance" | ||
f" [{deep_get(event, 'requestParameters', 'instanceId')}] " | ||
"was modified." | ||
) | ||
|
||
|
||
def dedup(event): | ||
return deep_get(event, "requestParameters", "instanceId") | ||
|
||
|
||
def alert_context(event): | ||
return aws_rule_context(event) |
71 changes: 71 additions & 0 deletions
71
rules/aws_cloudtrail_rules/aws_ec2_startup_script_change.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
AnalysisType: rule | ||
Description: 'Detects changes to the EC2 instance startup script. The shell script will be executed as root/SYSTEM every time the specific instances are booted up.' | ||
DisplayName: AWS EC2 Startup Script Change | ||
Enabled: true | ||
Filename: aws_ec2_startup_script_change.py | ||
Reports: | ||
MITRE ATT&CK: | ||
- TA0002:T1059 | ||
Severity: High | ||
Tests: | ||
- ExpectedResult: true | ||
Log: | ||
awsregion: us-east-1 | ||
eventid: abc-123 | ||
eventname: ModifyInstanceAttribute | ||
eventsource: ec2.amazonaws.com | ||
eventtime: "2022-07-17 04:50:23" | ||
eventtype: AwsApiCall | ||
eventversion: "1.08" | ||
p_any_aws_instance_ids: | ||
- testinstanceid | ||
p_event_time: "2022-07-17 04:50:23" | ||
p_log_type: AWS.CloudTrail | ||
p_parse_time: "2022-07-17 04:55:11.788" | ||
requestParameters: | ||
instanceId: testinstanceid | ||
userData: <scripthere> | ||
Name: ModifyInstanceAttributeUserdata | ||
- ExpectedResult: false | ||
Log: | ||
awsregion: us-east-1 | ||
eventid: abc-123 | ||
eventname: ModifyInstanceAttribute | ||
eventsource: ec2.amazonaws.com | ||
eventtime: "2022-07-17 04:50:23" | ||
eventtype: AwsApiCall | ||
eventversion: "1.08" | ||
p_any_aws_instance_ids: | ||
- testinstanceid | ||
p_event_time: "2022-07-17 04:50:23" | ||
p_log_type: AWS.CloudTrail | ||
p_parse_time: "2022-07-17 04:55:11.788" | ||
requestParameters: | ||
instanceId: testinstanceid | ||
instanceType: | ||
value: t3.nano | ||
Name: ModifyInstanceAttribute-NoUserData | ||
- ExpectedResult: false | ||
Log: | ||
awsregion: us-east-1 | ||
eventid: abc-123 | ||
eventname: ModifyImageAttribute | ||
eventsource: ec2.amazonaws.com | ||
eventtime: "2022-07-17 04:50:23" | ||
eventtype: AwsApiCall | ||
eventversion: "1.08" | ||
p_any_aws_instance_ids: | ||
- testinstanceid | ||
p_event_time: "2022-07-17 04:50:23" | ||
p_log_type: AWS.CloudTrail | ||
p_parse_time: "2022-07-17 04:55:11.788" | ||
requestParameters: | ||
instanceId: testinstanceid | ||
instanceType: | ||
value: t3.nano | ||
Name: NoModifyInstanceAttribute | ||
DedupPeriodMinutes: 60 | ||
LogTypes: | ||
- AWS.CloudTrail | ||
RuleID: AWS.EC2.Startup.Script.Change | ||
Threshold: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from panther_base_helpers import aws_rule_context | ||
|
||
IPSET_ACTIONS = ["CreateIPSet", "UpdateIPSet"] | ||
|
||
|
||
def rule(event): | ||
if ( | ||
event.get("eventSource", "") == "guardduty.amazonaws.com" | ||
or event.get("eventSource", "") == "wafv2.amazonaws.com" | ||
): | ||
if event.get("eventName", "") in IPSET_ACTIONS: | ||
return True | ||
return False | ||
|
||
|
||
def title(event): | ||
return "IPSet was modified in " f"[{event.get('recepientAccountId','')}]" | ||
|
||
|
||
def alert_context(event): | ||
return aws_rule_context(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
AnalysisType: rule | ||
Description: 'Detects creation and updates of the list of trusted IPs used by GuardDuty and WAF. Potentially to disable security alerts against malicious IPs.' | ||
DisplayName: AWS Trusted IPSet Modified | ||
Enabled: true | ||
Filename: aws_ipset_modified.py | ||
Reports: | ||
MITRE ATT&CK: | ||
- TA0005:T1562 | ||
Severity: High | ||
Tests: | ||
- ExpectedResult: true | ||
Log: | ||
awsregion: us-east-1 | ||
eventid: abc-123 | ||
eventname: CreateIPSet | ||
eventsource: guardduty.amazonaws.com | ||
eventtime: "2022-07-17 04:50:23" | ||
eventtype: AwsApiCall | ||
eventversion: "1.08" | ||
p_any_aws_instance_ids: | ||
- testinstanceid | ||
p_event_time: "2022-07-17 04:50:23" | ||
p_log_type: AWS.CloudTrail | ||
p_parse_time: "2022-07-17 04:55:11.788" | ||
Name: CreateIPSet Event | ||
- ExpectedResult: true | ||
Log: | ||
awsregion: us-east-1 | ||
eventid: abc-123 | ||
eventname: CreateIPSet | ||
eventsource: guardduty.amazonaws.com | ||
eventtime: "2022-07-17 04:50:23" | ||
eventtype: AwsApiCall | ||
eventversion: "1.08" | ||
p_any_aws_instance_ids: | ||
- testinstanceid | ||
p_event_time: "2022-07-17 04:50:23" | ||
p_log_type: AWS.CloudTrail | ||
p_parse_time: "2022-07-17 04:55:11.788" | ||
Name: UpdateIPSet | ||
- ExpectedResult: false | ||
Log: | ||
awsregion: us-east-1 | ||
eventid: abc-123 | ||
eventname: ModifyInstanceAttributes | ||
eventsource: guardduty.amazonaws.com | ||
eventtime: "2022-07-17 04:50:23" | ||
eventtype: AwsApiCall | ||
eventversion: "1.08" | ||
p_any_aws_instance_ids: | ||
- testinstanceid | ||
p_event_time: "2022-07-17 04:50:23" | ||
p_log_type: AWS.CloudTrail | ||
p_parse_time: "2022-07-17 04:55:11.788" | ||
Name: NotIPSet | ||
DedupPeriodMinutes: 60 | ||
LogTypes: | ||
- AWS.CloudTrail | ||
RuleID: AWS.IPSet.Modified | ||
Threshold: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from panther_base_helpers import deep_get | ||
|
||
|
||
def rule(event): | ||
return ( | ||
event.get("eventName") == "ModifyDBInstance" | ||
and event.get("eventSource") == "rds.amazonaws.com" | ||
and bool(deep_get(event, "responseElements", "pendingModifiedValues", "masterUserPassword")) | ||
) | ||
|
||
|
||
def title(event): | ||
return ( | ||
f"RDS Master Password Updated on [{deep_get(event, 'responseElements', 'dBInstanceArn')}]" | ||
) |
Oops, something went wrong.