Commit Graph

864 Commits

Author SHA1 Message Date
Mark Stemm
ccea09b089 Rule updates next (#293)
* Let luajit spawn shells.

* Start support for db mgmt programs

Add support for db management programs that tend to spawn
shells. Starting with two lists
mysql_mgmt_binaries/postgres_mgmt_binaries which are combined into
db_mgmt_binaries. db_mgmt_binaries is added to both shell spawning rules
and the individual programs are removed.

* Let apache beam spawn shells

The program is "python pipeline.py" but it appears to be related to
https://github.com/apache/beam/blob/master/sdks/python/apache_beam/pipeline.py.

* Better support for dovecot

Allow dovecot to setuid by adding to mail_binaries.

Allow the program auth, when run by dovecot, to spawn shells.

* Better support for plesk

Create a list plesk_binaries and allow them to run shells.

Also let them write to files below /etc/sw/keys.

* Let strongswan spawn shells.

Specifically the program starter. Using the full command line to be more
specific.

* Let proftpd modify files below /etc.

* Let chef binaries write below /etc

* Let mandb read sensitive files

* Let specific phusion passenger binaries run shells

The program is "my_init", which is fairly generic, so capture it by the
full command line.

* Make git-remote-http more permissive.

* Let networkmanager modify /etc/resolv.conf

specifically nm-dispatcher

* Let hostid open network connections

It might perform dns lookups as a part of resolving ip addresses.

* Let uwsgi spawn shells

* Add docker-runc-cur as a docker binary.

truncated version of docker-runc-current.

* Add rule for allowed containers

New rule Launch Disallowed Container triggers when a container is
started that does not match the macro allowed_containers. In the main
falco rules file, this macro never matches, so it never
triggers. However, in a second rules file the macro allowed_containers
could be filled in with the specific images that match.

* Also let foreman spawn shells

Used by Red Hat Sattelite.

* Let confluence run shells.

Appears as java program, so look for the classpath.

* Make allowed_containers macro more foolproof.

In some cases, the container image might not be known/is NULL, so the
comparison aganst "dummy-not-allowed-container-image" doesn't work.

Replace this with proc.vpid=1, which is in the main rule Launch
Disallowed Continer. Ensures it will only trigger when the
allowed_containers macro is overridden.

* Let tomcat spawn shells.

It's java so you need to look at the classpath.

* Let pip install software.

* Add another yarn command line.

* Let add-shell write to /etc/shells.tmp

* Let more plesk binaries setuid.

* Add imap-login as a mail binary.

* Fix plesk writing keys macro

Should be testing proc.name, not proc.cmdline.

* Let screen read sensitive files.

* Add more shell spawners.

S99qualys-cloud is the init script, cfn-signal is cloudformation.

* Exclude nologin from user mgmt programs.

* Let programs run by locales.postins write to /etc

It can run scripts like sed to modify files before writing the final
file.

* Let install4j java progs spawn shells.

Again, searching by classpath.

* Let some shell cmds be spawned outside containers

We had a list known_container_shell_spawn_cmdlines that contained
innocuous commandlines, but it only worked for containers.

Split this list into container-specific and general commandlines, and
add an exception for the general commandlines for the Run Shell
Untrusted rule.

* Add addl ruby-based passenger spawners

Add a different way to identify ruby run by phusion passenger.

* Allow bundle ruby cmds to be identififed by name

In some cases, bundle runs ruby scripts by direct script
name (foo.rb). Also allow that to spawn shells.

* Let nginx spawn shells.

* Skip setuid rules for containers.

For now, entirely skip the setuid rule for containers. Will add back
once I can find a way to check for unknown users.

* Let PassengerWatchd run shells

* Add additional foreman shells

Let the direct parent also be scl when the ancestor is tfm-rake,tfm-ruby.

* Add additional innocuous command lines.

* Also let cron spawn shells in containers

Seen when using things like phusion passenger.

* Also let run-parts run cmp/cp for sensitive files

Might be a case of a missing process but might also be legitimate.

* Let erlexec spawn shells.

* Add additional innocuous shell cmdlines.

* Add suexec as a userexec binary.

* Add imap/mailmng-core as mail binaries.

Also split list across multiple lines.

* Let perl spawn shells when run by cpanm

* Let apache_control_ spawn shells

* Let ics_start/stop running java spawn shells

java is the direct parent, ics_start/stop are ancestors.

* Let PassengerAgent setuid.

It setuids to nobody.

* Let multilog write below /etc if run by supervise

* Let bwrap setuid

A container setup utility.

* Detect writes below /, /root

New rule Write below root detects writes either directly below / or
anywhere below /root.

* Don't let shells directly open network connections

In addition to system binaries, don't let shells directly open network
connections. Bash has /dev/{tcp,udp} which allows direct connections.

* Add additional sensitive mounts.

Add additional sensitive mounts, including the docker socket, /,
anywhere below /root, or anywhere below /etc.

* Let pki-realm write below /etc/pki/realms

Appears to be an ansible script.

* Let sgdisk write below dev

* Let debconf-show read sensitive files.

* Additional case for build-related scripts.

* Add additional mail binaries.

* Let ruby running discourse spawn shells.

* Let beam.smp and paster run shells

* Temporarily undo shells opening net conns update

At some customers, at container create time events are being lost, and
for that reason programs spawned by the shell that perform network
connections are being misattributed to the shell.

* Make the actual sensitive files a list.

Make the actual sensitive files used by the sensitive files macro a list
so it can be easily extended.

* Print mounts in Launch Sensitive Mount Container

Add the full list of mounts to the output of Launch Sensitive Mount
Container, so it's easy to see which sensitive mount was used.

* Add container.image to container-related rules.

Helps in diagnosis.

* Add sw-engine-kv as a plesk binary.

* Allow sa-update to read sensitive files

SpamAssassin updater.

* Add additional shell spawners.

* Allow sumologic secureFiles to run user mgmt progs

See https://help.sumologic.com/Send-Data/Installed-Collectors/05Reference-Information-for-Collector-Installation/08Enhanced-File-System-Security-for-Installed-Collectors.

* Only consider full mounts of /etc as sensitive

A legitimate case is k8s mounting /etc/kubernetes/ssl, which was
matching /etc*. The glob matcher we have isn't a full regex so you can't
exclude strings, only characters.

* Let htpasswd write below /etc

Part of nginx

* Let pam-auth-update read sensitive files

* Let hawkular-metric spawn shells.

* Generalize jenkins scripts spawning shells

Generalize jenkins_script_sh to jenkins_scripts and add additional
cases.

* Let php run by assemble spawn shells

Better than globally letting php spawn shells.

* Add additional setuid binaries.

* Add additional package mgmt prog

rhsmcertd-worke(r), red hat subscription manager

* Add additional yarn cmdlines.

* Let dmeventd write below etc.

device mapper event daemon.

* Let rhsmcertd-worke(r) spawn shells.

* Let node spawn bitnami-related shells.

* Add user allowed sensitive mounts

New macro user_sensitive_mount_containers allows a second rules file to
specify containers/images that can perform sensitive mounts.

* Add start-stop-daemon as setuid program

It has -g/-u args to change gid/uid.

Also move some other single setuid programs to the list
known_setuid_binaries.

* Add additional shell spawners/cmdlines.

* Let python running localstack spawn shells.

* Add additional chef binaries.

* Let fluentd spawn shells.

* Don't consider unix_chkpwd to be a user mgmt prog

It only checks passwords.

* Get setuid for NULL user in container working

Reorganize the unknown_user_in_container macro to get it working again
in containers. Previously, it was being skipped entirely due to a
problem with handling of unknown users, which get returned as NULL.

The new macro is known_user_in_container, which tests the user.name
against "N/A". It happens that if user.name is NULL, the comparison
fails, so it has the same effect as if the string "N/A" were being
returned. Any valid user name won't match the string "N/A", so known
users will cause the macro to return true.

The setuid rule needs an additional check for not container, so add that.

* Add exceptions for Write below root

Add lists of files/directories that are acceptable to write.
2017-10-25 14:39:53 -07:00
Mark Stemm
9ec26795c5 Merge pull request #292 from draios/perf-improvements
Expose evttypes for ruleset
2017-10-19 14:38:57 -07:00
Mark Stemm
eeae04ac67 Expose evttypes for ruleset
Add the ability to return the specific event types that are relevant for
a given ruleset. Allows pre-filtering based on ruleset outside the
engine.
2017-10-18 13:34:19 -07:00
Mark Stemm
e5bd58ab91 Merge pull request #291 from draios/update-curl-fix-osx
Update curl version, fixing osx build
2017-10-13 12:45:20 -07:00
Mark Stemm
2fa867e8d0 Try using system cmake
We were installing cmake 3.3.2, while the travis vms have 3.2.2, which
might be new enough.
2017-10-13 12:13:35 -07:00
Mark Stemm
55b9408c7d Update curl version, fixing osx build
@ret2libc reported that osx builds were failing with the current version
of libcurl. Update to the latest version and add the necessary configure
arguments.

Also use https links for all dependencies downloads.
2017-10-13 11:35:48 -07:00
Mark Stemm
5b65fe11f1 Merge pull request #290 from draios/no-rules-files-in-engine
Move rules cmakefiles from engine to falco itself
2017-10-10 15:59:32 -07:00
Mark Stemm
5d21936f60 Move rules cmakefiles from engine to falco itself
The rules CMakeLists.txt, which controls the installation of the falco
rules files, was in the engine CMakeLists.txt, which meant that programs
that included the engine would also include rules files.

This may not always be desired, so move the rules CMakeLists.txt to the
main falco CMakeLists.txt instead.
2017-10-10 14:47:33 -07:00
Mark Stemm
5f688d89e4 Merge pull request #289 from draios/update-readme-no-mailing-list
Update README to drop mailing list
2017-10-10 11:51:23 -07:00
Mark Stemm
2bda0f7ed5 Update README to drop mailing list
Also update the version.
2017-10-10 11:20:36 -07:00
Mark Stemm
9b35e06db8 Merge pull request #288 from draios/fix-rule-loading
Fix built-in falco config location.
2017-10-10 10:48:08 -07:00
Mark Stemm
60d609b8ec Also update changelog. 2017-10-10 09:43:44 -07:00
Mark Stemm
38f1d20ab2 Fix built-in falco config location.
Also needed to be updated from /etc/ to /etc/falco.
2017-10-10 09:42:06 -07:00
Mark Stemm
5230b22876 Merge pull request #287 from draios/prepare-for-0.8.0
Docs changes for 0.8.0
2017-10-09 17:15:38 -07:00
Mark Stemm
1676333d7b Docs changes for 0.8.0
Also fix the incorrect year for several prior releases.
2017-10-09 16:48:59 -07:00
Mark Stemm
4a8ac8d164 Merge pull request #259 from draios/more-beta-updates
More beta updates
2017-10-09 15:09:09 -07:00
Mark Stemm
e1044629cb Work around unknown users in containers wrt setuid
Work around https://github.com/draios/sysdig/issues/954, which relates
to not always knowing the proper user name in containers, by not running
the rule when in a container and the user name is "<NA>". This won't
address cases where the uid from inside the container maps to a user
name outside the container that is different than the user inside the
container, but it will help a bit.
2017-10-09 13:15:39 -07:00
Mark Stemm
080305c7a0 Adjust for new severity
Shell in container is now debug level, so adjust test case to match.
2017-10-09 13:05:12 -07:00
Mark Stemm
26d5ea0123 Merge pull request #286 from draios/no-config-when-validate-rules
Add ability to validate rules file
2017-10-09 12:50:56 -07:00
Mark Stemm
53ca4349f9 Add ability to validate rules file
New argument -V validates a single rules file without any verbose
description of the rules and without reading the main falco config file
at all.
2017-10-09 12:02:23 -07:00
Mark Stemm
0fcd01f98d Let git modify nssdb
Let git-remote-http modify files below the nssdb.
2017-10-09 10:37:33 -07:00
Mark Stemm
1b591dc4f3 Misc build-related fixes
- Let yarn spawn shells
- Add several allowed commandlines
- Let configure spawn shells in containers
2017-10-09 10:36:35 -07:00
Mark Stemm
43b773e9b2 Misc gem/ruby/bundler changes
- Let gem install software.
- Let ruby spawn shells when run by bundle.
2017-10-09 10:34:41 -07:00
Mark Stemm
0d88c3020d Let qualys perform more actions.
It can have more intermediate shells, is allowed to write to its own
conf file, and can run user management binaries.
2017-10-09 09:20:42 -07:00
Mark Stemm
33a28cc173 Let node running yarn spawn shells. 2017-10-09 09:20:41 -07:00
Mark Stemm
a68d2ad769 Let bundle spawn shells. 2017-10-09 09:20:41 -07:00
Mark Stemm
a921012a6c let logdna-agent spawn shells. 2017-10-09 09:20:41 -07:00
Mark Stemm
08afb75009 Add /etc/hrmconfig as a safe directory.
Used by docker swarm http routing mesh.
2017-10-09 09:20:41 -07:00
Mark Stemm
823c105f54 Let systemd-udevd spawn shells 2017-10-09 09:20:41 -07:00
Mark Stemm
bde8d67330 Let psql read sensitive files. 2017-10-09 09:20:41 -07:00
Mark Stemm
9504d420f0 Add more jenkins spawners.
Jenkins spawns shells via script.sh, so allow it.
2017-10-09 09:20:41 -07:00
Mark Stemm
4f5ab79c69 Add xray-rabbitmq shell spawning programs.
They have names {1234}_scheduler and need to be quoted as they start
with digits.
2017-10-09 09:20:41 -07:00
Mark Stemm
6540a856fa Let adclient write below etc. 2017-10-09 09:20:41 -07:00
Mark Stemm
c3c171c7e5 More centrify changes.
Add crlutil as a program that can modify below etc.

Let centrify programs modify below etc.

Add more info for writes below etc to track etc writers through scripts.

Increase the level of debugging for shells.
2017-10-09 09:20:41 -07:00
Mark Stemm
011cb2f030 Also let mailq setuid.
Simialr to showq
2017-10-09 09:20:41 -07:00
Mark Stemm
59ab40d457 Let centrify spawn shells.
This is higher up than other programs.
2017-10-09 09:20:41 -07:00
Mark Stemm
cf5397f701 Change level for sshkit binaries.
It's actually the programs spawned by sshkit scripts that modify files
below /etc.
2017-10-09 09:20:41 -07:00
Mark Stemm
cff8ca428a The right program was mailq
not smmsp, that was the user.
2017-10-09 09:20:41 -07:00
Mark Stemm
d9cb1e2b27 Let adclient/certutil spawn shells/write below etc
Let adclient/certutil spawn shells and write below etc.
2017-10-09 09:20:41 -07:00
Mark Stemm
96992d7ac3 Add scripts possibly run by sshkit
Some general management scripts, possibly run by sshkit (need to check).
2017-10-09 09:20:41 -07:00
Mark Stemm
a22099c8c3 Let adclient spawn shells.
It's not direct, hence the run_by_adclient macro.
2017-10-09 09:20:41 -07:00
Mark Stemm
0e009fc89a Let smmsp setuid.
Another sendmail binary.
2017-10-09 09:20:41 -07:00
Mark Stemm
1a41eeada7 Add ability to augment sensitive file reads
Similar to user_known_write_etc_conditions, add the ability to easily
override sensitve file reads in a second rules file.
2017-10-09 09:20:41 -07:00
Mark Stemm
fefb8ba614 Allow puppet to run shells.
Similar model as chef/qualsys/etc.
2017-10-09 09:20:41 -07:00
Mark Stemm
2bc9d35d37 Let nfsnobody become themself. 2017-10-09 09:20:41 -07:00
Mark Stemm
09748fcbb3 Allow writes to /etc/motd
These files are relatively innocuous.
2017-10-09 09:20:41 -07:00
Mark Stemm
a0e88417fc Add more container innocuous cmdlines
Various uname -x variants and ruby version.
2017-10-09 09:20:41 -07:00
Mark Stemm
e44ce9a8d3 Add calico/node as a trusted container.
It generally needs to run privileged.
2017-10-09 09:20:41 -07:00
Mark Stemm
c4c5d2f585 Let chef read sensitive files
Add the macro run_by_chef to the set of exclusions for reading sensitive
files.
2017-10-09 09:20:41 -07:00
Mark Stemm
340ee2ece7 Add general ability to augment write_etc_common
Add a stub macro user_known_write_etc_conditions that allows easy
additions to write_etc_common in a separate rules file.
2017-10-09 09:20:41 -07:00