Detection rules › Panther

CloudTrail EC2 StopInstances

Severity
informational
Log types
AWS.CloudTrail
Tags
panther-signal
Reference
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-file-examples.html
Source
github.com/panther-labs/panther-analysis

A CloudTrail instances were stopped. It makes further changes of instances possible

Rule body yaml

AnalysisType: rule
RuleID: "AWS.EC2.StopInstances"
DisplayName: "CloudTrail EC2 StopInstances"
Enabled: true
CreateAlert: false
Filename: aws_ec2_stopinstances.py
LogTypes:
  - AWS.CloudTrail
Tags:
  - panther-signal
Severity: Info
Description: >
  A CloudTrail instances were stopped. It makes further changes of instances possible
Reference: https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-file-examples.html
Tests:
  -
    Name: CloudTrail Instances Were Stopped
    ExpectedResult: true
    Log:
      {
        "eventVersion": "1.08",
        "userIdentity": {
          "type": "IAMUser",
          "principalId": "EXAMPLE6E4XEGITWATV6R",
          "arn": "arn:aws:iam::777788889999:user/Nikki",
          "accountId": "777788889999",
          "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
          "userName": "Nikki",
          "sessionContext": {
            "sessionIssuer": { },
            "webIdFederationData": { },
            "attributes": {
              "creationDate": "2023-07-19T21:11:57Z",
              "mfaAuthenticated": "false"
            }
          }
        },
        "eventTime": "2023-07-19T21:14:20Z",
        "eventSource": "ec2.amazonaws.com",
        "eventName": "StopInstances",
        "awsRegion": "us-east-1",
        "sourceIPAddress": "192.0.2.0",
        "userAgent": "aws-cli/2.13.5 Python/3.11.4 Linux/4.14.255-314-253.539.amzn2.x86_64 exec-env/CloudShell exe/x86_64.amzn.2 prompt/off command/ec2.stop-instances",
        "requestParameters": {
          "instancesSet": {
            "items": [
              {
                "instanceId": "i-EXAMPLE56126103cb"
              },
              {
                "instanceId": "i-EXAMPLEaff4840c22"
              }
            ]
          },
          "force": false
        },
        "responseElements": {
          "requestId": "c308a950-e43e-444e-afc1-EXAMPLE73e49",
          "instancesSet": {
            "items": [
              {
                "instanceId": "i-EXAMPLE56126103cb",
                "currentState": {
                  "code": 64,
                  "name": "stopping"
                },
                "previousState": {
                  "code": 16,
                  "name": "running"
                }
              },
              {
                "instanceId": "i-EXAMPLEaff4840c22",
                "currentState": {
                  "code": 64,
                  "name": "stopping"
                },
                "previousState": {
                  "code": 16,
                  "name": "running"
                }
              }
            ]
          }
        },
        "requestID": "c308a950-e43e-444e-afc1-EXAMPLE73e49",
        "eventID": "9357a8cc-a0eb-46a1-b67e-EXAMPLE19b14",
        "readOnly": false,
        "eventType": "AwsApiCall",
        "managementEvent": true,
        "recipientAccountId": "777788889999",
        "eventCategory": "Management",
        "tlsDetails": {
          "tlsVersion": "TLSv1.2",
          "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256",
          "clientProvidedHostHeader": "ec2.us-east-1.amazonaws.com"
        },
        "sessionCredentialFromConsole": "true"
      }
  -
    Name: CloudTrail Instances Were Started
    ExpectedResult: false
    Log:
      {
        "eventVersion": "1.08",
        "userIdentity": {
          "type": "IAMUser",
          "principalId": "EXAMPLE6E4XEGITWATV6R",
          "arn": "arn:aws:iam::123456789012:user/Mateo",
          "accountId": "123456789012",
          "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
          "userName": "Mateo",
          "sessionContext": {
            "sessionIssuer": { },
            "webIdFederationData": { },
            "attributes": {
              "creationDate": "2023-07-19T21:11:57Z",
              "mfaAuthenticated": "false"
            }
          }
        },
        "eventTime": "2023-07-19T21:17:28Z",
        "eventSource": "ec2.amazonaws.com",
        "eventName": "StartInstances",
        "awsRegion": "us-east-1",
        "sourceIPAddress": "192.0.2.0",
        "userAgent": "aws-cli/2.13.5 Python/3.11.4 Linux/4.14.255-314-253.539.amzn2.x86_64 exec-env/CloudShell exe/x86_64.amzn.2 prompt/off command/ec2.start-instances",
        "requestParameters": {
          "instancesSet": {
            "items": [
              {
                "instanceId": "i-EXAMPLE56126103cb"
              },
              {
                "instanceId": "i-EXAMPLEaff4840c22"
              }
            ]
          }
        },
        "responseElements": {
          "requestId": "e4336db0-149f-4a6b-844d-EXAMPLEb9d16",
          "instancesSet": {
            "items": [
              {
                "instanceId": "i-EXAMPLEaff4840c22",
                "currentState": {
                  "code": 0,
                  "name": "pending"
                },
                "previousState": {
                  "code": 80,
                  "name": "stopped"
                }
              },
              {
                "instanceId": "i-EXAMPLE56126103cb",
                "currentState": {
                  "code": 0,
                  "name": "pending"
                },
                "previousState": {
                  "code": 80,
                  "name": "stopped"
                }
              }
            ]
          }
        },
        "requestID": "e4336db0-149f-4a6b-844d-EXAMPLEb9d16",
        "eventID": "e755e09c-42f9-4c5c-9064-EXAMPLE228c7",
        "readOnly": false,
        "eventType": "AwsApiCall",
        "managementEvent": true,
        "recipientAccountId": "123456789012",
        "eventCategory": "Management",
        "tlsDetails": {
          "tlsVersion": "TLSv1.2",
          "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256",
          "clientProvidedHostHeader": "ec2.us-east-1.amazonaws.com"
        },
        "sessionCredentialFromConsole": "true"
      }
  -
    Name: Error Stopping CloudTrail Instances
    ExpectedResult: false
    Log:
      {
          "eventVersion": "1.05",
          "errorCode": "SomeErrorCode",
          "userIdentity": {
            "type": "IAMUser",
            "principalId": "EXAMPLE6E4XEGITWATV6R",
            "arn": "arn:aws:iam::777788889999:user/Nikki",
            "accountId": "777788889999",
            "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
            "userName": "Nikki",
            "sessionContext": {
              "sessionIssuer": { },
              "webIdFederationData": { },
              "attributes": {
                "creationDate": "2023-07-19T21:11:57Z",
                "mfaAuthenticated": "false"
              }
            }
          },
          "eventTime": "2023-07-19T21:14:20Z",
          "eventSource": "ec2.amazonaws.com",
          "eventName": "StopInstances",
          "awsRegion": "us-east-1",
          "sourceIPAddress": "192.0.2.0",
          "userAgent": "aws-cli/2.13.5 Python/3.11.4 Linux/4.14.255-314-253.539.amzn2.x86_64 exec-env/CloudShell exe/x86_64.amzn.2 prompt/off command/ec2.stop-instances",
          "requestParameters": {
            "instancesSet": {
              "items": [
                {
                  "instanceId": "i-EXAMPLE56126103cb"
                },
                {
                  "instanceId": "i-EXAMPLEaff4840c22"
                }
              ]
            },
            "force": false
          },
          "requestID": "c308a950-e43e-444e-afc1-EXAMPLE73e49",
          "eventID": "9357a8cc-a0eb-46a1-b67e-EXAMPLE19b14",
          "readOnly": false,
          "eventType": "AwsApiCall",
          "managementEvent": true,
          "recipientAccountId": "777788889999",
          "eventCategory": "Management",
          "tlsDetails": {
            "tlsVersion": "TLSv1.2",
            "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256",
            "clientProvidedHostHeader": "ec2.us-east-1.amazonaws.com"
          },
          "sessionCredentialFromConsole": "true"
      }

Detection logic

Condition

errorCode is_null
errorMessage is_null
eventName eq "StopInstances"

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
errorCodeis_null
  • (no value, null check)
errorMessageis_null
  • (no value, null check)
eventNameeq
  • StopInstances

Output fields

Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.

Field
eventName
eventSource
awsRegion
recipientAccountId
sourceIPAddress
userAgent
userIdentity