You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I create and add a custom syscall rule that often triggers in my deployment, and use a k8smeta-field, k8smeta.pod.name to be precise. I would expect this field to be populated, but it returns N/A. Sorry for this bug report being very long, I just included a lot of context :)
How to reproduce it
Deploy falco with the following command using its Helm-chart: helm upgrade --install falco falcosecurity/falco --namespace falco --create-namespace -f falco-values.yaml
falco-values.yaml has the following contents:
falco:
rules_file:
- /etc/falco/rules.ddriver:
kind: ebpfcollectors:
kubernetes:
enabled: falsefalcosidekick:
enabled: truewebui:
enabled: truecustomRules:
rules-k8smeta.yaml: |- - macro: k8s_containers condition: > (container.image.repository in (gcr.io/google_containers/hyperkube-amd64, gcr.io/google_containers/kube2sky, docker.io/sysdig/sysdig, sysdig/sysdig, fluent/fluentd-kubernetes-daemonset, prom/prometheus, falco_containers, falco_no_driver_containers, ibm_cloud_containers, velero/velero, quay.io/jetstack/cert-manager-cainjector, weaveworks/kured, quay.io/prometheus-operator/prometheus-operator, registry.k8s.io/ingress-nginx/kube-webhook-certgen, quay.io/spotahome/redis-operator, registry.opensource.zalan.do/acid/postgres-operator, registry.opensource.zalan.do/acid/postgres-operator-ui, rabbitmqoperator/cluster-operator, quay.io/kubecost1/kubecost-cost-model, docker.io/bitnami/prometheus, docker.io/bitnami/kube-state-metrics, mcr.microsoft.com/oss/azure/aad-pod-identity/nmi) or (k8s.ns.name = "kube-system")) - macro: never_true condition: (evt.num=0) - macro: container condition: (container.id != host) - macro: k8s_api_server condition: (fd.sip.name="kubernetes.default.svc.cluster.local") - macro: user_known_contact_k8s_api_server_activities condition: (never_true) - rule: Custom Contact K8S API Server From Container desc: > Detect attempts to communicate with the K8S API Server from a container by non-profiled users. Kubernetes APIs play a pivotal role in configuring the cluster management lifecycle. Detecting potential unauthorized access to the API server is of utmost importance. Audit your complete infrastructure and pinpoint any potential machines from which the API server might be accessible based on your network layout. If Falco can't operate on all these machines, consider analyzing the Kubernetes audit logs (typically drained from control nodes, and Falco offers a k8saudit plugin) as an additional data source for detections within the control plane. condition: > evt.type=connect and evt.dir=< and (fd.typechar=4 or fd.typechar=6) and container and k8s_api_server and not k8s_containers and not user_known_contact_k8s_api_server_activities output: Custom Unexpected connection to K8s API Server from container (connection=%fd.name lport=%fd.lport rport=%fd.rport fd_type=%fd.type fd_proto=%fd.l4proto evt_type=%evt.type user=%user.name user_uid=%user.uid user_loginuid=%user.loginuid process=%proc.name proc_exepath=%proc.exepath parent=%proc.pname command=%proc.cmdline k8s_podname=%k8smeta.pod.name orig_podname=%k8s.pod.name terminal=%proc.tty %container.info) priority: NOTICE tags: [maturity_stable, container, network, k8s, mitre_discovery, T1565]
The included custom rule is a copy of the Custom Contact K8S API Server From Container rule with all its dependencies. The only modification is that two new fields k8s_podname=%k8smeta.pod.name and orig_podname=%k8s.pod.name are added to the output. The orig_podname field is populated - it says the same as k8s.pod.name in the output. However, k8s_podname remains N/A, and I would expect this field to be populated if the same value is available in k8s.pod.name, which is said to only be kept alive for backwards compatibility purposes (line 250 in Falco's official Helm chart).
Expected behaviour
I would expect that if k8s.pod.name is populated with a value, k8smeta.pod.name should also be populated.
Screenshots
Checking out the events in the UI, we see that the k8s_podname field remains N/A while orig_podname gets the same value as k8s.pod.name.
falco-k8s-metacollector is running in the same namespace as the falco-pods and the UI.
Logs from the artifact-install-container show that k8smeta is indeed installed correctly.
Environment
Falco version: 0.38.1 (x86_64)
System info: {"machine":"x86_64","nodename":"falco-fq2mk","release":"6.8.0-36-generic","sysname":"Linux","version":"Field properties changes #36-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 10 10:49:14 UTC 2024"},"version":"0.38.1"}
Cloud provider or hardware configuration: microk8s on three VM's which are connected in a cluster, each with 4 vCPU's and 16 GB RAM. microk8s uses its own version of containerd that has its socket in /var/snap/microk8s/common/run/containerd.sock. In that position falco does not find it, so I created an empty file in /run/containerd/containerd.sock, and then used sudo mount --bind /var/snap/microk8s/common/run/containerd.sock /run/containerd/containerd.sock to make it accessible for falco. That seems to work, as before this change the pod- and containername were N/A in the UI as well, and now they are populated, so falco seems to have access to the containerd socket at least. Changing the deployment volume containerd-socket to mount the /var/snap/microk8s/common/run to falco instead of /run/containerd also works.
As far as I can see, k8smeta and k8smeta collector are configured correctly here in the config as well. I experimented with changing the port or hostname of the metacollector, and then I got errors, same when I turned on SSL without fixing the certificates. This screenshot from the falco-container log also confirms that k8smeta is running - it says that it received at least one event from k8s-metacollector, indicating that their connection should be OK.
Also here it looks as if the k8smeta plugin is healthy. When I removed collectors.kubernetes.enabled=true, falco would not start any longer claiming that I used an invalid value in my rule in rules-k8smeta.yaml, the invalid value being k8smeta.pod.name, which is another indication of k8smeta likely being set up correctly.
Describe the bug
I set up k8smeta and k8smetacollector according to this command (line 273 in Falco's official Helm chart):
helm install falco falcosecurity/falco \ --namespace falco \ --create-namespace \ --set collectors.kubernetes.enabled=trueI create and add a custom syscall rule that often triggers in my deployment, and use a k8smeta-field,
k8smeta.pod.nameto be precise. I would expect this field to be populated, but it returnsN/A. Sorry for this bug report being very long, I just included a lot of context :)How to reproduce it
Deploy falco with the following command using its Helm-chart:
helm upgrade --install falco falcosecurity/falco --namespace falco --create-namespace -f falco-values.yamlfalco-values.yaml has the following contents:
The included custom rule is a copy of the
Custom Contact K8S API Server From Containerrule with all its dependencies. The only modification is that two new fieldsk8s_podname=%k8smeta.pod.nameandorig_podname=%k8s.pod.nameare added to the output. Theorig_podnamefield is populated - it says the same ask8s.pod.namein the output. However,k8s_podnameremainsN/A, and I would expect this field to be populated if the same value is available ink8s.pod.name, which is said to only be kept alive for backwards compatibility purposes (line 250 in Falco's official Helm chart).Expected behaviour
I would expect that if
k8s.pod.nameis populated with a value,k8smeta.pod.nameshould also be populated.Screenshots

Checking out the events in the UI, we see that the k8s_podname field remains
N/Awhile orig_podname gets the same value as k8s.pod.name.falco-k8s-metacollector is running in the same namespace as the falco-pods and the UI.
Logs from the artifact-install-container show that k8smeta is indeed installed correctly.
Environment
/var/snap/microk8s/common/run/containerd.sock. In that position falco does not find it, so I created an empty file in/run/containerd/containerd.sock, and then usedsudo mount --bind /var/snap/microk8s/common/run/containerd.sock /run/containerd/containerd.sockto make it accessible for falco. That seems to work, as before this change the pod- and containername wereN/Ain the UI as well, and now they are populated, so falco seems to have access to the containerd socket at least. Changing the deployment volumecontainerd-socketto mount the/var/snap/microk8s/common/runto falco instead of/run/containerdalso works.Linux microk8s-1 6.8.0-36-generic #36-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 10 10:49:14 UTC 2024 x86_64 x86_64 x86_64 GNU/Linuxhelm upgrade --install falco falcosecurity/falco --namespace falco --create-namespace -f falco-values.yaml, see above.Additional context
/etc/falco/falco.yamlpulled from one of the falco-pods:As far as I can see, k8smeta and k8smeta collector are configured correctly here in the config as well. I experimented with changing the port or hostname of the metacollector, and then I got errors, same when I turned on SSL without fixing the certificates. This screenshot from the falco-container log also confirms that k8smeta is running - it says that it received at least one event from k8s-metacollector, indicating that their connection should be OK.
Also here it looks as if the k8smeta plugin is healthy. When I removed
collectors.kubernetes.enabled=true, falco would not start any longer claiming that I used an invalid value in my rule inrules-k8smeta.yaml, the invalid value beingk8smeta.pod.name, which is another indication ofk8smetalikely being set up correctly.