Skip to content

Falco with plugin k8saudit-eks #2461

Description

@pealtrufo

I am a little bit confused when following documentation to deploy Falco on an EKS cluster with the kernel module and also the k8saudit-eks plugin.

I am deploying it using helm, and using the yaml file in chart repo below as a basis, where I make the changes required to use the k8saudit-eks plugin instead
https://github.com/falcosecurity/charts/blob/master/falco/values-syscall-k8saudit.yaml
https://github.com/falcosecurity/plugins/tree/master/plugins/k8saudit-eks

The resulting yaml I am using is this:

# Enable the driver, and choose between the kernel module or the ebpf probe.
# Default value: kernel module.
driver:
  enabled: true
  kind: module

# Enable the collectors used to enrich the events with metadata.
# Check the values.yaml file for fine-grained options.
collectors:
  enabled: true

# We set the controller to daemonset since we have the syscalls source enabled.
# It will ensure that every node on our cluster will be monitored by Falco.
# Please note that the api-server will use the "k8saudit-webhook" service to send
# audit logs to the falco instances. That means that when we have multiple instances of Falco
# we can not predict to which instance the audit logs will be sent. When testing please check all
# the Falco instance to make sure that at least one of them have received the audit logs.
controller:
  kind: daemonset

tty: true

falcoctl:
  artifact:
    install:
      # -- Enable the init container. We do not recommend installing plugins for security reasons since they are executable objects.
      # We install only "rulesfiles".
      enabled: true
    follow:
      # -- Enable the sidecar container. We do not support it yet for plugins. It is used only for rules feed such as k8saudit-rules rules.
      enabled: true
  config:
    artifact:
      install:
        # -- Do not resolve the depenencies for artifacts. By default is true, but for our use case we disable it.
        resolveDeps: false
        # -- List of artifacts to be installed by the falcoctl init container.
        # We do not recommend installing (or following) plugins for security reasons since they are executable objects.
        refs: [falco-rules:0, k8saudit-rules:0.5]
      follow:
        # -- List of artifacts to be followed by the falcoctl sidecar container.
        # We do not recommend installing (or following) plugins for security reasons since they are executable objects.
        refs: [falco-rules:0, k8saudit-rules:0.5]

services:
  - name: k8saudit-webhook
    type: NodePort
    ports:
      - port: 9765 # See plugin open_params
        nodePort: 30007
        protocol: TCP

falco:
  rules_file:
    - /etc/falco/falco_rules.yaml
    - /etc/falco/k8s_audit_rules.yaml
    - /etc/falco/rules.d
  jsonOutput: true
  plugins:
    - name: k8saudit-eks
      library_path: libk8saudit-eks.so
      init_config:
        region: "eu-west-2"
        profile: "default"
        shift: 10
        polling_interval: 10
        use_async: false
        buffer_size: 500
      open_params: "cluster-name"
    - name: json
      library_path: libjson.so
      init_config: ""

  load_plugins: [k8saudit-eks, json]

Now when deploying this config, Falco pods can't start and these are the logs I can see:

kubectl logs -n falco falco-2m445
Defaulted container "falco" out of: falco, falcoctl-artifact-follow, falco-driver-loader (init), falcoctl-artifact-install (init)
Thu Mar 30 15:06:26 2023: Falco version: 0.34.1 (x86_64)
Thu Mar 30 15:06:26 2023: Falco initialized with configuration file: /etc/falco/falco.yaml
Thu Mar 30 15:06:26 2023: Loading plugin 'k8saudit-eks' from file /usr/share/falco/plugins/libk8saudit-eks.so
Thu Mar 30 15:06:26 2023: Runtime error: cannot load plugin /usr/share/falco/plugins/libk8saudit-eks.so: can't load plugin dynamic library: /usr/share/falco/plugins/libk8saudit-eks.so: cannot open shared object file: No such file or directory. Exiting.

I can see this warning in the output of the helm install command:

