Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to match null fields in condition? #3438

Open
raphael-ru opened this issue Dec 20, 2024 · 0 comments
Open

How to match null fields in condition? #3438

raphael-ru opened this issue Dec 20, 2024 · 0 comments

Comments

@raphael-ru
Copy link

I am trying to create an exception for the following rule trigger where some of the fields are null. I want to disregard the alert if k8s.pod.name = null and some other conditions are true. I have tried several different conditions without success (not exists and != '""').

Given other issues here regarding the null value, I have thought about whether k8s.pod.name shouldn't be null in the first place. But I only see the fields as null with this specific proc.cmdline, so I'm assuming this is expected.

Here is the stdout from Falco.

{
  "hostname": "[...]",
  "output_fields": {
    "container.id": "[...]",
    "container.image.repository": null,
    "container.image.tag": null,
    "container.name": null,
    "evt.time.iso8601": 1734653069292140901,
    "evt.type": "connect",
    "fd.l4proto": "udp",
    "fd.lport": 443,
    "fd.name": "[...]",
    "fd.rport": 54126,
    "fd.type": "ipv4",
    "k8s.ns.name": null,
    "k8s.pod.name": null,
    "proc.cmdline": "python3 /image/hello/../world.py --some-args [...]",
    "proc.exepath": "",
    "proc.name": "python3",
    "proc.pname": null,
    "proc.tty": 0,
    "user.loginuid": -1,
    "user.name": "foo",
    "user.uid": 1000
  },
  "priority": "Notice",
  "rule": "Unexpected UDP Traffic",
  "source": "syscall",
  "tags": ["..."],
  "time": "2024-12-20T00:04:29.292140901Z"
}

I tried both not exists and != '""'. I used both the condition syntax and the exception syntax. Example:

    - rule: Unexpected UDP Traffic
      desc: > 
        Detecting UDP traffic ...
      condition: > 
        inbound_outbound 
        and fd.l4proto=udp 
        and not expected_udp_traffic
        and not container.id = host 
        and not (proc.args startswith /image/hello/../world.py and proc.name = python3 and user.uid = 1000 and fd.lport = 433 and not k8s.pod.name exists)

and

exceptions:
     - name: startup_exception
        fields: [k8s.pod.name, proc.args, proc.name, user.uid, fd.lport]
        comps: [=, startswith, =, =, =]
        values:
        - ['""', /image/hello/../world.py, python3, 1000, 443]

I would really appreciate some guidance on how to write the filter correctly.

Thank you for all your hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant