Detection rules › Panther

GCP K8s Pod Using Host PID Namespace

Status
Deprecated
Severity
medium
Log types
GCP.AuditLog
Tags
Deprecated, GCP, Optional
Reference
https://medium.com/snowflake/from-logs-to-detection-using-snowflake-and-panther-to-detect-k8s-threats-d72f70a504d7
Source
github.com/panther-labs/panther-analysis

This detection monitors for any pod creation or modification using the host PID namespace. The Host PID namespace enables a pod and its containers to have direct access and share the same view as of the host’s processes. This can offer a powerful escape hatch to the underlying host.

MITRE ATT&CK coverage

TacticTechniques
ExecutionT1610 Deploy Container
Privilege EscalationT1611 Escape to Host

Rules detecting the same action

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

Rule body yaml

AnalysisType: rule
RuleID: "GCP.K8s.Pod.Using.Host.PID.Namespace"
DisplayName: "GCP K8s Pod Using Host PID Namespace"
Enabled: false
Status: Deprecated
Filename: gcp_k8s_pod_using_host_pid_namespace.py
LogTypes:
  - GCP.AuditLog
Tags:
  - Deprecated
  - GCP
  - Optional
Severity: Medium
Description:
  This detection monitors for any pod creation or modification using the host PID namespace. The Host
  PID namespace enables a pod and its containers to have direct access and share the same view as of the host’s
  processes. This can offer a powerful escape hatch to the underlying host.
Runbook:
  Investigate a reason of creating a pod using the host PID namespace. Advise that it is discouraged
  practice. Create ticket if appropriate.
Reports:
  MITRE ATT&CK:
    - TA0004:T1611 # Escape to Host
    - TA0002:T1610 # Deploy Container
Reference: https://medium.com/snowflake/from-logs-to-detection-using-snowflake-and-panther-to-detect-k8s-threats-d72f70a504d7
Tests:
  - Name: triggers
    ExpectedResult: true
    Log:
      {
        "authorizationInfo":
          [
            {
              "granted": true,
              "permission": "io.k8s.core.v1.pods.create",
              "resource": "core/v1/namespaces/default/pods/nginx-test",
            },
          ],
        "protoPayload":
          {
            "methodName": "io.k8s.core.v1.pods.create",
            "request": { "spec": { "hostPID": true } },
          },
      }
  - Name: ignore
    ExpectedResult: false
    Log:
      {
        "authorizationInfo":
          [
            {
              "granted": true,
              "permission": "io.k8s.core.v1.pods.create",
              "resource": "core/v1/namespaces/default/pods/nginx-test",
            },
          ],
        "protoPayload":
          {
            "methodName": "io.k8s.core.v1.pods.create",
            "request": { "spec": { "hostPID": false } },
          },
      }

Detection logic

Condition

protoPayload.request.spec.hostPID eq "True" or protoPayload.response.spec.hostPID eq "True"
protoPayload.methodName in ["io.k8s.core.v1.pods.create", "io.k8s.core.v1.pods.update", "io.k8s.core.v1.pods.patch"]
not (protoPayload.authenticationInfo.principalEmail is_not_null and (protoPayload.authenticationInfo.principalEmail starts_with "system:kube-controller-manager" or protoPayload.authenticationInfo.principalEmail starts_with "system:kube-scheduler" or protoPayload.authenticationInfo.principalEmail starts_with "system:addon-manager" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:kube-system:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:kube-public:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:kube-node-lease:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:gke-system:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:gke-managed-system:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:gmp-system:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:gmp-public:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:config-management-system:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:istio-system:" or protoPayload.authenticationInfo.principalEmail starts_with "system:serviceaccount:asm-system:"))
protoPayload.resourceName not is_not_null

This rule also runs imperative logic the parser cannot express as a filter; the conditions above are the structured part it could extract.

Exclusions

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

FieldKindExcluded values
protoPayload.authenticationInfo.principalEmailstarts_withsystem:addon-manager
protoPayload.authenticationInfo.principalEmailstarts_withsystem:kube-controller-manager
protoPayload.authenticationInfo.principalEmailstarts_withsystem:kube-scheduler
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:asm-system:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:config-management-system:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:gke-managed-system:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:gke-system:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:gmp-public:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:gmp-system:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:istio-system:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:kube-node-lease:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:kube-public:
protoPayload.authenticationInfo.principalEmailstarts_withsystem:serviceaccount:kube-system:
protoPayload.authenticationInfo.principalEmailis_not_null(no value, null check)
protoPayload.resourceNameis_not_null(no value, null check)

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.

FieldKindValues
protoPayload.methodNamein
  • io.k8s.core.v1.pods.create
  • io.k8s.core.v1.pods.patch
  • io.k8s.core.v1.pods.update
protoPayload.request.spec.hostPIDeq
  • True
protoPayload.response.spec.hostPIDeq
  • True

Output fields

Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.

FieldSource
projectresource.labels.project_id
principalprotoPayload.authenticationInfo.principalEmail
caller_ipprotoPayload.requestMetadata.callerIP
methodNameprotoPayload.methodName
resourceNameprotoPayload.resourceName
serviceNameprotoPayload.serviceName