AnalysisType: rule
RuleID: Wiz.Rotate.Service.Account.Secret
Description: This rule detects service account secrets rotations.
DisplayName: Wiz Rotate Service Account Secret
Runbook: Verify the action was planned.
Reference: https://www.wiz.io/academy/kubernetes-secrets
Enabled: true
Filename: wiz_rotate_service_account_secret.py
Severity: Medium
Reports:
MITRE ATT&CK:
- TA0001:T1078.004 # Valid Accounts: Cloud Accounts
LogTypes:
- Wiz.Audit
DedupPeriodMinutes: 60
Threshold: 1
Tests:
- Name: RotateServiceAccountSecret
ExpectedResult: true
Log:
{
"id": "d78f5ef1-3814-4d47-b789-0e43d4cc0ef2",
"action": "RotateServiceAccountSecret",
"requestId": "2303f545-a219-4c6d-b217-b76bb5e06a20",
"status": "SUCCESS",
"timestamp": "2024-07-16T10:47:43.562393Z",
"actionParameters": {
"ID": "rsao...<redacted>",
"selection": [
"__typename",
{
"serviceAccount": [
"__typename",
"id",
"enabled",
"name",
"clientId",
"scopes",
"lastRotatedAt",
"expiresAt",
"description",
{
"integration": [
"__typename",
"id"
]
},
"clientSecret"
]
}
]
},
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"sourceIP": "12.34.56.78",
"serviceAccount": null,
"user": {
"id": "test.user@company.com",
"name": "user@company.com"
}
}
- Name: CreateUser
ExpectedResult: false
Log:
{
"id": "220d23be-f07c-4d97-b4a6-87ad04eddb14",
"action": "CreateUser",
"requestId": "0d9521b2-c3f8-4a73-bf7c-20257788752e",
"status": "SUCCESS",
"timestamp": "2024-07-29T09:40:15.66643Z",
"actionParameters": {
"input": {
"assignedProjectIds": null,
"email": "testy@company.com",
"expiresAt": null,
"name": "Test User",
"role": "GLOBAL_ADMIN"
},
"selection": [
"__typename",
{
"user": [
"__typename",
"id"
]
}
]
},
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"sourceIP": "8.8.8.8",
"serviceAccount": null,
"user": {
"id": "someuser@company.com",
"name": "someuser@company.com"
}
}
- Name: RotateServiceAccountSecret - Fail
ExpectedResult: false
Log:
{
"id": "d78f5ef1-3814-4d47-b789-0e43d4cc0ef2",
"action": "RotateServiceAccountSecret",
"requestId": "2303f545-a219-4c6d-b217-b76bb5e06a20",
"status": "FAILED",
"timestamp": "2024-07-16T10:47:43.562393Z",
"actionParameters": { },
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"sourceIP": "12.34.56.78",
"serviceAccount": null,
"user": {
"id": "test.user@company.com",
"name": "user@company.com"
}
}
# ------ paired body: wiz_rotate_service_account_secret.py ------
from panther_wiz_helpers import wiz_actor, wiz_alert_context, wiz_success
def rule(event):
if not wiz_success(event):
return False
return event.get("action", "ACTION_NOT_FOUND") == "RotateServiceAccountSecret"
def title(event):
actor = wiz_actor(event)
return (
f"[Wiz]: [{event.get('action', 'ACTION_NOT_FOUND')}] action "
f"performed by {actor.get('type')} [{actor.get('name')}]"
)
def dedup(event):
return event.get("id")
def alert_context(event):
return wiz_alert_context(event)