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