Runtime Security & Threat Detection with Falco and eBPF
When to Use This Skill
Triggers — load this skill when:
- Runtime detection coverage is needed for containers or Kubernetes nodes
- A Falco rule must be written, scoped, or tuned against noise
- A runtime alert (shell in container, sensitive mount, crypto-miner) needs triage
Route elsewhere when:
- Pre-deploy image hardening ->
docker-containerization-basics
- Full incident containment and forensics ->
secops-incident-triage-forensics
- Cloud control-plane misconfiguration ->
cloud-security-posture-cspm-cis
1. Custom Falco Security Rules (falco_rules.local.yaml)
- rule: Terminal Shell Spawned Inside Production Container
desc: Detect interactive shell execution (bash/sh) within production pods
condition: >
spawned_process and container
and (k8s.ns.name = "production")
and (proc.name in (bash, sh, zsh, ksh, csh))
and not user_expected_debug_shell
output: >
CRITICAL: Shell spawned in container (user=%user.name pod=%k8s.pod.name
ns=%k8s.ns.name image=%container.image.repository cmdline=%proc.cmdline)
priority: CRITICAL
tags: [container, mitre_execution, pci_dss]
- rule: Sensitive File Access Under /etc
desc: Detect unexpected modification of system configuration files
condition: >
open_write and container
and fd.name startswith "/etc"
and not proc.name in (dpkg, apt, apk)
output: >
WARNING: File modified in /etc (file=%fd.name proc=%proc.name container=%container.name)
priority: WARNING
tags: [filesystem, mitre_persistence]
2. Runtime Security Operational Playbook
- Alert Routing: Forward Falco alerts via Falcosidekick directly to Slack, PagerDuty, and SIEM (Elasticsearch/Splunk).
- Automated Containment: Integrate Falco with Kubernetes webhook responders to isolate or terminate compromised pods automatically.
- Read-Only Root Filesystems: Combine runtime monitoring with
readOnlyRootFilesystem: true in Pod Security Standards.
3. Tuning: Macros, Lists & Exceptions
Noise is a security failure, not an inconvenience: a muted channel detects nothing. Tune by
narrowing the rule, never by disabling it.
- list: trusted_debug_images
items: ["company/debug-toolbox", "company/netshoot"]
- macro: from_trusted_debug
condition: container.image.repository in (trusted_debug_images)
- rule: Terminal shell in container
desc: A shell was spawned in a container outside the sanctioned debug path
condition: >
spawned_process and container and shell_procs
and not from_trusted_debug
and not k8s.ns.name in (kube-system, falco)
output: "Shell in container (user=%user.name ns=%k8s.ns.name pod=%k8s.pod.name cmd=%proc.cmdline)"
priority: WARNING
tags: [container, shell, mitre_execution]
exceptions:
- name: ci_test_runner
fields: [k8s.ns.name, proc.name]
comps: [=, =]
values: [[ci-runners, sh]]
Discipline that keeps the signal alive:
- Prefer
exceptions: (structured, reviewable, per-field) over appending and not ... chains.
- Set
priority so paging maps to CRITICAL/ERROR only; WARNING goes to a queue, not a pager.
- Review the top five noisiest rules weekly; a rule firing hundreds of times a day is either
mis-scoped or describes normal behaviour that should be fixed at the source.
1---2name: container-runtime-security-falco3description: Runtime threat detection with Falco and eBPF: custom rule authoring, syscall and Kubernetes audit sources, macros, lists and exceptions for tuning, alert routing, and response playbooks. Use when alerting on attacker behaviour inside a running container such as an interactive shell being opened in production, writing or tuning a noisy Falco rule, or triaging a runtime alert.4---56# Runtime Security & Threat Detection with Falco and eBPF78## When to Use This Skill910**Triggers — load this skill when:**1112- Runtime detection coverage is needed for containers or Kubernetes nodes13- A Falco rule must be written, scoped, or tuned against noise14- A runtime alert (shell in container, sensitive mount, crypto-miner) needs triage1516**Route elsewhere when:**1718- Pre-deploy image hardening -> `docker-containerization-basics`19- Full incident containment and forensics -> `secops-incident-triage-forensics`20- Cloud control-plane misconfiguration -> `cloud-security-posture-cspm-cis`2122## 1. Custom Falco Security Rules (`falco_rules.local.yaml`)2324```yaml25- rule: Terminal Shell Spawned Inside Production Container26 desc: Detect interactive shell execution (bash/sh) within production pods27 condition: >28 spawned_process and container29 and (k8s.ns.name = "production")30 and (proc.name in (bash, sh, zsh, ksh, csh))31 and not user_expected_debug_shell32 output: >33 CRITICAL: Shell spawned in container (user=%user.name pod=%k8s.pod.name34 ns=%k8s.ns.name image=%container.image.repository cmdline=%proc.cmdline)35 priority: CRITICAL36 tags: [container, mitre_execution, pci_dss]3738- rule: Sensitive File Access Under /etc39 desc: Detect unexpected modification of system configuration files40 condition: >41 open_write and container42 and fd.name startswith "/etc"43 and not proc.name in (dpkg, apt, apk)44 output: >45 WARNING: File modified in /etc (file=%fd.name proc=%proc.name container=%container.name)46 priority: WARNING47 tags: [filesystem, mitre_persistence]48```4950---5152## 2. Runtime Security Operational Playbook53541. **Alert Routing**: Forward Falco alerts via Falcosidekick directly to Slack, PagerDuty, and SIEM (Elasticsearch/Splunk).552. **Automated Containment**: Integrate Falco with Kubernetes webhook responders to isolate or terminate compromised pods automatically.563. **Read-Only Root Filesystems**: Combine runtime monitoring with `readOnlyRootFilesystem: true` in Pod Security Standards.5758---5960## 3. Tuning: Macros, Lists & Exceptions6162Noise is a security failure, not an inconvenience: a muted channel detects nothing. Tune by63narrowing the rule, never by disabling it.6465```yaml66- list: trusted_debug_images67 items: ["company/debug-toolbox", "company/netshoot"]6869- macro: from_trusted_debug70 condition: container.image.repository in (trusted_debug_images)7172- rule: Terminal shell in container73 desc: A shell was spawned in a container outside the sanctioned debug path74 condition: >75 spawned_process and container and shell_procs76 and not from_trusted_debug77 and not k8s.ns.name in (kube-system, falco)78 output: "Shell in container (user=%user.name ns=%k8s.ns.name pod=%k8s.pod.name cmd=%proc.cmdline)"79 priority: WARNING80 tags: [container, shell, mitre_execution]81 exceptions:82 - name: ci_test_runner83 fields: [k8s.ns.name, proc.name]84 comps: [=, =]85 values: [[ci-runners, sh]]86```8788Discipline that keeps the signal alive:8990- Prefer `exceptions:` (structured, reviewable, per-field) over appending `and not ...` chains.91- Set `priority` so paging maps to CRITICAL/ERROR only; WARNING goes to a queue, not a pager.92- Review the top five noisiest rules weekly; a rule firing hundreds of times a day is either93 mis-scoped or describes normal behaviour that should be fixed at the source.