Detects container escape attempts using Falco runtime security rules in Kubernetes or Docker, monitoring syscalls, host filesystem mounts, nsenter, and privileged containers.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cybersecurity-skills-zh:detecting-container-escape-with-falco-rulesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Falco 是一个 CNCF 毕业的运行时安全工具,通过监控 Linux 系统调用来检测异常的容器行为。它使用规则引擎来识别容器逃逸技术,例如挂载主机文件系统、访问敏感主机路径、加载内核模块以及利用特权容器能力。
Falco 是一个 CNCF 毕业的运行时安全工具,通过监控 Linux 系统调用来检测异常的容器行为。它使用规则引擎来识别容器逃逸技术,例如挂载主机文件系统、访问敏感主机路径、加载内核模块以及利用特权容器能力。
# 添加 Falco Helm chart
helm repo add falcosecurity https://falcosecurity.github.io/charts
helm repo update
# 使用 eBPF 驱动安装 Falco
helm install falco falcosecurity/falco \
--namespace falco --create-namespace \
--set falcosidekick.enabled=true \
--set falcosidekick.webui.enabled=true \
--set driver.kind=ebpf \
--set collectors.containerd.enabled=true \
--set collectors.containerd.socket=/run/containerd/containerd.sock
# 验证
kubectl get pods -n falco
kubectl logs -n falco -l app.kubernetes.io/name=falco --tail=20
# 添加 Falco GPG 密钥和仓库
curl -fsSL https://falco.org/repo/falcosecurity-packages.asc | \
sudo gpg --dearmor -o /usr/share/keyrings/falco-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/falco-archive-keyring.gpg] https://download.falco.org/packages/deb stable main" | \
sudo tee /etc/apt/sources.list.d/falcosecurity.list
sudo apt-get update
sudo apt-get install -y falco
# 启动 Falco
sudo systemctl enable falco
sudo systemctl start falco
- rule: Container Mounting Host Filesystem
desc: 检测容器尝试挂载主机文件系统
condition: >
spawned_process and container and
proc.name = mount and
(proc.args contains "/host" or proc.args contains "nsenter")
output: >
容器正在挂载主机文件系统
(user=%user.name container_id=%container.id container_name=%container.name
image=%container.image.repository command=%proc.cmdline %evt.args)
priority: CRITICAL
tags: [container, escape, T1611]
- rule: Nsenter Execution in Container
desc: 检测使用 nsenter 逃逸容器命名空间
condition: >
spawned_process and container and proc.name = nsenter
output: >
容器中执行了 nsenter - 潜在的逃逸尝试
(user=%user.name container_id=%container.id image=%container.image.repository
command=%proc.cmdline parent=%proc.pname)
priority: CRITICAL
tags: [container, escape, namespace, T1611]
- rule: Launch Privileged Container
desc: 检测特权容器被启动
condition: >
container_started and container and container.privileged=true
output: >
已启动特权容器
(user=%user.name container_id=%container.id container_name=%container.name
image=%container.image.repository)
priority: WARNING
tags: [container, privileged, T1610]
- rule: Write to Sysrq Trigger
desc: 检测写入 /proc/sysrq-trigger,这可能使主机崩溃或被控制
condition: >
open_write and container and fd.name = /proc/sysrq-trigger
output: >
从容器写入 /proc/sysrq-trigger
(user=%user.name container_id=%container.id image=%container.image.repository
command=%proc.cmdline)
priority: CRITICAL
tags: [container, escape, host-manipulation]
- rule: Container Loading Kernel Module
desc: 检测容器尝试加载内核模块
condition: >
spawned_process and container and
(proc.name in (insmod, modprobe) or
(proc.name = init_module))
output: >
从容器加载内核模块
(user=%user.name container_id=%container.id image=%container.image.repository
command=%proc.cmdline)
priority: CRITICAL
tags: [container, escape, kernel, T1611]
- rule: Write to Cgroup Release Agent
desc: 检测写入 cgroup release_agent,这是已知的容器逃逸向量
condition: >
open_write and container and
fd.name endswith release_agent
output: >
容器写入 cgroup release_agent - 逃逸尝试
(user=%user.name container_id=%container.id image=%container.image.repository
file=%fd.name command=%proc.cmdline)
priority: CRITICAL
tags: [container, escape, cgroup, CVE-2022-0492]
- rule: Container Reading Host Shadow File
desc: 检测容器通过挂载卷读取主机上的 /etc/shadow
condition: >
open_read and container and
(fd.name = /etc/shadow or fd.name startswith /host/etc/shadow)
output: >
容器正在读取主机 shadow 文件
(user=%user.name container_id=%container.id image=%container.image.repository
file=%fd.name command=%proc.cmdline)
priority: CRITICAL
tags: [container, credential-access, T1003]
- rule: Container Accessing Docker Socket
desc: 检测容器访问 Docker socket,这允许控制主机
condition: >
(open_read or open_write) and container and
fd.name = /var/run/docker.sock
output: >
容器正在访问 Docker socket
(user=%user.name container_id=%container.id image=%container.image.repository
command=%proc.cmdline)
priority: CRITICAL
tags: [container, escape, docker-socket, T1610]
# /etc/falco/rules.d/container-escape.yaml
- list: escape_binaries
items: [nsenter, chroot, unshare, mount, umount, pivot_root]
- macro: container_escape_attempt
condition: >
spawned_process and container and
proc.name in (escape_binaries)
- rule: Container Escape Binary Execution
desc: 检测执行通常用于容器逃逸的二进制文件
condition: container_escape_attempt
output: >
容器中执行了逃逸相关二进制文件
(user=%user.name container=%container.name image=%container.image.repository
command=%proc.cmdline parent=%proc.pname pid=%proc.pid)
priority: CRITICAL
tags: [container, escape, mitre_T1611]
- rule: Sensitive File Access from Container
desc: 检测容器访问敏感主机文件
condition: >
(open_read or open_write) and container and
(fd.name startswith /proc/1/ or
fd.name = /etc/shadow or
fd.name = /etc/kubernetes/admin.conf or
fd.name startswith /var/lib/kubelet/)
output: >
从容器访问了敏感文件
(container=%container.name image=%container.image.repository
file=%fd.name command=%proc.cmdline user=%user.name)
priority: CRITICAL
tags: [container, sensitive-file, mitre_T1005]
# /etc/falco/falco.yaml(关键设置)
rules_files:
- /etc/falco/falco_rules.yaml
- /etc/falco/rules.d/container-escape.yaml
json_output: true
json_include_output_property: true
json_include_tags_property: true
log_stderr: true
log_syslog: true
log_level: info
priority: WARNING
stdout_output:
enabled: true
syslog_output:
enabled: true
http_output:
enabled: true
url: http://falcosidekick:2801
insecure: true
grpc:
enabled: true
bind_address: "unix:///run/falco/falco.sock"
threadiness: 8
grpc_output:
enabled: true
# Falcosidekick values.yaml
config:
slack:
webhookurl: "https://hooks.slack.com/services/XXXXX"
minimumpriority: "warning"
messageformat: |
*{{.Priority}}* - {{.Rule}}
容器: {{.OutputFields.container_name}}
镜像: {{.OutputFields.container_image_repository}}
命令: {{.OutputFields.proc_cmdline}}
# 模拟容器逃逸尝试(在测试容器中)
kubectl run test-escape --image=alpine --restart=Never -- sh -c "cat /etc/shadow"
# 模拟 nsenter
kubectl run test-nsenter --image=alpine --restart=Never --overrides='{"spec":{"hostPID":true}}' -- nsenter -t 1 -m -u -i -n -- cat /etc/hostname
# 检查 Falco 告警
kubectl logs -n falco -l app.kubernetes.io/name=falco --tail=50 | grep -i escape
npx claudepluginhub killvxk/cybersecurity-skills-zhDetects container escape attempts in real-time using Falco rules monitoring syscalls, host filesystem mounts, file access, and privilege escalations in Kubernetes or Docker.
Detects container escape attempts in real-time using Falco runtime security rules that monitor syscalls, file access, and privilege escalation. Useful for SOC analysts and Kubernetes security monitoring.
Detects container escape attempts in real-time using Falco runtime security rules that monitor syscalls, file access, and privilege escalation. Useful for SOC analysts and Kubernetes security monitoring.