Detection rules › Elastic

Kubernetes Privileged Pod Created

Status
production
Severity
medium
Author
Elastic
Source
github.com/elastic/detection-rules

This rule detects when a user creates a pod/container running in privileged mode. A highly privileged container has access to the node's resources and breaks the isolation between containers. If compromised, an attacker can use the privileged container to gain access to the underlying host. Gaining access to the host may provide the adversary with the opportunity to achieve follow-on objectives, such as establishing persistence, moving laterally within the environment, or setting up a command and control channel on the host.

MITRE ATT&CK coverage

TacticTechniques
ExecutionT1610 Deploy Container
Privilege EscalationT1611 Escape to Host

Event coverage

ProviderEventTitle
Kubernetes-podscreate-podscreate pods

Rules detecting the same action

Other rules on this platform that filter on the same API call or operation.

Rule body elastic

[metadata]
creation_date = "2022/07/05"
integration = ["kubernetes"]
maturity = "production"
updated_date = "2026/04/10"

[rule]
author = ["Elastic"]
description = """
This rule detects when a user creates a pod/container running in privileged mode. A highly privileged container has
access to the node's resources and breaks the isolation between containers. If compromised, an attacker can use the
privileged container to gain access to the underlying host. Gaining access to the host may provide the adversary with
the opportunity to achieve follow-on objectives, such as establishing persistence, moving laterally within the
environment, or setting up a command and control channel on the host.
"""
false_positives = [
    """
    By default a container is not allowed to access any devices on the host, but a "privileged" container is given
    access to all devices on the host. This allows the container nearly all the same access as processes running on the
    host. An administrator may want to run a privileged container to use operating system administrative capabilities
    such as manipulating the network stack or accessing hardware devices from within the cluster. Add exceptions for
    trusted container images using the query field "kubernetes.audit.requestObject.spec.container.image"
    """,
]
index = ["logs-kubernetes.audit_logs-*"]
language = "kuery"
license = "Elastic License v2"
name = "Kubernetes Privileged Pod Created"
note = """## Triage and analysis

> **Disclaimer**:
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

### Investigating Kubernetes Privileged Pod Created

Kubernetes allows for the creation of privileged pods, which can access the host's resources, breaking container isolation. Adversaries may exploit this to escalate privileges, access sensitive data, or establish persistence. The detection rule identifies such events by monitoring audit logs for pod creation with privileged settings, excluding known safe images, to flag potential security threats.

### Possible investigation steps

- Review the Kubernetes audit logs to identify the user or service account responsible for creating the privileged pod by examining the `kubernetes.audit.annotations.authorization_k8s_io/decision` and `kubernetes.audit.verb:create` fields.
- Investigate the context of the privileged pod creation by checking the `kubernetes.audit.requestObject.spec.containers.image` field to determine if the image used is known or potentially malicious.
- Assess the necessity and legitimacy of the privileged pod by consulting with the relevant development or operations teams to understand if there was a valid reason for its creation.
- Examine the `kubernetes.audit.objectRef.resource:pods` field to identify the specific pod and its associated namespace, and verify if it aligns with expected deployment patterns or environments.
- Check for any subsequent suspicious activities or anomalies in the Kubernetes environment that may indicate further exploitation attempts, such as lateral movement or data exfiltration, following the creation of the privileged pod.

### False positive analysis

- Known safe images like "docker.elastic.co/beats/elastic-agent:8.4.0" are already excluded from triggering alerts. Ensure that any additional internal or third-party images that are verified as safe are added to the exclusion list to prevent unnecessary alerts.
- Development and testing environments often use privileged pods for legitimate purposes. Consider creating separate rules or exceptions for these environments to avoid false positives while maintaining security in production.
- Automated deployment tools or scripts might create privileged pods as part of their normal operation. Review these tools and, if they are deemed safe, add their specific actions or images to the exclusion list.
- Regularly review and update the exclusion list to reflect changes in your environment, such as new safe images or changes in deployment practices, to maintain an accurate detection rule.

### Response and remediation

- Immediately isolate the affected node to prevent further exploitation and lateral movement within the cluster. This can be done by cordoning and draining the node to stop new pods from being scheduled and to safely evict existing pods.
- Terminate the privileged pod to stop any ongoing malicious activity. Ensure that the termination is logged for further analysis.
- Conduct a thorough review of the audit logs to identify any unauthorized access or actions taken by the privileged pod. Focus on any attempts to access sensitive data or escalate privileges.
- Reset credentials and access tokens that may have been exposed or compromised due to the privileged pod's access to the host's resources.
- Patch and update the Kubernetes environment and any affected nodes to address vulnerabilities that may have been exploited to create the privileged pod.
- Implement network segmentation and firewall rules to limit the communication capabilities of pods, especially those with elevated privileges, to reduce the risk of lateral movement.
- Escalate the incident to the security operations team for a comprehensive investigation and to assess the need for further security measures or incident response actions.

## Setup

The Kubernetes Fleet integration with Audit Logs enabled or similarly structured data is required to be compatible with this rule."""
references = [
    "https://media.defense.gov/2021/Aug/03/2002820425/-1/-1/1/CTR_KUBERNETES%20HARDENING%20GUIDANCE.PDF",
    "https://kubernetes.io/docs/tasks/configure-pod-container/security-context/",
]
risk_score = 47
rule_id = "c7908cac-337a-4f38-b50d-5eeb78bdb531"
severity = "medium"
tags = [
    "Data Source: Kubernetes",
    "Domain: Kubernetes",
    "Use Case: Threat Detection",
    "Tactic: Execution",
    "Tactic: Privilege Escalation",
    "Resources: Investigation Guide",
]
timestamp_override = "event.ingested"
type = "query"
query = '''
data_stream.dataset : "kubernetes.audit_logs" and kubernetes.audit.annotations.authorization_k8s_io/decision:"allow" and
kubernetes.audit.objectRef.resource:pods and kubernetes.audit.verb:create and kubernetes.audit.requestObject.spec.containers.securityContext.privileged:true and
not kubernetes.audit.requestObject.spec.containers.image: (
  *amazonaws.com/betsie/pipeline/pipeline-core* or mirror.gcr.io/aquasec/trivy* or rancher/mirrored-longhornio-longhorn-instance-manager* or quay.io/calico* or
  rancher/system-agent* or openebs/m-exporter* or openebs/cstor-istgt* or ghcr.io/kubereboot/kured* or registry.k8s.io/sig-storage/csi-node-driver-registrar* or
  registry.k8s.io/csi-secrets-store* or registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper* or sonarsource/sonar-scanner-cli* or
  rancher/mirrored-longhornio-longhorn-engine* or jenkins/inbound-agent* or mcr.microsoft.com/oss/v2/kubernetes-csi* or registry.k8s.io/dns/k8s-dns-node-cache* or
  *amazonaws.com/eks/kube-proxy* or *amazonaws.com/eks/aws-efs-csi-driver* or *amazonaws.com/eks/livenessprobe* or *amazonaws.com/amazon-k8s-cni* or
  *amazonaws.com/amazon/aws-network-policy-agent* or mcr.microsoft.com/oss/kubernetes-csi* or openebs/node-disk-manager* or openebs/node-disk-exporter* or
  mcr.microsoft.com/oss/kubernetes/kube-proxy* or public.ecr.aws/eks-distro/kubernetes-csi/livenessprobe* or public.ecr.aws/eks-distro/kubernetes-csi/external-provisioner* or
  amazon/aws-efs-csi-driver* or registry.k8s.io/kube-proxy* or registry.crowdstrike.com/falcon-sensor* or *octopus-deploy/tentacle* or */sysdig/*
)
'''

