Detection rules › Panther

Kubernetes All Secrets Dumped Across Namespaces

Status
Experimental
Severity
critical
Group by
username
Compliance
Stratus Red Team k8s.credential-access.dump-secrets
Log types
Amazon.EKS.Audit, Azure.MonitorActivity, GCP.AuditLog
Tags
Kubernetes, Credential Access, Mass Exfiltration, Secrets Management, Unified Detection
Reference
https://stratus-red-team.cloud/attack-techniques/kubernetes/k8s.credential-access.dump-secrets/
Source
github.com/panther-labs/panther-analysis

This detection monitors for cluster-wide secret list operations that dump all secrets across all namespaces in a single API call. Attackers with list secrets permissions at the cluster level can trivially access every secret in the cluster using the LIST /api/v1/secrets API, exposing all credentials, tokens, and sensitive configuration data. This is a known attack technique documented by Stratus Red Team and represents mass credential theft.

MITRE ATT&CK coverage

Rule body yaml

AnalysisType: rule
RuleID: "Kubernetes.Secrets.DumpAllNamespaces"
DisplayName: "Kubernetes All Secrets Dumped Across Namespaces"
Enabled: true
Status: Experimental
Filename: k8s_secrets_dump_all_namespaces.py
LogTypes:
  - Amazon.EKS.Audit
  - Azure.MonitorActivity
  - GCP.AuditLog
Tags:
  - Kubernetes
  - Credential Access
  - Mass Exfiltration
  - Secrets Management
  - Unified Detection
Severity: Critical
Description: >
  This detection monitors for cluster-wide secret list operations that dump all secrets across all namespaces in a
  single API call. Attackers with list secrets permissions at the cluster level can trivially access every secret in
  the cluster using the LIST /api/v1/secrets API, exposing all credentials, tokens, and sensitive configuration data.
  This is a known attack technique documented by Stratus Red Team and represents mass credential theft.
Runbook: |
  1. Immediately investigate the user or service account performing this operation and determine if they are compromised
  2. Review what secrets exist in the cluster to assess the scope of credential exposure and rotate all sensitive credentials
  3. Search for other suspicious API activity by this user in the past 24 hours and check for data exfiltration or lateral movement attempts
Reports:
  Stratus Red Team:
    - k8s.credential-access.dump-secrets
  MITRE ATT&CK:
    - TA0006:T1552.007 # Credential Access: Unsecured Credentials - Container API
    - TA0009:T1530 # Collection: Data from Cloud Storage Object
Reference: https://stratus-red-team.cloud/attack-techniques/kubernetes/k8s.credential-access.dump-secrets/
DedupPeriodMinutes: 60
SummaryAttributes:
  - username
  - p_source_label
