Container Security 标志

Container Security

社区
brucesongs
container-security

Container security covers the complete lifecycle from image building, registry management, runtime protection, to orchestration platform (Kubernetes) security.

Add to TypingMind

概览

发布者brucesongs
代码仓库kali-claw
技能名称container-security
星标数
70
复刻数
18
附带文件
15
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 15 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 brucesongs 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Container Security AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/brucesongs/kali-claw/tree/main/skills/container-security
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/brucesongs/kali-claw.git /tmp/kali-claw
mkdir -p .claude/skills
cp -r /tmp/kali-claw/skills/container-security .claude/skills/container-security
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Container Security,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Container Security。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Container Security 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Skill: Container Security

Supplementary Files:

  • payloads.md — Container security testing attack payloads, categorized by image analysis, escape techniques, Kubernetes security, runtime security, registry security, network policies, secret detection, and privilege escalation
  • test-cases.md — 11 structured test cases covering image security, container runtime, Kubernetes, networking, and advanced scenarios

Summary

Container Security skill domain covering cloud operations.

Tools: trivy, docker-bench-security, kubeaudit, falco, clair, grype

Domain: cloud

MITRE ATT&CK: TA0008-Lateral Movement

Description

Container security covers the complete lifecycle from image building, registry management, runtime protection, to orchestration platform (Kubernetes) security. The core objective is to identify configuration flaws, known vulnerabilities, and privilege abuse in container environments, and to verify the effectiveness of container isolation mechanisms.

Mastering this skill requires a deep understanding of Docker architecture (namespaces, cgroups, union filesystem), Kubernetes RBAC and Network Policy, as well as the underlying principles of container escape. The attacker's perspective focuses on breaking out of container isolation from within to obtain host privileges, while the defender's perspective focuses on trusted image signing, least privilege, and runtime monitoring.


Use Cases

  1. Container Image Vulnerability Assessment - Scan images for known CVEs, configuration flaws, and hardcoded secrets
  2. Container Escape Testing - Verify whether privileged containers, mounted volumes, and kernel vulnerabilities can be exploited to escape to the host
  3. Kubernetes Security Audit - Check RBAC configuration, Pod Security Standards, and Network Policies
  4. CI/CD Shift-Left Security - Integrate image scanning and security policies into build pipelines
  5. Runtime Anomaly Detection - Monitor in-container processes, network connections, and filesystem changes
  6. CIS Benchmark Compliance - Evaluate Docker and Kubernetes configurations against CIS security benchmarks

Core Tools

ToolPurposeCommand Example
trivyAll-in-one image/filesystem/repository/K8s configuration scannertrivy image nginx:latest
docker-bench-securityCIS Docker Benchmark automated checksdocker-bench-security -c 1,2,3
kubeauditKubernetes security configuration auditkubeaudit all
falcoRuntime behavior monitoring and anomaly detectionfalco -r rules.yaml
clairStatic container vulnerability analysis serviceclairctl analyze --image nginx:latest
grypeFast vulnerability scanning with SBOM input supportgrype nginx:latest

Methodology

Attack Chain

Image Analysis      Registry Security   Runtime Escape     Orchestration      Host Compromise
(trivy scan,      (Unauthenticated    (Privileged       Attack             (Post-escape
 CVE matching)     access, image       container,        (RBAC abuse,       privilege
                    tampering)         kernel vuln)      ServiceAccount)    escalation)
    |               |                  |                |               |
    v               v                  v                v               v
 Credential       Malicious Image     Namespace        Cluster-level     Root Access
 Leakage          Injection           Breakout         Lateral Movement  (Host Control)
 (Env vars,       (Supply chain       (cgroup/ptrace)  (Secret theft)
  hardcoded keys)  attack)

Phase Details:

  1. Image Analysis - Scan image layer filesystems to identify known vulnerabilities (CVEs), sensitive file leakage, and improper configurations
  2. Registry Security - Detect unauthenticated Docker Registry access, verify image signatures and integrity
  3. Runtime Escape - Exploit privileged mode, sensitive path mounts (/var/run/docker.sock), and kernel vulnerabilities to break container isolation
  4. Orchestration Platform Attack - Abuse overly permissive RBAC, default ServiceAccount tokens, and unprotected API Servers
  5. Host Compromise - Obtain host root privileges from the escaped container, completing lateral movement and persistence

Defense Perspective

  • Image Signing - Use cosign/Notary to sign and verify images, preventing supply chain attacks
  • Read-Only Filesystem - Set container root filesystem to read-only, limiting attacker write capability
  • Network Policy - Use K8s Network Policy to restrict inter-Pod communication, implementing micro-segmentation
  • Pod Security Standards - Enforce Restricted/Baseline policies, prohibiting privileged containers
  • Runtime Monitoring - Use Falco to detect anomalous processes, sensitive file access, and privilege escalation behavior
  • Minimal Base Images - Use distroless or scratch images to reduce attack surface

