falcosecurity / falco

Cloud Native Runtime Security
https://falco.org
Apache License 2.0
7.38k stars 902 forks source link

"Write below rpm database" rule failing in Amazon Linux 2 #745

Closed fcoelho closed 5 years ago

fcoelho commented 5 years ago

What happened:

The "Write below rpm database" rule fails under Amazon Linux 2 when installing something, like running yum install -y vim. The generated event looks like this:

{
  "output": "2019-07-30T19:35:28.038655549+0000: Error Rpm database opened for writing by a non-rpm program (command=python -c import yum; y=yum.YumBase(); y.doConfigSetup(init_plugins=False); print(y.conf.yumvar) file=/var/lib/rpm/__db.003 parent=python pcmdline=python -m amazon_linux_extras system_motd container_id=host image=<NA>)",
  "priority": "Error",
  "rule": "Write below rpm database",
  "time": "2019-07-30T19:35:28.038655549Z",
  "output_fields": {
    "container.id": "host",
    "container.image.repository": null,
    "evt.time.iso8601": 1564515328038655500,
    "fd.name": "/var/lib/rpm/__db.003",
    "proc.cmdline": "python -c import yum; y=yum.YumBase(); y.doConfigSetup(init_plugins=False); print(y.conf.yumvar)",
    "proc.pcmdline": "python -m amazon_linux_extras system_motd",
    "proc.pname": "python"
  }
}

What you expected to happen:

It shouldn't fail for regular yum install commands

How to reproduce it (as minimally and precisely as possible):

Running yum install vim is enough to trigger the issue.

Anything else we need to know?:

I'm using the following blocks to silence the alerts:

- macro: amazon_linux_running_python_yum
  condition: >
    proc.name = python
    and proc.pcmdline = "python -m amazon_linux_extras system_motd"
    and proc.cmdline = "python -c import yum; y=yum.YumBase(); y.doConfigSetup(init_plugins=False); print(y.conf.yumvar)"

- rule: Write below rpm database
  append: true
  condition: and not amazon_linux_running_python_yum

Environment:

leodido commented 5 years ago

/assign @Kaizhe

Kaizhe commented 5 years ago

Thanks I will take a look!

poiana commented 5 years ago

@fcoelho: There is not a label identifying the kind of this issue. Please specify it either using /kind <group> or manually from the side menu. In case you do not know which kind this proposal is please mention the maintainers using @team/maintainers.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.