WARNING:
It seems you are loading the following plugins [k8saudit-eks json], please make sure to install them by adding the correct reference to falcoctl.config.artifact.install.refs: [falco-rules:0 k8saudit-rules:0.5]

But when looking to the sample yaml, there's this comment: We do not recommend installing (or following) plugins for security reasons since they are executable objects

  config:
    artifact:
      install:
        # -- Do not resolve the depenencies for artifacts. By default is true, but for our use case we disable it.
        resolveDeps: false
        # -- List of artifacts to be installed by the falcoctl init container.
        # We do not recommend installing (or following) plugins for security reasons since they are executable objects.
        refs: [falco-rules:0, k8saudit-rules:0.5]

Which seems to imply that you don't recommend installing plugins this way.

If I amend the yaml file and configure the falcoctl section this way, pods are started ok:

falcoctl:
  artifact:
    install:
      # -- Enable the init container. We do not recommend installing plugins for security reasons since they are executable objects.
      # We install only "rulesfiles".
      enabled: true
    follow:
      # -- Enable the sidecar container. We do not support it yet for plugins. It is used only for rules feed such as k8saudit-rules rules.
      enabled: true
  config:
    artifact:
      allowedTypes:
        - rulesfile
        - plugin
      install:
        # -- Do not resolve the depenencies for artifacts. By default is true, but for our use case we disable it.
        resolveDeps: false
        # -- List of artifacts to be installed by the falcoctl init container.
        # We do not recommend installing (or following) plugins for security reasons since they are executable objects.
        refs: [falco-rules:0, k8saudit-rules:0.5, k8saudit-eks:0.1, json:0.6]
        # refs: [falco-rules:0, k8saudit-rules:0.5]
      follow:
        # -- List of artifacts to be followed by the falcoctl sidecar container.
        # We do not recommend installing (or following) plugins for security reasons since they are executable objects.
        refs: [falco-rules:0, k8saudit-rules:0.5]

Note I added plugins to be installed in refs also had to add value plugin as allowedType in config for it to work. Otherwise, pods wouldn't start.

Is this ok? I ended up with this config based on googling and testing different configs I found. I don't think it is clear in the docs so I suppose I am looking for validation :)
I am happy to contribute with any required changes to the docs if you think that's required.

This is what I can see in the logs just after deploy. So everything seems to be ok. I can trigger rules too and can see the warnings in pods output:

kubectl logs -n falco falco-k4vfp
Defaulted container "falco" out of: falco, falcoctl-artifact-follow, falco-driver-loader (init), falcoctl-artifact-install (init)
Thu Mar 30 15:21:44 2023: Falco version: 0.34.1 (x86_64)
Thu Mar 30 15:21:44 2023: Falco initialized with configuration file: /etc/falco/falco.yaml
Thu Mar 30 15:21:44 2023: Loading plugin 'k8saudit-eks' from file /usr/share/falco/plugins/libk8saudit-eks.so
Thu Mar 30 15:21:44 2023: Loading plugin 'json' from file /usr/share/falco/plugins/libjson.so
Thu Mar 30 15:21:44 2023: Loading rules from file /etc/falco/falco_rules.yaml
Thu Mar 30 15:21:44 2023: Loading rules from file /etc/falco/k8s_audit_rules.yaml
Thu Mar 30 15:21:44 2023: The chosen syscall buffer dimension is: 8388608 bytes (8 MBs)
Thu Mar 30 15:21:44 2023: Starting health webserver with threadiness 2, listening on port 8765
Thu Mar 30 15:21:44 2023: Enabled event sources: k8s_audit, syscall
Thu Mar 30 15:21:44 2023: Opening capture with plugin 'k8saudit-eks'
Thu Mar 30 15:21:44 2023: Opening capture with Kernel module

Note: I understand the k8s service is not required when using k8saudit-eks plugin, right?

Environment

  • Falco version: 0.34.1 (x86_64)
  • Cloud provider or hardware configuration: AWS EKS
  • Installation method: Helm

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions