What it does
Falco (CNCF) reads kernel events (system calls) with an eBPF probe and checks them against rules: a shell in a container, a write below /etc, reading /etc/shadow, a new outbound connection from a database, a privileged container start, kubectl exec into a pod. Alerts go to stdout, files, syslog, or through Falcosidekick to Slack, Loki, Elasticsearch and more.
Falco is part of the CKS exam (read and change rules, find the offending pod).
How to write it
falco [-r RULES_FILE] [-o key=value] [--list] [-U]
systemctl status falco-modern-bpfMain parts
Rule file parts
rule/desc/condition/output/priority- One detection.
macro- Reusable condition part.
list- Reusable list of values (binaries, paths).
append/override- Change default rules without editing them.
priorityEMERGENCY…DEBUG- Severity of the rule.
Options 7
Most used
Flags
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Install on Kubernetes with Helm
2Trigger a test alert
3Install on RHEL as a service
4Write your own rule
cat /etc/falco/rules.d/shop.yaml - rule: Shell in shop container desc: Someone started a shell in a shop pod condition: spawned_process and container and k8s.ns.name = "shop" and proc.name in (sh, bash, ash) output: "Shell in shop pod (user=%user.name pod=%k8s.pod.name cmd=%proc.cmdline)" priority: WARNING5Validate rules before restart
falco -V /etc/falco/rules.d/shop.yaml systemctl restart falco-modern-bpf6Add allowed programs to a default rule (no edit of the original)
cat /etc/falco/rules.d/exceptions.yaml - list: user_known_package_manager_in_container items: [apk] override: items: append7Find the fields you can use
8Send alerts to Slack with Falcosidekick
helm upgrade falco falcosecurity/falco -n falco --reuse-values --set falcosidekick.enabled=true --set falcosidekick.config.slack.webhookurl=https://hooks.slack.com/services/T000/B000/XXXX9JSON output for SIEMs
cat /etc/falco/config.d/json.yaml json_output: true file_output: { enabled: true, filename: /var/log/falco/events.json }10See which rules are loaded
falco -L | head -40
Nothing matches this filter.
Watch out
- Falco detects, it does not block. Combine with Pod Security, NetworkPolicies and seccomp.
- Tune noisy rules with exceptions; alert fatigue hides real attacks.
Files
/etc/falco/falco.yaml- Main config.
/etc/falco/falco_rules.yaml- Default rules (do not edit).
/etc/falco/rules.d/- Your rules and overrides.
Tips to remember
- CKS: know where the rules are, how to change the output format, and how to find the container from an alert.
Exit codes
0 | Success. |
1 | Error (bad rules or config). |