Kubernetes Suspicious Assignment of Controller Service Account

This rule detects a request to attach a controller service account to an existing or new pod running in the kube-system namespace. By default, controllers running as part of the API Server utilize admin-equivalent service accounts hosted in the kube-system namespace. Controller service accounts aren't normally assigned to running pods and could indicate adversary behavior within the cluster. An attacker that can create or modify pods or pod controllers in the kube-system namespace, can assign one of these admin-equivalent service accounts to a pod and abuse their powerful token to escalate privileges and gain complete cluster control.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2022/09/13"
 3integration = ["kubernetes"]
 4maturity = "production"
 5min_stack_comments = "New fields added to Kubernetes Integration"
 6min_stack_version = "8.4.0"
 7updated_date = "2023/06/22"
 8
 9[rule]
10author = ["Elastic"]
11description = """
12This rule detects a request to attach a controller service account to an existing or new pod running in the kube-system
13namespace. By default, controllers running as part of the API Server utilize admin-equivalent service accounts hosted in
14the kube-system namespace. Controller service accounts aren't normally assigned to running pods and could indicate
15adversary behavior within the cluster. An attacker that can create or modify pods or pod controllers in the kube-system
16namespace, can assign one of these admin-equivalent service accounts to a pod and abuse their powerful token to escalate
17privileges and gain complete cluster control.
18"""
19false_positives = [
20    """
21    Controller service accounts aren't normally assigned to running pods, this is abnormal behavior with very few
22    legitimate use-cases and should result in very few false positives.
23    """,
24]
25index = ["logs-kubernetes.*"]
26language = "kuery"
27license = "Elastic License v2"
28name = "Kubernetes Suspicious Assignment of Controller Service Account"
29note = """## Setup
30
31The Kubernetes Fleet integration with Audit Logs enabled or similarly structured data is required to be compatible with this rule."""
32references = [
33    "https://www.paloaltonetworks.com/apps/pan/public/downloadResource?pagePath=/content/pan/en_US/resources/whitepapers/kubernetes-privilege-escalation-excessive-permissions-in-popular-platforms",
34]
35risk_score = 47
36rule_id = "63c05204-339a-11ed-a261-0242ac120002"
37severity = "medium"
38tags = ["Data Source: Kubernetes", "Tactic: Execution", "Tactic: Privilege Escalation"]
39timestamp_override = "event.ingested"
40type = "query"
41
42query = '''
43event.dataset : "kubernetes.audit_logs"
44  and kubernetes.audit.annotations.authorization_k8s_io/decision:"allow"
45  and kubernetes.audit.verb : "create"
46  and kubernetes.audit.objectRef.resource : "pods"
47  and kubernetes.audit.objectRef.namespace : "kube-system"
48  and kubernetes.audit.requestObject.spec.serviceAccountName:*controller
49'''
50
51
52[[rule.threat]]
53framework = "MITRE ATT&CK"
54[[rule.threat.technique]]
55id = "T1078"
56name = "Valid Accounts"
57reference = "https://attack.mitre.org/techniques/T1078/"
58[[rule.threat.technique.subtechnique]]
59id = "T1078.001"
60name = "Default Accounts"
61reference = "https://attack.mitre.org/techniques/T1078/001/"
62
63
64
65[rule.threat.tactic]
66id = "TA0004"
67name = "Privilege Escalation"
68reference = "https://attack.mitre.org/tactics/TA0004/"

Setup

The Kubernetes Fleet integration with Audit Logs enabled or similarly structured data is required to be compatible with this rule.

References

Related rules

to-top