Challenge
DifficultyEasy
Learner activity0 solved of 4 attempts

Install Falco and Catch curl and wget in Pods With a Custom Rule

Install Falco with the modern eBPF driver on a Kubernetes worker node, add a custom rule that catches curl and wget started in Pods, and find its alert in the Falco service logs. Practice adding custom Falco rules and reading their alerts.

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

  1. Install Falco on node-01 with the modern eBPF driver (see Install on a host (DEB, RPM)). The Falco service must be running and must start again after a reboot.
  2. Add the rule above to Falco on node-01 without changing it, either in falco_rules.local.yaml or in a new .yaml file in the rules.d directory, and leave the default falco_rules.yaml as it is.
  3. Create a Pod named falco-test in the default namespace with the image nginx:stable-alpine, and download https://labs.iximiuz.com/ in it with curl or wget.
  4. Save the logs of the modern eBPF Falco service to /home/laborant/falco.log on node-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:

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:

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:


⚒ Test Cases

Problem
Solution
Start
Tasks