# Kubeconfig Exposure Detection Module

id: kubeconfig-exposure
info:
  name: Kubeconfig Exposure
  author: sif
  severity: high
  description: Detects an exposed kubeconfig that leaks cluster endpoints and client credentials
  tags: [kubernetes, kubeconfig, cluster, credentials, exposure, recon]

type: http

http:
  method: GET
  paths:
    - "{{BaseURL}}/.kube/config"
    - "{{BaseURL}}/kube/config"

  matchers:
    - type: status
      status:
        - 200

    - type: word
      part: body
      words:
        - "kind: Config"

    - type: word
      part: body
      condition: or
      words:
        - "clusters:"
        - "current-context:"
        - "client-certificate-data:"
        - "client-key-data:"

    - type: word
      part: body
      negative: true
      condition: or
      words:
        - "<!DOCTYPE"
        - "<!doctype"
        - "<html"
        - "<HTML"
        - "<head>"
        - "<title>"

  extractors:
    - type: regex
      name: cluster_server
      part: body
      regex:
        - 'server:\s*(https?://[^\s]+)'
      group: 1
