Verifying Falco is Running
First, ensure that Falco has been installed on your host system as a package. You can verify its status by running:Ensure that Falco is installed and properly configured on your nodes before proceeding.
Creating an NGINX Pod
To generate events for Falco to monitor, deploy an NGINX pod with the following command:Monitoring Falco Logs
Open a new terminal session and SSH into node 01. Begin streaming Falco logs in real time to monitor security events:Interacting with the NGINX Container
In your initial terminal session, access the NGINX container’s shell by executing:Understanding Falco Rules
Falco uses a set of rules defined in a YAML configuration file to determine which events should trigger alerts. Each rule comprises five mandatory keys:- rule: A unique name for the rule.
- desc: A detailed description explaining the purpose of the rule.
- condition: A filtering expression applied to incoming events.
- output: The log message generated when the rule is triggered.
- priority: The severity level associated with the event.
Rule Breakdown
-
Rule & Description:
The rule “Detect Shell inside a container” is designed to trigger an alert when a shell (such as bash) is initiated within a container environment. -
Condition:
The condition uses a macro named “container” to ensure the event originates from within a container and checks if the process name belongs to one of the pre-defined Linux shells (bash, zsh, ksh, sh, or csh). -
Output:
The output message incorporates dynamic filters to include the username (user=%user.name) and container ID (container=%container.id) in the alert. -
Priority:
The severity level for this alert is set to WARNING. Falco supports multiple priority levels ranging from debug (lowest) to emergency (highest). -
Lists and Macros:
- The “linux_shells” list consolidates common shell names to simplify the condition.
- The “container” macro verifies that the event originates from a container (i.e.,
container.id != host), improving the readability and maintainability of the rule.
Always ensure that your security rules are tested in a non-production environment before applying them to production systems.