Detection rules › Panther

GCP Cloud Run Service Created FOLLOWED BY Set IAM Policy

Severity
high
Time window
90m
Match by
p_alert_context.caller_ip
Reference
https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/
Source
github.com/panther-labs/panther-analysis

Detects run.services.create method for privilege escalation in GCP. The exploit creates a new Cloud Run Service that, when invoked, returns the Service Account's access token by accessing the metadata API of the server it is running on.

MITRE ATT&CK coverage

TacticTechniques
Privilege EscalationT1548 Abuse Elevation Control Mechanism

Rule body yaml

AnalysisType: correlation_rule
RuleID: "GCP.Cloud.Run.Service.Created.FOLLOWED.BY.Set.IAM.Policy"
DisplayName: "GCP Cloud Run Service Created FOLLOWED BY Set IAM Policy"
Enabled: true
Severity: High
Description: Detects run.services.create method for privilege escalation in GCP. The exploit creates a new Cloud Run 
  Service that, when invoked, returns the Service Account's access token by accessing the metadata API of the server 
  it is running on.
Reference: https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/
Runbook: Confirm this was authorized and necessary behavior
Reports:
    MITRE ATT&CK:
        - TA0004:T1548  # Abuse Elevation Control Mechanism
Detection:
    - Sequence:
        - ID: ServiceCreated
          RuleID: GCP.Cloud.Run.Service.Created
        - ID: SetIAMPolicy
          RuleID: GCP.Cloud.Run.Set.IAM.Policy
      Transitions:
        - ID: ServiceCreated FOLLOWED BY SetIAMPolicy
          From: ServiceCreated
          To: SetIAMPolicy
          WithinTimeFrameMinutes: 90
          Match:
            - On: p_alert_context.caller_ip
      LookbackWindowMinutes: 2160
      Schedule:
        RateMinutes: 1440 
        TimeoutMinutes: 5
Tests:
    - Name: GCP Service Run, Followed By IAM Policy Change From Same IP
      ExpectedResult: true
      RuleOutputs:
        - ID: ServiceCreated
          Matches:
            p_alert_context.caller_ip:
              1.1.1.1:
                - "2024-06-01T10:00:00Z"
        - ID: SetIAMPolicy
          Matches:
            p_alert_context.caller_ip:
              1.1.1.1:
                - "2024-06-01T10:00:01Z"
    - Name: GCP Service Run, Not Followed By IAM Policy Change
      ExpectedResult: false
      RuleOutputs:
        - ID: ServiceCreated
          Matches:
            p_alert_context.caller_ip:
              1.1.1.1:
                - "2024-06-01T10:00:00Z"
    - Name: IAM Policy Change, Not Preceeded By GCP Service Run
      ExpectedResult: false
      RuleOutputs:
        - ID: SetIAMPolicy
          Matches:
            p_alert_context.caller_ip:
              1.1.1.1:
                - "2024-06-01T10:00:01Z"
    - Name: GCP Service Run, Followed By IAM Policy Change From Different IP
      ExpectedResult: false
      RuleOutputs:
        - ID: ServiceCreated
          Matches:
            p_alert_context.caller_ip:
              1.1.1.1:
                - "2024-06-01T10:00:00Z"
        - ID: SetIAMPolicy
          Matches:
            p_alert_context.caller_ip:
              2.2.2.2:
                - "2024-06-01T10:00:01Z"

Detection logic

Stage 1: step ServiceCreated ordered before $SetIAMPolicy

References detection GCP.Cloud.Run.Service.Created.

Stage 2: step SetIAMPolicy ordered after $ServiceCreated

References detection GCP.Cloud.Run.Set.IAM.Policy.