Tests:
  - Name: EKS cluster-wide secret list
    ExpectedResult: true
    Log:
      {
        "kind": "Event",
        "apiVersion": "audit.k8s.io/v1",
        "stage": "ResponseComplete",
        "verb": "list",
        "user": {"username": "attacker@example.com"},
        "sourceIPs": ["203.0.113.42"],
        "userAgent": "kubectl/v1.28.0",
        "objectRef": {
          "resource": "secrets",
          "apiVersion": "v1"
        },
        "requestURI": "/api/v1/secrets?limit=500",
        "responseStatus": {"code": 200},
        "p_log_type": "Amazon.EKS.Audit",
        "p_source_label": "eks-cluster"
      }
  - Name: AKS cluster-wide secret list
    ExpectedResult: true
    Log:
      {
        "p_log_type": "Azure.MonitorActivity",
        "category": "kube-audit",
        "operationName": "Microsoft.ContainerService/managedClusters/diagnosticLogs/Read",
        "properties": {
          "log": "{\"kind\":\"Event\",\"apiVersion\":\"audit.k8s.io/v1\",\"stage\":\"ResponseComplete\",\"verb\":\"list\",\"user\":{\"username\":\"compromised-user@example.com\"},\"sourceIPs\":[\"1.2.3.4\"],\"objectRef\":{\"resource\":\"secrets\",\"apiVersion\":\"v1\"},\"requestURI\":\"/api/v1/secrets\",\"responseStatus\":{\"code\":200}}"
        },
        "p_source_label": "aks-cluster"
      }
  - Name: GKE cluster-wide secret list
    ExpectedResult: true
    Log:
      {
        "protoPayload": {
          "authenticationInfo": {"principalEmail": "user@company.com"},
          "authorizationInfo": [{
            "granted": true,
            "permission": "io.k8s.core.v1.secrets.list",
            "resource": "core/v1/secrets"
          }],
          "methodName": "io.k8s.core.v1.secrets.list",
          "requestMetadata": {"callerIP": "8.8.8.8"},
          "resourceName": "core/v1/secrets",
          "serviceName": "k8s.io",
          "requestURI": "/api/v1/secrets?limit=500"
        },
        "resource": {
          "type": "k8s_cluster",
          "labels": {"project_id": "test-project"}
        },
        "p_log_type": "GCP.AuditLog",
        "p_source_label": "gke-cluster"
      }
  - Name: EKS cluster-wide secret list with watch parameter
    ExpectedResult: true
    Log:
      {
        "kind": "Event",
        "verb": "list",
        "user": {"username": "attacker@example.com"},
        "objectRef": {"resource": "secrets", "apiVersion": "v1"},
        "requestURI": "/api/v1/secrets?watch=true",
        "responseStatus": {"code": 200},
        "p_log_type": "Amazon.EKS.Audit",
        "p_source_label": "eks-cluster"
      }
  - Name: Namespaced secret list (not cluster-wide)
    ExpectedResult: false
    Log:
      {
        "kind": "Event",
        "verb": "list",
        "user": {"username": "developer@example.com"},
        "objectRef": {
          "resource": "secrets",
          "namespace": "production",
          "apiVersion": "v1"
        },
        "requestURI": "/api/v1/namespaces/production/secrets",
        "responseStatus": {"code": 200},
        "p_log_type": "Amazon.EKS.Audit"
      }
  - Name: Get single secret (not list)
    ExpectedResult: false
    Log:
      {
        "kind": "Event",
        "verb": "get",
        "user": {"username": "admin@example.com"},
        "objectRef": {
          "resource": "secrets",
          "namespace": "default",
          "name": "api-token",
          "apiVersion": "v1"
        },
        "requestURI": "/api/v1/namespaces/default/secrets/api-token",
        "responseStatus": {"code": 200},
        "p_log_type": "Amazon.EKS.Audit"
      }
  - Name: System component listing secrets (excluded)
    ExpectedResult: false
    Log:
      {
        "kind": "Event",
        "verb": "list",
        "user": {"username": "system:serviceaccount:kube-system:namespace-controller"},
        "objectRef": {"resource": "secrets", "apiVersion": "v1"},
        "requestURI": "/api/v1/secrets",
        "responseStatus": {"code": 200},
        "p_log_type": "Amazon.EKS.Audit"
      }
  - Name: Kube-state-metrics listing secrets (excluded)
    ExpectedResult: false
    Log:
      {
        "kind": "Event",
        "verb": "list",
        "user": {"username": "system:serviceaccount:kube-system:kube-state-metrics"},
        "objectRef": {"resource": "secrets", "apiVersion": "v1"},
        "requestURI": "/api/v1/secrets",
        "responseStatus": {"code": 200},
        "p_log_type": "Amazon.EKS.Audit"
      }
  - Name: Failed cluster-wide list (excluded)
    ExpectedResult: false
    Log:
      {
        "kind": "Event",
        "verb": "list",
        "user": {"username": "attacker@example.com"},
        "objectRef": {"resource": "secrets", "apiVersion": "v1"},
        "requestURI": "/api/v1/secrets",
        "responseStatus": {"code": 403},
        "p_log_type": "Amazon.EKS.Audit"
      }

Detection logic

Condition

not (verb ne "list" or resource ne "secrets" or (responseStatus is_not_null and (responseStatus.code ge "400" or (responseStatus.code ge "1" and responseStatus.code le "16"))))
not (namespace is_not_null or (requestURI is_not_null and requestURI contains "/namespaces/"))
not ((username is_not_null and (username in ["masterclient", "aksService"] or (username starts_with "system:" and username not contains "serviceaccount"))) or username in ["system:serviceaccount:kube-system:namespace-controller", "system:serviceaccount:kube-system:kube-state-metrics", "system:apiserver"])

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
usernamecontainsserviceaccount
usernamestarts_withsystem:
usernameinaksService, masterclient
usernameis_not_null(no value, null check)
usernameinsystem:apiserver, system:serviceaccount:kube-system:kube-state-metrics, system:serviceaccount:kube-system:namespace-controller
responseStatus.codege1
responseStatus.codele16
responseStatus.codege400
responseStatusis_not_null(no value, null check)
resourcenesecrets
verbnelist
requestURIcontains/namespaces/
requestURIis_not_null(no value, null check)
namespaceis_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
usernamecontains
  • serviceaccount

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
username
sourceIPs
userAgent
namespace
verb
resource
requestURI
responseStatus
clusterp_source_label