Practical Steps

1. Image Vulnerability Scanning and Analysis

Use trivy, grype, dockle, and other tools to scan images for CVEs, configuration flaws, and sensitive information leakage.

2. Container Escape Detection and Exploitation

Detect container environment indicators, privileged mode, and sensitive mount points; exploit docker.sock mounts and kernel vulnerabilities for escape.

3. Kubernetes Security Audit

Enumerate RBAC bindings, ServiceAccount permissions, and Secret mounts; use kubeaudit for automated auditing.

4. Runtime Security Monitoring

Check container process capability configurations; use Falco rules to detect shell execution, sensitive file access, and escape behavior.

5. CIS Benchmark Compliance Checks

Use docker-bench-security and kube-bench for Docker/Kubernetes security baseline assessment.

Detailed payloads in payloads.md, complete test checklist in test-cases.md.


Common Pitfalls

  • Scanning images without checking runtime configuration: A clean vulnerability scan does not mean a container is secure. A fully patched image running in privileged mode with docker.sock mounted is more dangerous than an outdated image running with least privilege and a read-only filesystem.
  • Ignoring ServiceAccount tokens in Kubernetes: Every Pod receives an automatically mounted ServiceAccount token by default. If the ServiceAccount has excessive RBAC permissions, any code running in the Pod (including attacker code after exploitation) inherits those cluster-level privileges.
  • Neglecting supply chain verification: Pulling images by tag (e.g., nginx:latest) rather than by digest means the image content can change without notice. An upstream image compromise or tag hijacking can introduce malicious code into your infrastructure without any configuration change on your end.

Automation and Scripting

Automate container security scanning by integrating trivy into CI/CD pipelines to block builds with Critical/High CVEs from being pushed to production registries. Use kubeaudit in scheduled CronJobs to continuously audit Kubernetes RBAC configurations and alert on deviations. Script falco rule testing by generating expected benign and malicious events in a test cluster and verifying that alerts fire correctly. Build custom Python scripts using the Docker SDK to enumerate all running containers and their mount points for rapid privilege escalation surface assessment.

Reporting and Documentation

Container security reports should separate findings by layer: image vulnerabilities (CVE list with CVSS scores), runtime configuration issues (privileged mode, cap-add, sensitive mounts), orchestration misconfigurations (RBAC, Network Policies, Pod Security Standards), and supply chain risks (unsigned images, unverified registries). For each container escape finding, document the escape path from inside the container to host access with specific commands and outputs. Include CIS Benchmark compliance scores as a measurable baseline for tracking improvement over time.

Legal and Ethical Considerations

Container escape testing in shared Kubernetes clusters (multi-tenant environments) carries significant risk of affecting other tenants. Verify that the engagement scope covers escape attempts and coordinate with the cluster operations team to ensure testing occurs in an isolated namespace or during a maintenance window. Container security tools like trivy and kubeaudit are generally safe to run in production for scanning, but active exploitation techniques (escape attempts, privilege escalation) should be performed in dedicated test environments whenever possible.

Integration with Other Tools

Container security findings connect to multiple adjacent skill domains. Image vulnerability results from trivy feed into vulnerability-assessment for CVE tracking and remediation prioritization. Kubernetes RBAC misconfigurations discovered by kubeaudit inform post-exploitation lateral movement planning. Container escape techniques that reach the host transition to host-level post-exploitation methodology. Cloud metadata access from within containers (via SSRF or direct access) connects to cloud-security assessment of the broader infrastructure.

Case Studies and Examples

  • docker.sock escape: A web application container had the Docker socket mounted for "log collection." An attacker who gained RCE in the web app used the Docker CLI to create a new privileged container mounting the host's root filesystem, achieving full host compromise in under 60 seconds.
  • Kubernetes ServiceAccount escalation: A pod's default ServiceAccount had cluster-admin RBAC bindings due to a misconfigured Helm chart. An attacker who compromised the application used the mounted token to read all Secrets across all namespaces, including database credentials and TLS private keys.
  • Supply chain attack via image poisoning: A development team used node:latest as their base image. An upstream compromise of the Node.js Docker image (before it was detected and pulled) would have deployed malicious code to all downstream builds. Shifting to pinned digests and cosign verification prevented this vector.

Detection Methods

Container security detection combines runtime monitoring (Falco, Tetragon), Kubernetes audit logging, image scanning (Trivy, Grype), and cloud-native SIEM integration. Understanding detection patterns helps testers operate more stealthily and helps defenders prioritize monitoring.

