Challenge
DifficultyEasy
Learner activity No attempts yet

Detect Download Tools in Pods With Falco

Install Falco with the modern eBPF driver on a Kubernetes worker node, add a custom rule for download tools 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 rules of Falco have no rule for these commands, so the security team wrote one 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)). Its service must be running and start after a reboot.
  2. Add the rule above to Falco on node-01, without changing it. Use either of these two places:
    • the local rules file, /etc/falco/falco_rules.local.yaml
    • a new rules file of your own in /etc/falco/rules.d/, with any name that ends in .yaml

    Do not edit the default rules file, /etc/falco/falco_rules.yaml.
  3. Create a Pod named falco-test in the default namespace with the image nginx:stable, and run curl https://labs.iximiuz.com/ in it.
  4. Save the logs of the Falco service to /home/laborant/falco.log on node-01. They must contain the alert for this curl 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