跳到正文
Skillpedia
部署与云(DevOps)35k · #8207

performing-container-escape-detection

它能做什么

这个工具检查 Kubernetes 集群中的容器配置,查找可能让容器“逃逸”并访问宿主机系统的安全漏洞。它会排查高风险设置,比如特权访问和敏感目录挂载。

适用场景

  • ✓对集群进行安全审计时。
  • ✓调查安全事件时。
  • ✓启用新的安全规则之前。

技能链接

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-container-escape-detection/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-container-escape-detection/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“扫描我的 Kubernetes 集群,看看有没有允许容器逃逸的配置。”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具使用 Kubernetes 的 Python 库检查每个容器的设置。它会查找一些危险信号,比如 'privileged: true',或者能访问关键系统目录的卷挂载。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Performing Container Escape Detection

When to Use

  • When conducting security assessments that involve performing container escape detection
  • When following incident response procedures for related security events
  • When performing scheduled security testing or auditing activities
  • When validating security controls through hands-on testing

Prerequisites

  • Familiarity with container security concepts and tools
  • Access to a test or lab environment for safe execution
  • Python 3.8+ with required dependencies installed
  • Appropriate authorization for any testing activities

Instructions

Audit Kubernetes pods for container escape vectors including privileged mode, dangerous capabilities, host namespace sharing, and writable hostPath mounts.

from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()

pods = v1.list_pod_for_all_namespaces()
for pod in pods.items:
    for container in pod.spec.containers:
        sc = container.security_context
        if sc and sc.privileged:
            print(f"PRIVILEGED: {pod.metadata.namespace}/{pod.metadata.name}")

Key escape vectors:

  1. Privileged containers (full host access)
  2. CAP_SYS_ADMIN capability
  3. Host PID/Network/IPC namespace sharing
  4. Writable hostPath mounts to / or /etc
  5. Docker socket mount (/var/run/docker.sock)

Examples

# Check for docker socket mounts
for vol in pod.spec.volumes or []:
    if vol.host_path and "docker.sock" in (vol.host_path.path or ""):
        print(f"Docker socket exposed: {pod.metadata.name}")
常见问题

什么是“容器逃逸”?

指运行在容器内的程序,成功访问或控制了容器所在服务器的操作系统。这本来是不应该发生的。

什么是“能力”(capabilities)?

这是容器可以拥有的一些特殊权限。其中一些,比如 CAP_SYS_ADMIN,权限非常大,如果配置不当就会很危险。

什么是“hostPath 挂载”?

指把服务器(宿主机)上的某个目录共享给容器。如果挂载了 '/' 或 '/etc' 这类敏感目录,容器就可能获取服务器上重要文件的访问权限。

详情

作者的原始描述

Audits container and pod configuration for escape-enabling misconfiguration using the Kubernetes Python client - privileged flags, dangerous capability grants, host path mounts, shared namespaces, and CVE-2022-0492 style cgroup abuse. Use when sweeping a cluster for workloads that could break out, producing a posture report, or checking configuration before enforcement is switched on. Keywords: pr

repo: mukul975/Anthropic-Cybersecurity-Skills

热度

GitHub 星标
35k
排名
#8207
许可证
Apache-2.0
更新时间
2026/8/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能