Detection rules › Kusto

GCP IAM - New Authentication Token for Service Account

Status
available
Severity
medium
Time window
1h
Source
github.com/Azure/Azure-Sentinel

Detects when new authentication token is created for service account.

MITRE ATT&CK coverage

TacticTechniques
Lateral Movement

Telemetry coverage

PlatformRecord / event type
GCPGenerateAccessToken

Rule body

id: 80e4db30-5636-4fbd-8816-24c3ded8d243
name: GCP IAM - New Authentication Token for Service Account
description: |
  'Detects when new authentication token is created for service account.'
severity: Medium
status: Available
requiredDataConnectors:
  - connectorId: GCPIAMDataConnector
    dataTypes:
      - GCP_IAM
queryFrequency: 1h
queryPeriod: 1h
triggerOperator: gt
triggerThreshold: 0
tactics:
  - LateralMovement
relevantTechniques:
  - T1550
query: |
  GCP_IAM
  | where PayloadMethodname in ('GenerateAccessToken', 'google.iam.admin.v1.GenerateAccessToken')
  | extend result = parse_json(todynamic(PayloadAuthorizationinfo))[0]['granted']
  | where result =~ 'true'
  | extend service_account = extract(@'serviceAccounts\/(.*?)@', 1, PayloadResponseName)
  | project-away result
  | extend AccountName = tostring(split(service_account, "@")[0]), AccountUPNSuffix = tostring(split(service_account, "@")[1])
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: service_account
      - identifier: Name
        columnName: AccountName
      - identifier: UPNSuffix
        columnName: AccountUPNSuffix
  - entityType: IP
    fieldMappings:
      - identifier: Address
        columnName: SrcIpAddr
version: 1.0.2
kind: Scheduled

Stages and Predicates

Stage 1: source

GCP_IAM

Stage 2: where

| where PayloadMethodname in ('GenerateAccessToken', 'google.iam.admin.v1.GenerateAccessToken')

Stage 3: extend

| extend result = parse_json(todynamic(PayloadAuthorizationinfo))[0]['granted']

Stage 4: where

| where result =~ 'true'

Stage 5: extend

| extend service_account = extract(@'serviceAccounts\/(.*?)@', 1, PayloadResponseName)

Stage 6: project-away

| project-away result

Stage 7: extend

| extend AccountName = tostring(split(service_account, "@")[0]), AccountUPNSuffix = tostring(split(service_account, "@")[1])

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
PayloadMethodnamein
  • GenerateAccessToken
  • google.iam.admin.v1.GenerateAccessToken
field:"gcp::method_name" kind:in
resulteq
  • true
field:"result" kind:eq value:"true"

Output fields

These fields are emitted when the rule matches.

FieldSource
service_accountextend
AccountNameextend
AccountUPNSuffixextend