[[rule.threat]]
framework = "MITRE ATT&CK"

[[rule.threat.technique]]
id = "T1611"
name = "Escape to Host"
reference = "https://attack.mitre.org/techniques/T1611/"

[rule.threat.tactic]
id = "TA0004"
name = "Privilege Escalation"
reference = "https://attack.mitre.org/tactics/TA0004/"

[[rule.threat]]
framework = "MITRE ATT&CK"

[[rule.threat.technique]]
id = "T1610"
name = "Deploy Container"
reference = "https://attack.mitre.org/techniques/T1610/"

[rule.threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"

Stages and Predicates

Stage 1: query

data_stream.dataset : "kubernetes.audit_logs" and kubernetes.audit.annotations.authorization_k8s_io/decision:"allow" and
kubernetes.audit.objectRef.resource:pods and kubernetes.audit.verb:create and kubernetes.audit.requestObject.spec.containers.securityContext.privileged:true and
not kubernetes.audit.requestObject.spec.containers.image: (
  *amazonaws.com/betsie/pipeline/pipeline-core* or mirror.gcr.io/aquasec/trivy* or rancher/mirrored-longhornio-longhorn-instance-manager* or quay.io/calico* or
  rancher/system-agent* or openebs/m-exporter* or openebs/cstor-istgt* or ghcr.io/kubereboot/kured* or registry.k8s.io/sig-storage/csi-node-driver-registrar* or
  registry.k8s.io/csi-secrets-store* or registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper* or sonarsource/sonar-scanner-cli* or
  rancher/mirrored-longhornio-longhorn-engine* or jenkins/inbound-agent* or mcr.microsoft.com/oss/v2/kubernetes-csi* or registry.k8s.io/dns/k8s-dns-node-cache* or
  *amazonaws.com/eks/kube-proxy* or *amazonaws.com/eks/aws-efs-csi-driver* or *amazonaws.com/eks/livenessprobe* or *amazonaws.com/amazon-k8s-cni* or
  *amazonaws.com/amazon/aws-network-policy-agent* or mcr.microsoft.com/oss/kubernetes-csi* or openebs/node-disk-manager* or openebs/node-disk-exporter* or
  mcr.microsoft.com/oss/kubernetes/kube-proxy* or public.ecr.aws/eks-distro/kubernetes-csi/livenessprobe* or public.ecr.aws/eks-distro/kubernetes-csi/external-provisioner* or
  amazon/aws-efs-csi-driver* or registry.k8s.io/kube-proxy* or registry.crowdstrike.com/falcon-sensor* or *octopus-deploy/tentacle* or */sysdig/*
)

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
kubernetes.audit.requestObject.spec.containers.imagematch/sysdig/
kubernetes.audit.requestObject.spec.containers.imagematchamazonaws.com/amazon-k8s-cni
kubernetes.audit.requestObject.spec.containers.imagematchamazonaws.com/amazon/aws-network-policy-agent
kubernetes.audit.requestObject.spec.containers.imagematchamazonaws.com/betsie/pipeline/pipeline-core
kubernetes.audit.requestObject.spec.containers.imagematchamazonaws.com/eks/aws-efs-csi-driver
kubernetes.audit.requestObject.spec.containers.imagematchamazonaws.com/eks/kube-proxy
kubernetes.audit.requestObject.spec.containers.imagematchamazonaws.com/eks/livenessprobe
kubernetes.audit.requestObject.spec.containers.imagematchoctopus-deploy/tentacle
kubernetes.audit.requestObject.spec.containers.imagestarts_withamazon/aws-efs-csi-driver
kubernetes.audit.requestObject.spec.containers.imagestarts_withghcr.io/kubereboot/kured
kubernetes.audit.requestObject.spec.containers.imagestarts_withjenkins/inbound-agent
kubernetes.audit.requestObject.spec.containers.imagestarts_withmcr.microsoft.com/oss/kubernetes-csi
kubernetes.audit.requestObject.spec.containers.imagestarts_withmcr.microsoft.com/oss/kubernetes/kube-proxy
kubernetes.audit.requestObject.spec.containers.imagestarts_withmcr.microsoft.com/oss/v2/kubernetes-csi
kubernetes.audit.requestObject.spec.containers.imagestarts_withmirror.gcr.io/aquasec/trivy
kubernetes.audit.requestObject.spec.containers.imagestarts_withopenebs/cstor-istgt
kubernetes.audit.requestObject.spec.containers.imagestarts_withopenebs/m-exporter
kubernetes.audit.requestObject.spec.containers.imagestarts_withopenebs/node-disk-exporter
kubernetes.audit.requestObject.spec.containers.imagestarts_withopenebs/node-disk-manager
kubernetes.audit.requestObject.spec.containers.imagestarts_withpublic.ecr.aws/eks-distro/kubernetes-csi/external-provisioner
kubernetes.audit.requestObject.spec.containers.imagestarts_withpublic.ecr.aws/eks-distro/kubernetes-csi/livenessprobe
kubernetes.audit.requestObject.spec.containers.imagestarts_withquay.io/calico
kubernetes.audit.requestObject.spec.containers.imagestarts_withrancher/mirrored-longhornio-longhorn-engine
kubernetes.audit.requestObject.spec.containers.imagestarts_withrancher/mirrored-longhornio-longhorn-instance-manager
kubernetes.audit.requestObject.spec.containers.imagestarts_withrancher/system-agent
kubernetes.audit.requestObject.spec.containers.imagestarts_withregistry.crowdstrike.com/falcon-sensor
kubernetes.audit.requestObject.spec.containers.imagestarts_withregistry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper
kubernetes.audit.requestObject.spec.containers.imagestarts_withregistry.k8s.io/csi-secrets-store
kubernetes.audit.requestObject.spec.containers.imagestarts_withregistry.k8s.io/dns/k8s-dns-node-cache
kubernetes.audit.requestObject.spec.containers.imagestarts_withregistry.k8s.io/kube-proxy
kubernetes.audit.requestObject.spec.containers.imagestarts_withregistry.k8s.io/sig-storage/csi-node-driver-registrar
kubernetes.audit.requestObject.spec.containers.imagestarts_withsonarsource/sonar-scanner-cli

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.