Detection rules › Panther

Monitor Unauthorized API Calls

Severity
informational
Group by
actor_user
Compliance
CIS 3.1
Log types
AWS.CloudTrail
Tags
AWS, Discovery:Cloud Service Discovery
Reference
https://amzn.to/3aOukaA
Source
github.com/panther-labs/panther-analysis

An unauthorized AWS API call was made

MITRE ATT&CK coverage

TacticTechniques
DiscoveryT1526 Cloud Service Discovery

Rule body yaml

AnalysisType: rule
Filename: aws_unauthorized_api_call.py
RuleID: "AWS.CloudTrail.UnauthorizedAPICall"
DisplayName: "Monitor Unauthorized API Calls"
Enabled: true
DedupPeriodMinutes: 1440 # 24 hours
LogTypes:
  - AWS.CloudTrail
Tags:
  - AWS
  - Discovery:Cloud Service Discovery
Reports:
  CIS:
    - 3.1
  MITRE ATT&CK:
    - TA0007:T1526
Severity: Info
CreateAlert: false
Description: An unauthorized AWS API call was made
Runbook: https://docs.runpanther.io/alert-runbooks/built-in-rules/aws-unauthorized-api-call
Reference: https://amzn.to/3aOukaA
SummaryAttributes:
  - eventName
  - userAgent
  - sourceIpAddress
  - recipientAccountId
  - p_any_aws_arns
Threshold: 20
Tests:
  - Name: Unauthorized API Call from Within AWS (IP)
    ExpectedResult: true
    Log:
      {
        "eventVersion": "1.05",
        "userIdentity":
          {
            "type": "IAMUser",
            "principalId": "1111",
            "arn": "arn:aws:iam::123456789012:user/tester",
            "accountId": "123456789012",
            "accessKeyId": "1",
            "userName": "tester",
            "sessionContext":
              {
                "attributes":
                  {
                    "mfaAuthenticated": "true",
                    "creationDate": "2019-01-01T00:00:00Z",
                  },
              },
            "invokedBy": "signin.amazonaws.com",
          },
        "eventTime": "2019-01-01T00:00:00Z",
        "eventSource": "iam.amazonaws.com",
        "eventName": "CreateServiceLinkedRole",
        "awsRegion": "us-east-1",
        "sourceIPAddress": "3.10.107.144",
        "errorCode": "AccessDenied",
        "errorMessage": "User: arn:aws:iam::123456789012:user/tester is not authorized to perform: iam:Action on resource: arn:aws:iam::123456789012:resource",
        "userAgent": "sqs.amazonaws.com",
        "requestParameters": null,
        "responseElements": null,
        "requestID": "1",
        "eventID": "1",
        "eventType": "AwsApiCall",
        "recipientAccountId": "123456789012",
        p_log_type: "AWS.CloudTrail",
      }
  - Name: Unauthorized API Call from Within AWS (FQDN)
    ExpectedResult: false
    Log:
      {
        "eventVersion": "1.05",
        "userIdentity":
          {
            "type": "IAMUser",
            "principalId": "1111",
            "arn": "arn:aws:iam::123456789012:user/tester",
            "accountId": "123456789012",
            "accessKeyId": "1",
            "userName": "tester",
            "sessionContext":
              {
                "attributes":
                  {
                    "mfaAuthenticated": "true",
                    "creationDate": "2019-01-01T00:00:00Z",
                  },
              },
            "invokedBy": "signin.amazonaws.com",
          },
        "eventTime": "2019-01-01T00:00:00Z",
        "eventSource": "iam.amazonaws.com",
        "eventName": "CreateServiceLinkedRole",
        "awsRegion": "us-east-1",
        "sourceIPAddress": "sqs.amazonaws.com",
        "errorCode": "AccessDenied",
        "errorMessage": "User: arn:aws:iam::123456789012:user/tester is not authorized to perform: iam:Action on resource: arn:aws:iam::123456789012:resource",
        "userAgent": "sqs.amazonaws.com",
        "requestParameters": null,
        "responseElements": null,
        "requestID": "1",
        "eventID": "1",
        "eventType": "AwsApiCall",
        "recipientAccountId": "123456789012",
        p_log_type: "AWS.CloudTrail",
      }
  - Name: Authorized API Call
    ExpectedResult: false
    Log:
      {
        "eventVersion": "1.05",
        "userIdentity":
          {
            "type": "IAMUser",
            "principalId": "1111",
            "arn": "arn:aws:iam::123456789012:user/tester",
            "accountId": "123456789012",
            "accessKeyId": "1",
            "userName": "tester",
            "sessionContext":
              {
                "attributes":
                  {
                    "mfaAuthenticated": "true",
                    "creationDate": "2019-01-01T00:00:00Z",
                  },
              },
            "invokedBy": "signin.amazonaws.com",
          },
        "eventTime": "2019-01-01T00:00:00Z",
        "eventSource": "iam.amazonaws.com",
        "eventName": "CreateServiceLinkedRole",
        "awsRegion": "us-east-1",
        "sourceIPAddress": "111.111.111.111",
        "userAgent": "signin.amazonaws.com",
        "requestParameters": null,
        "responseElements": null,
        "requestID": "1",
        "eventID": "1",
        "eventType": "AwsApiCall",
        "recipientAccountId": "123456789012",
        p_log_type: "AWS.CloudTrail",
      }

Detection logic

Condition

errorCode eq "AccessDenied"
eventName not in ["DescribeEventAggregates", "ListResourceTags"]

This rule also runs imperative logic the parser cannot express as a filter; the conditions above are the structured part it could extract.

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
eventNameinDescribeEventAggregates, ListResourceTags

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
errorCodeeq
  • AccessDenied

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.

FieldSource
eventName
eventSource
awsRegion
recipientAccountId
sourceIPAddress
userAgent
userIdentity
typeuserIdentity.type