Privilege Escalation (TA0004)(external, opens in a new tab or window)
text code block:from logs-kubernetes.audit_logs-* metadata _id, _index, _version | where kubernetes.audit.objectRef.resource in ("roles", "clusterroles") and kubernetes.audit.verb in ("update", "patch") and `kubernetes.audit.annotations.authorization_k8s_io/decision` == "allow" and kubernetes.audit.level == "RequestResponse" and kubernetes.audit.stage == "ResponseComplete" and kubernetes.audit.sourceIPs is not null and not kubernetes.audit.sourceIPs in ("::1", "127.0.0.1") and KQL(""" kubernetes.audit.responseObject.rules.verbs:"*" and kubernetes.audit.responseObject.rules.resources:"*" """) | keep user.name, user_agent.original, event.action, source.ip, kubernetes.audit.verb, kubernetes.audit.objectRef.resource, kubernetes.audit.objectRef.name, kubernetes.audit.requestURI, kubernetes.audit.user.username, kubernetes.audit.user.groups, `kubernetes.audit.annotations.authorization_k8s_io/decision`, event.original, _id, _version, _index, data_stream.namespace
Install detection rules in Elastic Security
Detect Kubernetes RBAC Wildcard Elevation on Existing Role in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).