[New Rules] Misc. K8s RBAC Abuse Rules#5673
Conversation
Rule: New - GuidelinesThese guidelines serve as a reminder set of considerations when proposing a new rule. Documentation and Context
Rule Metadata Checks
New BBR Rules
Testing and Validation
|
| ClusterRole, which provides unrestricted access to all Kubernetes resources and represents a | ||
| high-risk privilege escalation or misconfiguration. | ||
| """ | ||
| index = ["logs-kubernetes.audit_logs-*"] |
There was a problem hiding this comment.
Most k8s rules don't have an interval/timing set. I assume these will use the default. I copy-pasted these templates so I left them out as well - if we should still include these, I can add them in a large PR to all k8s rules.
terrancedejesus
left a comment
There was a problem hiding this comment.
Queries, rules and behavior they match on look good. My biggest question is parity between K8s integration and each provider audit logs. Example - I searched for rolebindings and found some GCP audit log based rules with similar visibility. Have we considered when to use what vs what? Can maybe be discussed async.
| rule_id = "a2951930-dd35-438c-b10e-1bbdc5881cb4" | ||
| severity = "medium" | ||
| tags = [ | ||
| "Data Source: Kubernetes", |
There was a problem hiding this comment.
| "Data Source: Kubernetes", | |
| "Data Source: Kubernetes", | |
| "Data Source: Kubernetes Audit Logs" |
Just a thought. Faceted search should still show these if only Kubernetes is available vs container log searches. Ignore if you feel not necessary or we can circle back with the tagging initiative.
| query = ''' | ||
| event.dataset: "kubernetes.audit_logs" and kubernetes.audit.requestObject.spec.serviceAccountName:* and | ||
| kubernetes.audit.verb:"create" and kubernetes.audit.objectRef.resource:("rolebindings" or "clusterrolebindings") and | ||
| kubernetes.audit.annotations.authorization_k8s_io/decision:"allow" | ||
| ''' |
There was a problem hiding this comment.
@Aegrah I'm not sure why this one is malicious? Isn't this the normal process for assigning service accounts permissions?
There was a problem hiding this comment.
The reason to detect it is that this is the exact mechanism attackers abuse for privilege escalation and persistence: if any compromised identity can create a RoleBinding, it can instantly grant elevated permissions to a ServiceAccount and turn a pod-level compromise into cluster-level access. It's meant as high-signal monitoring of a critical control-plane action, not per se malicious. Also, this activity should not be frequent, and it will be easy to exclude known identities once we get telemetry.
New Rules Summary
1. Kubernetes Cluster-Admin Role Binding Created
Description: This rule detects the creation of a RoleBinding or ClusterRoleBinding that grants the cluster-admin ClusterRole, which provides unrestricted access to all Kubernetes resources and represents a high-risk privilege escalation or misconfiguration.
Detection: Monitors for
createoperations onrolebindingsorclusterrolebindingswhere theroleRef.nameiscluster-admin.2. Kubernetes Creation or Modification of Sensitive Role
Description: Detects the creation or modification of Kubernetes Roles or ClusterRoles that grant high-risk permissions, such as wildcard access or RBAC escalation verbs (e.g., bind, escalate, impersonate), which may enable privilege escalation or unauthorized access within the cluster.
Detection: Monitors for
create,update, orpatchoperations onrolesorclusterroleswhere the rules include sensitive verbs (*,escalate,bind,impersonate) or target RBAC resources.3. Kubernetes Creation of a RoleBinding Referencing a ServiceAccount
Description: This rule detects the creation of RoleBindings or ClusterRoleBindings that reference a ServiceAccount, which may indicate privilege delegation or potential RBAC misconfiguration leading to elevated access.
Detection: Monitors for
createoperations onrolebindingsorclusterrolebindingswhere the request object includes aserviceAccountName.4. Kubernetes Sensitive RBAC Change Followed by Workload Modification
Description: Detects a sequence where a principal creates or modifies a Role/ClusterRole to include high-risk permissions (e.g., wildcard access or escalation verbs) and then creates or patches a workload resource (DaemonSet, Deployment, or CronJob) shortly after, which may indicate RBAC-based privilege escalation followed by payload deployment.
Detection: Correlates two events within 5 minutes by the same user: (1) a Role/ClusterRole creation or modification, followed by (2) a DaemonSet, Deployment, or CronJob creation or patch.
5. Kubernetes Service Account Modified RBAC Objects
Description: Detects write operations performed by Kubernetes service accounts against RBAC resources (Roles, ClusterRoles, RoleBindings, ClusterRoleBindings). Service accounts typically do not manage RBAC directly; this activity may indicate token abuse, misconfigured permissions, or unauthorized privilege escalation.
Detection: Monitors for
create,update,patch, ordeleteoperations on RBAC resources performed by principals with usernames matchingsystem:serviceaccount:*, excluding known system controllers.