Container Runtime Indicators

  • Unexpected shell execution: Processes like /bin/sh, /bin/bash spawned inside non-shell containers (web servers, databases); detected by Falco default rules.
  • Sensitive file access: Reads of /etc/shadow, /proc/sysrq-trigger, /proc/1/root, host paths mounted via hostPath.
  • Anomalous syscalls: ptrace, keyctl, mount, unshare syscalls from inside containers indicate escape attempts.
  • Network anomalies: Reverse shells on non-standard ports; Tor / Tor-like traffic; DNS tunneling.
  • Capability misuse: CAP_SYS_ADMIN, CAP_DAC_READ_SEARCH, CAP_SYS_PTRACE invoked by non-privileged container processes.

Kubernetes API Server Indicators

  • Privileged Pod creation: Pod spec with privileged: true, hostPID: true, hostNetwork: true, hostPath mounts.
  • ServiceAccount token abuse: Pods mounting serviceAccountToken not declared in spec; access to /var/run/secrets/kubernetes.io/serviceaccount/token from unexpected processes.
  • RBAC escalation: clusterrolebindings.rbac.authorization.k8s.io create/update with subject = user (not service account).
  • Anonymous auth: API server with --anonymous-auth=true enabled; requests with no authentication.
  • kubectl exec patterns: kubectl exec on system pods (kube-apiserver, etcd); exec on pods in kube-system namespace from non-admin users.

Container Image / Registry Indicators

  • Image without digest pinning: Deployments using :latest or unpinned tags; vulnerable to supply chain attack.
  • Suspicious base images: Images from unknown registries, recently pushed images (<7 days), images with high CVSS vulnerabilities.
  • Cosign / Notation verification failure: Image signature missing or invalid; image verification bypassed via admission controller config.
  • Registry compromise: Pulls from compromised public registries (e.g., Docker Hub free tier); anomalous pull volume.

CI/CD Pipeline Indicators

  • Build argument injection: CI logs showing unexpected build args; image layers containing secrets not in .dockerignore.
  • Cache poisoning: Build cache from untrusted contributor; CI runs with cache-from external source.
  • Dependency confusion: Build pulls package from public registry when private package exists; anomalous package install.
  • Run-as-root in CI: Build containers running as root instead of non-root user.

SIEM Detection Rules

  • Falco default rules: Terminal shell in container, Contact Kubernetes API Server from Container, Write below etc, Read sensitive file.
  • Tetragon: eBPF-based runtime security; policies for syscalls, capabilities, namespaces.
  • Splunk SPL (K8s Audit): index=k8s verb=create resource=pods requestObject.spec.securityContext.privileged=true
  • Splunk SPL (Container): index=container sourcetype=falco rule="Terminal shell in container"
  • Sigma rule: sigma/rules/cloud/k8s_privileged_pod.yml
  • AWS GuardDuty EKS Protection: Detector for anomalous kubectl access patterns.

Defense Evasion Techniques

Runtime Stealth

  • Static binaries over interpreted scripts: Drop statically-compiled nmap instead of Python nmap-python; avoids Python interpreter dependency on Falco rules.
  • LOLBins (Living off the Land): Use existing container binaries (wget, curl, awk) instead of dropping new tools; avoids write events to filesystem.
  • Memory-only execution: Use memfd_create() syscall to run tools without disk artifacts; reflective DLL injection.
  • Process name spoofing: Rename malicious process to nginx or redis-server to blend with legitimate workload.
  • ** syscall proxying**: Use legitimate process (like nginx) to issue sensitive syscalls; inject code into worker process.

Container Escape Stealth

  • CVE selection: Choose newer, less-signatured CVEs (CVE-2024-1086 netfilter) over well-known ones (CVE-2022-0185); Falco rules lag.
  • Capability-based escape over privileged: Use CAP_SYS_ADMIN already in container spec rather than escalating to privileged; less suspicious.
  • Lesser-monitored syscalls: Use openat2, io_uring, bpf syscalls to evade default Falco rules.
  • Kernel namespace manipulation: unshare -U -r --map-root-user over setuid syscall; less signature coverage.
  • Cgroup v2 abuse: Cgroup v2 has fewer monitoring tools; exploit cgroup escape via v2-specific paths.

Kubernetes Stealth

  • Existing ServiceAccount over new RBAC: Use mounted SA token in compromised Pod; avoid creating new RoleBinding (logs).
  • Sidecar injection over new Pod: Inject into existing Pod via shared process namespace; avoids Pod creation event.
  • ConfigMap over Secret: Embed payload in ConfigMap (not flagged as sensitive); fetch via API later.
  • CronJob one-shot Pod: Schedule short-lived Pod via CronJob; complete action before runtime detection sees it.
  • PreStop hook abuse: Use existing Pod's preStop lifecycle hook to execute payload; blends with legitimate lifecycle.
  • HostPID/HostNetwork only: Skip privileged: true; use hostPID and hostNetwork which provide many capabilities with less alarming spec.

