Install Falco and Catch curl and wget in Pods With a Custom Rule
Scenario
Attackers who get into a container often fetch their tools with curl or wget.
The default Falco rules do not alert on these commands, so the security team wrote a rule
and asked you to add it.
All Pods run on node-01, the only worker node of the cluster. kubectl works on both node-01 and cplane-01.
This is the rule of the security team:
- rule: Download Tool in Container
desc: Detect curl or wget started inside a container
condition: spawned_process and container and proc.name in (curl, wget)
output: "[CUSTOM] Download tool run (pod=%k8s.pod.name ns=%k8s.ns.name cmd=%proc.cmdline)"
priority: WARNING
tags: [custom]
Task
- Install Falco on
node-01with the modern eBPF driver (see Install on a host (DEB, RPM)). The Falco service must be running and must start again after a reboot. - Add the rule above to Falco on
node-01without changing it, either infalco_rules.local.yamlor in a new.yamlfile in therules.ddirectory, and leave the defaultfalco_rules.yamlas it is. - Create a Pod named
falco-testin thedefaultnamespace with the imagenginx:stable-alpine, and downloadhttps://labs.iximiuz.com/in it withcurlorwget. - Save the logs of the modern eBPF Falco service to
/home/laborant/falco.logonnode-01. They must contain the alert for this download command.
Hint 1: Installing Falco
The Falco docs show how to trust the key of the Falco repository, add the repository, and install the package.
During the installation, Falco asks which driver to use.
The modern eBPF driver needs a recent kernel, so check the kernel of node-01 with uname -r first.
The name of the systemd service that Falco runs depends on the driver you choose.
Docs:
- Install on a host (DEB, RPM) (Falco)
- Kernel Events (Falco)
Hint 2: Custom rules
The rules_files setting in /etc/falco/falco.yaml lists the files and directories from which Falco loads rules, in order.
The local rules file and rules.d are already in the list, so the configuration needs no change.
Adding the rule to one of them is enough.
The custom rule uses macros from the default rules file, so validate the two files together with the -V flag of falco.
The service logs show which rules files the running Falco has loaded.
Docs:
- Basic Elements of Falco Rules (Falco)
- Custom Ruleset (Falco)
Hint 3: Reading the alerts
journalctl shows the logs of a single systemd unit.
Look for the text that starts the output of the custom rule.
Docs:
- Falco Outputs (Falco)
- journalctl(1) (Linux manual page)
⚒ Test Cases
Understanding the challenge
The cluster has one worker node, node-01, and every Pod runs there because cplane-01 is tainted.
Falco runs as a service on a node and sees only the processes of that node, so it has to be installed on node-01.
The task has four parts:
- Install Falco with the modern eBPF driver, and keep its service running and enabled.
- Add the custom rule to the local rules file or to your own file in
rules.d. - Create the
falco-testPod and download a page in it withcurlorwget. - Save the service logs, with the custom alert, to
/home/laborant/falco.log.
How Falco works
Drivers and services
Falco reads system calls from the kernel through a driver. The package ships one systemd unit per driver:
falco-modern-bpf.service: the modern eBPF probe. It is built into the Falco binary, so nothing is compiled or downloaded for the kernel. It needs a kernel with BTF support, which recent kernels such as the 6.1 kernel ofnode-01have.falco-kmod.service: a kernel module, which needs kernel headers and a build toolchain, or a prebuilt module for the exact kernel.
The installer asks which driver to use, then enables and starts the matching unit.
The /etc/falco directory
The package creates this directory on node-01:
/etc/falco
├── falco.yaml
├── config.d
│ ├── engine-kind-falcoctl.yaml
│ └── falco.container_plugin.yaml
├── falco_rules.yaml
├── falco_rules.local.yaml
└── rules.d
It holds two kinds of files: configuration files tell Falco how to run, and rules files tell it what to report.
falco.yamlis the main configuration file, with settings such asrules_files. It does not need changes here.config.d/holds small configuration files with extra settings. They do not need changes here.falco_rules.yamlholds the default rules. An upgrade overwrites this file, so do not edit it.falco_rules.local.yamlis for your own rules. It holds only a comment after the installation.rules.d/is for your own rules in separate files. It is empty after the installation.
Falco loads the rules files in the order of the rules_files setting in falco.yaml:
rules_files:
- /etc/falco/falco_rules.yaml
- /etc/falco/falco_rules.local.yaml
- /etc/falco/rules.d
The order matters, because a rule can use macros and lists only from the files loaded before it.
The custom rule uses the macros spawned_process and container from falco_rules.yaml, so its file has to come later.
By default, watch_config_files: true makes Falco reload its configuration and rules files when they change on disk.
The process ID stays the same, and the reload shows up in the service logs.
Where to add a custom rule
The default rules in falco_rules.yaml have no rule for curl or wget in a container, so you have to add one.
The default configuration already loads two places for your own rules:
/etc/falco/falco_rules.local.yamlfits when you have a few rules and want them in one file.- Your own file in
/etc/falco/rules.d/fits when you want a separate file for each set of rules.
Both options give the same result, and an upgrade of the package does not overwrite your rules.
You only add a rule, so no setting in falco.yaml or config.d has to change.
The rule reports an event when all three parts of its condition are true:
spawned_processis true when a new process starts.containeris true when the process runs in a container.proc.name in (curl, wget)is true when the name of the process iscurlorwget.
When several rules match one event
For each event, Falco checks the rules in the load order shown above.
The rule_matching setting in falco.yaml decides what Falco does when a rule matches:
rule_matching: first
first(the default): Falco stops at the first rule that matches the event. The rules after it are not checked for this event, so they do not alert.all: Falco checks every rule, and each rule that matches alerts.
So with first, a custom rule alerts only for events that no default rule has matched before it.
No default rule matches the start of a curl or wget that is part of the container image, so the custom rule alerts for these commands.
If a default rule also matches an event, a custom rule for the same event stays silent, even though falco -V reports it as valid.
To get both alerts, set rule_matching: all in falco.yaml.
To get only the custom alert, disable the default rule with enabled: false in the local rules file.
For example, a wget that is installed into a running container is not part of the image.
Its start matches the default rule Drop and execute new binary in container first, so the custom rule does not alert for it.
This is why the challenge uses nginx:stable-alpine, which already has both curl and wget.
Alerts
A text alert is one line with the time of the event, the priority, and the rule's output with the fields filled in.
The custom rule's alerts start with Warning [CUSTOM] Download tool run.
Step 1: Check the kernel of node-01
On node-01:
uname -r
6.1.193
The 6.1 kernel supports the modern eBPF driver.
Step 2: Install Falco
All commands in this step run on node-01 and come from Install on a host (DEB, RPM).
The version numbers in your output may differ.
Trust the key of the Falco repository:
curl -fsSL https://falco.org/repo/falcosecurity-packages.asc | sudo gpg --dearmor -o /usr/share/keyrings/falco-archive-keyring.gpg
The command prints nothing when it succeeds.
It writes the key to /usr/share/keyrings/falco-archive-keyring.gpg.
Add the repository:
echo "deb [signed-by=/usr/share/keyrings/falco-archive-keyring.gpg] https://download.falco.org/packages/deb stable main" | sudo tee -a /etc/apt/sources.list.d/falcosecurity.list
deb [signed-by=/usr/share/keyrings/falco-archive-keyring.gpg] https://download.falco.org/packages/deb stable main
tee prints the line that it wrote to the file.
signed-by ties the repository to the key from the previous command.
Update the package list:
sudo apt-get update -y
The output ends with the Falco repository:
Get:17 https://d20hasrqv82i0q.cloudfront.net/packages/deb stable InRelease [4168 B]
Get:18 https://d20hasrqv82i0q.cloudfront.net/packages/deb stable/main amd64 Packages [10.5 kB]
Fetched 12.4 MB in 2s (5385 kB/s)
Reading package lists...
download.falco.org redirects to the CloudFront address, so apt shows that name.
The signature check passed, because apt prints no NO_PUBKEY error.
Install Falco and choose the modern eBPF driver:
sudo FALCO_DRIVER_CHOICE=modern_ebpf apt-get install -y falco
The important lines of the output (shortened here) are:
The following NEW packages will be installed:
falco
...
[POST-INSTALL] Configure falcoctl 'modern_ebpf' driver type:
...
├ type: modern_ebpf
...
[POST-INSTALL] Enable 'falco-modern-bpf.service':
Created symlink /etc/systemd/system/falco.service → /usr/lib/systemd/system/falco-modern-bpf.service.
Created symlink /etc/systemd/system/multi-user.target.wants/falco-modern-bpf.service → /usr/lib/systemd/system/falco-modern-bpf.service.
[POST-INSTALL] Start 'falco-modern-bpf.service':
The output shows what the installer did:
- Line 2: apt installs one package,
falco. - Lines 4 to 6: the post-install script selects the
modern_ebpfdriver. - Lines 8 to 11: it enables
falco-modern-bpf.service, adds thefalco.servicealias, and starts the service.
Without FALCO_DRIVER_CHOICE, the installer opens a dialog instead.
Choose Modern eBPF there. The installer then asks about automatic rules updates with falcoctl, which does not affect this challenge.
Step 3: Make sure the service is running
The installer already enabled and started the service.
On node-01, run the command anyway, because it does both and changes nothing when they are already done:
sudo systemctl enable --now falco-modern-bpf
The command prints nothing, because the service is already enabled and running.
Check its status (the output is shortened here):
systemctl status falco-modern-bpf --no-pager
● falco-modern-bpf.service - Falco: Container Native Runtime Security with modern ebpf
Loaded: loaded (/usr/lib/systemd/system/falco-modern-bpf.service; enabled; preset: enabled)
Active: active (running) since Mon 2026-11-30 18:25:47 UTC; 52s ago
...
- Line 2:
enabledmeans the service starts at boot. - Line 3:
active (running)means it runs now.
Step 4: Add the custom rule
On node-01, check where Falco looks for rules:
grep -n -A4 '^rules_files:' /etc/falco/falco.yaml
239:rules_files:
240- - /etc/falco/falco_rules.yaml
241- - /etc/falco/falco_rules.local.yaml
242- - /etc/falco/rules.d
243-
Three entries are listed:
- Line 2: the default rules file. An upgrade overwrites it, so leave it as it is.
- Line 3: the local file for your own rules.
- Line 4: the directory for your own rules files. They are loaded after the local file.
Both places come after the default rules, so a rule in them can use the macros from there. Choose one of the two options below, so that the rule is defined only once.
Option 1: Use the local rules file
The local file holds only a comment after the installation:
cat /etc/falco/falco_rules.local.yaml
# Your custom rules!
Open the file:
sudo vim /etc/falco/falco_rules.local.yaml
Add the rule below the comment:
# Your custom rules!
- rule: Download Tool in Container
desc: Detect curl or wget started inside a container
condition: spawned_process and container and proc.name in (curl, wget)
output: "[CUSTOM] Download tool run (pod=%k8s.pod.name ns=%k8s.ns.name cmd=%proc.cmdline)"
priority: WARNING
tags: [custom]
The quotes around output are required, because the text starts with [, which YAML reads as the start of a list.
Keep the comment on its own line.
YAML treats # as a comment only when a space comes before it, so priority: WARNING# Your custom rules! makes the priority invalid.
Validate the file together with the default rules, because the custom rule uses their macros. The default rules file stays untouched:
sudo falco -V /etc/falco/falco_rules.yaml -V /etc/falco/falco_rules.local.yaml
The output ends with the result for each file:
/etc/falco/falco_rules.yaml: Ok
/etc/falco/falco_rules.local.yaml: Ok
Falco reads its configuration and plugins first, then validates the two rule files without starting the engine.
Both files are Ok.
Reload the service so that the running Falco loads the new rule:
sudo systemctl reload falco-modern-bpf
The command prints nothing. Check which rules files the running Falco has loaded:
sudo journalctl -u falco-modern-bpf --no-pager -o cat | grep -A2 'Loading rules from' | tail -n 3
Loading rules from:
/etc/falco/falco_rules.yaml | schema validation: ok
/etc/falco/falco_rules.local.yaml | schema validation: ok
- Line 2: the default rules are loaded.
- Line 3: your local file is loaded and has passed the schema validation (
ok). Before the rule was added, the log showednone, because the file had no rules.
Option 2: Create your own file in rules.d
Falco loads every .yaml file in /etc/falco/rules.d, so you can choose any name.
This solution uses download-tools.yaml:
sudo vim /etc/falco/rules.d/download-tools.yaml
Paste the rule:
- rule: Download Tool in Container
desc: Detect curl or wget started inside a container
condition: spawned_process and container and proc.name in (curl, wget)
output: "[CUSTOM] Download tool run (pod=%k8s.pod.name ns=%k8s.ns.name cmd=%proc.cmdline)"
priority: WARNING
tags: [custom]
Validate the file together with the default rules:
sudo falco -V /etc/falco/falco_rules.yaml -V /etc/falco/rules.d/download-tools.yaml
/etc/falco/falco_rules.yaml: Ok
/etc/falco/rules.d/download-tools.yaml: Ok
Reload the service, and check which rules files the running Falco has loaded:
sudo systemctl reload falco-modern-bpf
sudo journalctl -u falco-modern-bpf --no-pager -o cat | grep -A3 'Loading rules from' | tail -n 4
Loading rules from:
/etc/falco/falco_rules.yaml | schema validation: ok
/etc/falco/falco_rules.local.yaml | schema validation: none
/etc/falco/rules.d/download-tools.yaml | schema validation: ok
- Line 2: the default rules are loaded.
- Line 3: the local file shows
none, because it has no rules. - Line 4: your own file is loaded and has passed the schema validation (
ok).
Falco also reloads its files on its own when they change on disk. It can miss a change that is made while the service is still starting, so an explicit reload is safer.
Falco reports nothing for a second or two while it reloads. If the alert for a command is missing, run the command again.
Step 5: Create the Pod
On cplane-01:
kubectl run falco-test --image=nginx:stable-alpine
pod/falco-test created
kubectl get pod falco-test -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
falco-test 1/1 Running 0 7s 10.244.1.2 node-01 <none> <none>
The Pod is Running on node-01, where Falco watches.
Step 6: Download a page in the Pod
On cplane-01:
kubectl exec -it falco-test -- curl https://labs.iximiuz.com/
curl prints the HTML of the page (shortened here):
<!DOCTYPE html><html lang="en" data-theme="cmyk"><head><meta charset="utf-8">...
nginx:stable-alpine also has wget, so you can download the page with it instead:
kubectl exec -it falco-test -- wget -qO- https://labs.iximiuz.com/
-q turns off the progress output, and -O- prints the page instead of saving it to a file.
The output is the same HTML.
On node-01, the alerts for wget look like this (shortened here):
sudo journalctl -u falco-modern-bpf --no-pager -o cat | grep 'cmd=wget'
07:18:33.433934998: Warning [CUSTOM] Download tool run (pod=falco-test ns=default cmd=wget -qO- https://labs.iximiuz.com/) container_id=68074e02bf76 ...
07:18:33.613884664: Warning [CUSTOM] Download tool run (pod=falco-test ns=default cmd=wget -qO- https://labs.iximiuz.com/) container_id=68074e02bf76 ...
07:18:33.613920039: Warning [CUSTOM] Download tool run (pod=falco-test ns=default cmd=wget -qO- https://labs.iximiuz.com/) container_id=68074e02bf76 ...
07:18:33.613952399: Warning [CUSTOM] Download tool run (pod=falco-test ns=default cmd=wget -qO- https://labs.iximiuz.com/) container_id=68074e02bf76 ...
One download gives several alerts.
In this image, wget is part of BusyBox, and for an HTTPS download it starts a child process.
That child still has the name wget while it starts, so the rule matches it too.
Step 7: Save and read the logs
On node-01:
sudo journalctl -u falco-modern-bpf --no-pager -o cat > /home/laborant/falco.log
The command prints nothing.
-u falco-modern-bpf selects the logs of the modern eBPF Falco service, --no-pager prints the whole log at once,
and -o cat leaves out the journal prefix (date, host, and process).
sudo applies to journalctl only. The redirect runs in your own shell, so the file belongs to laborant.
Find the alert for the Pod:
grep 'pod=falco-test' /home/laborant/falco.log
07:18:18.569187788: Warning [CUSTOM] Download tool run (pod=falco-test ns=default cmd=curl https://labs.iximiuz.com/) container_id=68074e02bf76 container_name=falco-test container_image_repository=docker.io/library/nginx container_image_tag=stable-alpine k8s_pod_name=falco-test k8s_ns_name=default
The alert has the priority Warning, and the fields of the rule's output are filled in: Pod falco-test, namespace default, and command curl https://labs.iximiuz.com/.
This shows that the running Falco has loaded your rule.
Falco appends the container and Kubernetes fields (container_id=... to k8s_ns_name=default) to every alert, because the container plugin is loaded.
Optional check: the default rules still work next to the custom rule.
To see it, read a sensitive file in the Pod from cplane-01:
kubectl exec falco-test -- cat /etc/shadow
On node-01, find the alert of the default rule Read sensitive file untrusted (shortened here):
sudo journalctl -u falco-modern-bpf --no-pager -o cat | grep 'Sensitive file' | grep falco-test
15:18:11.680168374: Warning Sensitive file opened for reading by non-trusted program | file=/etc/shadow ... process=cat ... command=cat /etc/shadow ... k8s_pod_name=falco-test k8s_ns_name=default
Optional check: the rule applies to all Pods on node-01, in every namespace.
To see it, create another Pod on cplane-01 and run curl in it:
kubectl create namespace demo
kubectl run web -n demo --image=nginx:stable
kubectl wait pod web -n demo --for=condition=Ready
kubectl exec -n demo web -- curl -sI http://localhost
On node-01, find the alert for this Pod:
sudo journalctl -u falco-modern-bpf --no-pager -o cat | grep 'ns=demo'
15:18:14.297872247: Warning [CUSTOM] Download tool run (pod=web ns=demo cmd=curl -sI http://localhost) container_id=359e1b35bf86 container_name=web container_image_repository=docker.io/library/nginx container_image_tag=stable k8s_pod_name=web k8s_ns_name=demo
Review
- Falco runs on each node as a service and sees only that node, so it belongs on the node where the Pods run.
- The modern eBPF driver needs no kernel module and no headers, which makes it the simplest choice on a recent kernel.
- A rule that is missing from the default rules goes in
falco_rules.local.yamlor in your own file inrules.d. A reload of the service loads it, and no configuration change is needed. - The default rules stay active next to the custom rule.
- With the default
rule_matching: first, only the first rule that matches an event alerts, and the default rules are checked before your own. - Each alert is one line in the service journal, so
journalctl -u falco-modern-bpfis where to read them.