搭建 Falco 运行时安全检测

适用场景

需要检测容器内的异常进程、文件访问、网络连接和提权行为。Falco 基于 eBPF 或内核模块采集系统调用,按规则告警,适合 Kubernetes 运行时安全。

前置条件

步骤

  1. 安装 Falco:
helm repo add falcosecurity https://falcosecurity.github.io/charts
helm install falco falcosecurity/falco \
  --namespace falco --create-namespace \
  --set driver.kind=ebpf \
  --set tty=true
kubectl -n falco get pods
  1. 查看告警:
kubectl -n falco logs -l app.kubernetes.io/name=falco -f
  1. 安装 Falcosidekick 转发告警:
helm upgrade falco falcosecurity/falco \
  --namespace falco \
  --set falcosidekick.enabled=true \
  --set falcosidekick.config.slack.webhookurl='https://hooks.slack.com/...'
  1. 自定义规则:
kubectl -n falco create configmap falco-rules \
  --from-file=custom_rules.yaml=./custom_rules.yaml

规则示例:

- rule: Shell in container
  desc: Detect shell spawned in container
  condition: spawned_process and container and shell_procs
  output: Shell spawned (user=%user.name container=%container.name command=%proc.cmdline)
  priority: WARNING
  1. 排除已知误报:
- rule: Shell in container
  exceptions:
  - name: known_admin
    fields: [container.name, proc.cmdline]
    values:
      - [debug-tools, "/bin/sh -c echo ok"]

验证

回滚

常见坑

相关命令