-
Notifications
You must be signed in to change notification settings - Fork 920
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
Condition for "Modify Shell Configuration File" rule does not work #3460
Comments
Could you try using |
I will try to use
What would be the correct way to include this text in the rule? |
Using
returned again the following event: I will try conditioning it out only with contains deserialize then: |
The condition for Meanwhile, if you have any ideas why the following does not work, I will be really glad: This macro is inside the
Yet we still receive the following event in Slack: |
Thanks for the additional details! Looks odd, will try to reproduce and investigate. |
With such a - list: bash_config_filenames
items: [.bashrc, .bash_profile, .bash_history, .bash_login, .bash_logout, .inputrc, .profile]
- list: bash_config_files
items: [/etc/profile, /etc/bashrc]
# Covers both csh and tcsh
- list: csh_config_filenames
items: [.cshrc, .login, .logout, .history, .tcshrc, .cshdirs]
- list: csh_config_files
items: [/etc/csh.cshrc, /etc/csh.login]
- list: zsh_config_filenames
items: [.zshenv, .zprofile, .zshrc, .zlogin, .zlogout]
- list: shell_config_filenames
items: [bash_config_filenames, csh_config_filenames, zsh_config_filenames]
- list: shell_config_files
items: [bash_config_files, csh_config_files]
- list: shell_config_directories
items: [/etc/zsh]
- macro: open_write
condition: (evt.type in (open,openat,openat2) and evt.is_open_write=true and fd.typechar='f' and fd.num>=0)
- macro: open_read
condition: (evt.type in (open,openat,openat2) and evt.is_open_read=true and fd.typechar='f' and fd.num>=0)
- list: shell_binaries
items: [ash, bash, csh, ksh, sh, tcsh, zsh, dash]
- rule: Modify Shell Configuration File
desc: Detect attempt to modify shell configuration files
condition: >
(open_read or open_write) and
(fd.filename in (shell_config_filenames) or
fd.name in (shell_config_files) or
fd.directory in (shell_config_directories))
and not proc.name in (shell_binaries)
and not proc.pcmdline="bash -c echo $$; sleep 1; cat /home/ubuntu/.bashrc > /dev/null"
output: >
a shell configuration file has been opened (user=%user.name user_loginuid=%user.loginuid command=%proc.cmdline pcmdline=%proc.pcmdline ppid=%proc.ppid file=%fd.name container_id=%container.id image=%container.image.repository)
priority:
WARNING
tags: [file, mitre_persistence] I then only loaded this file in Falco by running
And then on another shell:
The event is excluded as it should be. If I change the bash line (e.g. |
Another attempt would be trying, if possible, an older Falco version (0.39.0, 0.38.2) to see if we introduced anything in these versions |
The proposed configuration/rule works as expected. However, if I change anything in this command, an event will be sent. My next config will be as I suggested in my previous comment: |
Definitely odd, as some rule appear to work and some don't in your environment. |
This also looks very similar to #3463 . I'm setting up a cluster to stress test with a large amount of events to see if this is easier to reproduce. |
Update on the situation: I can suppress the event with the following line: One more thing to mention - I've tried to include the %proc.acmdline[1] in the output with an argument, but it does not show at all. It's as if the field itself does not exist.
|
|
Thank you for checking this further!
Does it always happen (i.e.
It shows like an empty string and nothing else (not even |
No, the rule is only one. Verification below:
The output for Also, on the screenshot that you've replied to, there is |
Describe the bug
I have a condition for
not proc.pcmdline="systemd --switched-root --system --deserialize 21"
yet when I redeploy my falco pods, the event will still be in the log output:I even tried to specify the condition to even isolate the container.id like this:
and not (proc.pcmdline contains "systemd --switched-root --system --deserialize 21" and container.id="host")
But it still shows up.
How to reproduce it
Expected behaviour
The event should not be sent to Slack due to the condition of:
and not proc.pcmdline="systemd --switched-root --system --deserialize 21"
Screenshots
Environment
Falco version:
Tue Jan 21 15:11:16 2025: Falco version: 0.39.2 (x86_64)
System info:
Cloud provider or hardware configuration:
Running on AWS EKS 1.29.
OS:
Kubernetes daemonset
The text was updated successfully, but these errors were encountered: