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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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:
- Privileged containers (full host access)
- CAP_SYS_ADMIN capability
- Host PID/Network/IPC namespace sharing
- Writable hostPath mounts to / or /etc
- 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
热度
- GitHub 星标
- 35k
- 排名
- #8207
- 许可证
- Apache-2.0
- 更新时间
- 2026/8/31
评论
- …
同一仓库的更多技能
abusing-dpapi-for-credential-access
35k为你的 AI 智能体提供针对特定任务的现成指令,让它完成得更好、更快。
abusing-shadow-credentials-for-privesc
35k教你的 AI 智能体写出清晰、结构良好的文本。
achieving-cmmc-level-2-compliance
35k帮助你的智能体搭建符合 CMMC Level 2 合规要求的环境。它会落实安全要求,并管理必要的文档。
acquiring-disk-image-with-dd-and-dcfldd
35k帮助你的智能体创建硬盘的精确副本。这能确保调查过程中信息不丢失、不被篡改。