Reputation: 13
I would like to know if someone has an idea about how to identify commands ran by Ansible within a remote host.
To give you more context I'm gonna describe my workflow in-depth:
I have a scheduled job between 1 am to 6 am which runs a compliance Ansible playbook to ensure the production servers configuration are up to date and well configured, however, this playbook change some files inside the /etc
folder.
Besides this, I have a Falco stack which keeps an eye on what is going on the production servers and raises alerts when an event that I describe as suspicious is found (It can be a syscall/ network connection/ sensitive file editing "/etc/passwd, pam.conf, ..." etc...
So the problem I'm running through is, my playbook triggers some alerts for example:
Warning Sensitive file opened for reading by non-trusted program (user=XXXX user_loginuid=XXX program=python3 command=python3 file=/etc/shadow parent=sh gparent=sudo ggparent=sh gggparent=sshd container_id=host image=<NA>)
My question is, can we set a "flag or prefix" to all Ansible commands, which will allow me to whitelist this flag of prefix and avoid triggering my alerts for nothing.
PS: whitelisting python3
for the user root
is not a solution in my opinion.
Upvotes: 1
Views: 274
Reputation: 5557
Ansible is python tool, so the process accessing the file will be python3
. The commands that Ansible executes are based on the steps that are in the playbook.
You can solve your problem by modifying the falco
rules. You can evaluating the proc.pcmdline
in falcon rule and the chain of the proc.aname
to identify that the command was executed by the ansible process (ex. process is python3
, parent is sh
grandparent is sudo
, etc.)
Upvotes: 0