Image / Supply Chain Stealth

  • Multi-layer image obfuscation: Hide payload in lower image layers; lazy scanners may miss it.
  • Cosign signature theft: Steal cosign private key; sign malicious image as legitimate.
  • Admission controller bypass: Modify MutatingWebhookConfiguration to allowlist malicious images.
  • Build cache poisoning: Push poisoned layer to shared cache; affects all downstream builds silently.
  • Dependency confusion hybrid: Name private package similar to public one; trigger fallback to public (attacker-controlled) version.
  • SBOM manipulation: Generate fake SBOM after build; submitted SBOM does not match actual image contents.

Network Stealth

  • Cloudflare / API Gateway proxy: Route container traffic through Cloudflare to mask C2 destination.
  • DNS tunneling over HTTP: Use DNS-over-HTTPS to bypass network policy that allows only HTTP/HTTPS.
  • WebSocket over HTTP: Use WebSocket for C2 (persistent connection); evades connection-counting rate limits.
  • PrivateLink / VPC peering: Use private network paths instead of internet; bypass egress monitoring.
  • Service mesh abuse: Use Istio / Linkerd mTLS for C2; encrypted traffic invisible to L7 monitoring.

Persistence Stealth

  • DaemonSet deployment: Use DaemonSet (runs on every node) over Deployment; harder to detect anomaly across many pods.
  • Admission webhook persistence: Deploy mutating webhook as persistence; intercepts all Pod creations.
  • CRD-based persistence: Use Custom Resource Definition to store payload; blends with operator-deployed resources.
  • etcd direct manipulation: Modify etcd directly (if access); bypasses API server audit log.
  • kubelet anonymous auth abuse: Kubelets with --anonymous-auth=true; appear as anonymous system user.

Advanced Techniques

Advanced container security testing includes: kernel exploit chains from within containers (CVE-2022-0185, CVE-2024-1086 for netfilter escape), cgroup and namespace manipulation for container breakout, seccomp profile bypass through allowed syscalls, Kubernetes admission controller bypass through direct API server access, and etcd database manipulation for cluster-level persistence. For CI/CD pipeline testing, explore build cache poisoning, dependency confusion attacks, and malicious build argument injection.

Tool Comparison Matrix

ToolBest ForSpeedCoverageSkill Level
trivyAll-in-one scanning (image/K8s/filesystem)FastVery broadBeginner
grypeFast vulnerability scanning with SBOMFastBroadBeginner
falcoRuntime behavior monitoringReal-timeBroadIntermediate
kubeauditK8s security configuration auditFastK8s-specificBeginner
docker-bench-securityCIS Docker Benchmark checksFastDocker-specificBeginner
clairStatic vulnerability analysis serviceModerateBroadIntermediate

Performance and Remediation

Image scanning performance varies significantly by tool and image size. Trivy and grype complete scans of typical application images (500MB-2GB) in 10-30 seconds, while larger base images with extensive package lists can take 2-5 minutes. For large-scale deployments, use trivy in server mode with a centralized vulnerability database. Falco runtime monitoring has minimal performance impact (<2% CPU overhead). Prioritize container security remediation in order: fix Critical CVEs in base images immediately, remove privileged mode and docker.sock mounts, enforce Pod Security Standards, implement Network Policies, deploy image signing (cosign/Notary) in CI/CD, and rotate all ServiceAccount tokens after any suspected compromise.

Hacker Laws

LawApplication in Container Security
Defense in DepthContainers are not a security boundary. Image scanning + signature verification + runtime monitoring + network policies must be layered together; no single layer can be trusted as the sole defense
Least PrivilegeContainers should not run as root by default, should not mount docker.sock, and should not use privileged mode. Every unnecessary permission is an escape vector
Assume BreachDesign monitoring systems assuming the container has already been compromised. Falco detects anomalous processes, file access, and network connections for rapid response when escape occurs
Supply Chain TrustImages pass through multiple layers from build to runtime. Pulling images without verifying signatures means trusting all upstream sources, which breeds supply chain attacks
Minimize Attack SurfaceDistroless images have no shell or package manager; even if an attacker is inside the container, they lack tools. Reducing attack surface is more effective than adding defenses

Learning Resources

This skill's supplementary files: payloads.md, test-cases.md Related skills: skills/cloud-security/SKILL.md, skills/post-exploitation/SKILL.md External resources:

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Container Security AI 技能有什么作用?

Container security covers the complete lifecycle from image building, registry management, runtime protection, to orchestration platform (Kubernetes) security.

为什么在 TypingMind 中使用 Container Security?

因为您只需安装一次,就能搭配任何模型使用。Container Security 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Container Security?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/brucesongs/kali-claw/tree/main/skills/container-security。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Container Security?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Container Security 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Container Security 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Container Security AI 技能免费吗?

是的。brucesongs 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