Falco: A Security Camera For Kubernetes Applications
Security is always a key concern while running application in any type of system may it be in bare metal or in containerized world. With the increase in number of ephemeral containers, it starts getting harder to keep track of what is running inside each container. Specially in a Kubernetes cluster, containers are spun-up and killed in no time which raises the challenge of threat detection.
A malicious process could run in a container, process or send some private data to third party and the container could get killed. If we don’t have a proper threat & anomaly detection mechanism, we may not be aware of what is running inside.
Falco, a cloud native security project developed initially by Sysdig makes it possible for real time monitoring and alerting based on pre-defined and custom rules. It acts as an intelligent security camera which can monitor files, process, networking events happening inside every single pod inside the cluster and alert if a behaviour steps outside specified policy.
Falco is all based on rules. Example rules could be:
- Installation of packages, libraries inside any container
- Creation, deletion, rename and modification of files and folders inside the container after it starts running
- Execution of binaries like bash, ssh, docker binary, debian binaries, vpn client, mail binaries
- Unusual outbound traffic
- Any ssh connection to/from container
- Change of container files from host machine
- Detect an attempt to start a pod with a container image outside of a list of allowed images.
- Detect an attempt to start a pod with a privileged container
- Attempt to attach/exec to a pod
- Creation of new namespace etc.
We can define our own set of rule which is very specific for our application. Falco alerts with a real time message if any of the rules is violated.
Falcosidekick, a new addon for Falco which runs as daemon helps in extending the outputs of Falco rules execution. It takes a Falco’s events and forward them to different outputs in a fan-out way. There are a number of outputs ranging from Slack, alertmanager, lambda function, datadog, elasticsearch, grafana, pagerduty, opsgenie, google cloud function etc.
Falco can run as a daemon inside docker container or as a daemon inside Kubernetes cluster. If we choose to run as daemonset, a new container runs inside each node and process the data of all the container running inside the node.
Each of the Falco daemon consumes 150–300Mi memory and 100m of CPU in general state. Likewise for FalcoSidekick.
There is helm chart available for both which makes the installation very easy. Here is the official helm chart.
It’s better to segregate the falco daemon and other requirements inside a separate namespace. After cloning the repo, install the chart along with sidekick
helm install falco falco/ -n falco --set falcosidekick.enabled=true
This will install both the charts.
If we want to output the events to slack, the following values need to be passed:
This will send a nice message if any rule is triggered. For example, adding any packages inside pod
Check for the values file inside falco and falcosidekick chart. The pre-defined rules are inside
falco/ . Feel free to add/update the rules as per need.
Priority for Output
In Falco, a minimum priority can be set to send the output to multiple targets. The order of priority is: emergency|alert|critical|error|warning|notice|informational|debug
For example, we might want our pagerduty alert if a new library is installed inside inside a container as ciritical but send a warning if a log file is created which can be recorded to Elasticsearch output. With this, in case of incident, we can always view the threats on multiple outputs without creating too much alarms. Also, the detected threats could be assigned to appropriate team based on priority.
Falcosidekick offers a UI where we can view all the events recorded and filtered based on priority, rule and timerange.
We can see the Rule Timeline as well as the number of events executed along with the priority.
Once the helm chart is installed, above dashboard can be accessed with port-forward:
kubectl port-forward svc/falco-falcosidekick-ui 2802:2802 -n falco
And UI accessible through http://localhost:2802. It doesn’t have inbuilt authentication.