Commit Graph

2616 Commits

Author SHA1 Message Date
Henri DF
fe741c928d Merge pull request #70 from draios/build-release-by-default
Make default release type "build"
2016-05-15 10:48:08 -07:00
Henri DF
acfa8e7686 Make default release type "build" 2016-05-15 17:43:10 +00:00
Loris Degioanni
21eb418878 merge add-names-descriptions 2016-05-15 10:07:43 -07:00
Loris Degioanni
4bd11ddcfc a couple of fixes in the rules file 2016-05-15 10:00:13 -07:00
Mark Stemm
7436bc0952 Allow package mgmt binaries to work in bin dirs.
A new macro package_mgmt_binaries includes dpkg and rpm. Those programs
are allowed to create directories and modify files below binary
directories. I'm not adding them to other trusted sets for now, though.
2016-05-14 21:57:57 -07:00
Mark Stemm
0a9a85d1da Also update README example to reflect new format.
Include full macros and rule for write_binary_dir.
2016-05-14 21:51:55 -07:00
Loris Degioanni
5eb368035a rule file improvement pass 2016-05-14 13:00:58 -07:00
Mark Stemm
4313c9f7a3 Tidy up output of existing rules.
Try to clean up the language of the existing rule set, expanding the
output when possible, removing %evt.dir in most cases.

There is one substantive change: the mkdir half of modify_binary_dirs
was split out into its own rule mkdir_binary_dirs.
2016-05-13 17:25:45 -07:00
Mark Stemm
7be0454f6f Add ability to print name/description of rules.
When run with -l <rule>, falco will print the name/description of the
single rule <rule> and exit. With -L, falco will print the
name/description of all rules.

All the work is done in lua in the rule loader. A new lua function
describe_rule calls the local function describe_single_rule once or
multiple times depending on -l/-L. describe_single_rule prints the rule
name and a wrapped version of the rule description.
2016-05-13 16:30:15 -07:00
Mark Stemm
e662d1eeeb Add name/description to rules.
Add name and description fields to all rules. The name field is actually
a field called 'rule', which corresponds to the 'macro' field for
macros.

Within the rule loader, the state changes slightly. There are two
indices into the set of rules 'rules_by_name' and
'rules_by_idx' (formerly 'outputs'). They both now contain the original
table from the yaml parse. One field 'level' is added which is the
priority mapped to a number.

Get rid of the notion of default priority or output. Every rule must now
provide both.

Go through all current rules and add names and descriptions.
2016-05-13 16:30:09 -07:00
Mark Stemm
d16cc67e98 Merge pull request #63 from draios/reduce-rules-fps
Reduce rule FPs based on more complex environments
2016-05-13 09:39:00 -07:00
Mark Stemm
070667cad0 Reduce rule FPs based on more complex environments
Update rules to reduce FPs after running against some real-world
environments with and without containers. Summary of changes:

 - Too many processes read /etc/passwd--it's world-readable and a
   side-effect of getpwent. Switch to /etc/shadow instead.

 - Add a mail_binaries group. This wasn't directly used, but it may be
   handy for other rules and goes along with the changes in #54.

 - not_cron was the only macro expressing a negative, so switch it to be
   a positive 'cron'. Also add crond as a cron process.

 - add dragent to the set of programs that can call setns.

 - For the shell detection rules, change them to only look for the
   specific exec/clone event rather than all follow-on activity. Also
   allow docker to spawn shell scripts--this is required for entrypoints
   that use the shell instead of a direct exec. Also add a few
   additional programs that can spawn shells.

 - In containers, shells are allowed as long as the parent process is
   docker or bash. Like the outside of container case, only the initial
   clone/exec is detected.

 - Fix a typo Sytem -> System.

 - Change the chmod rule to only protect imporant/sensitive files. I saw
   lots of "regular" files being chmod()ed.

 - Change the setuid test to allow root to setuid to anything, rather
   than listing a bunch of programs run as root that drop privileges.

 - Allow running su/sudo in containers. Some containers add users from a
   base linux distribution before running.
2016-05-12 18:01:23 -07:00
Mark Stemm
6e2c115e37 Merge pull request #54 from draios/rule-service-spawns-process
Don't let databases spawn processes after startup.
2016-05-12 17:55:20 -07:00
Henri DF
81df435471 Merge pull request #56 from draios/remove-install-falco
Remove `install-falco` script.
2016-05-12 11:32:00 -07:00
Henri DF
fbdab4362c Remove install-falco script.
It isn't being used yet, for now we're using the corresponding script
from the sysdig repo. Removing it to avoid confusion, we can later
re-add as necessary.
2016-05-12 17:31:34 +00:00
Mark Stemm
d1fb172bff Merge pull request #55 from draios/run-falco-in-docker
Run falco by default in containers.
2016-05-12 09:24:38 -07:00
Mark Stemm
0e40ad26c4 Run falco by default in containers.
Instead of running bash as the sysdig container does, run falco. This
makes sense as falco doesn't have a general purpose use like sysdig
does.

To make it easier to run both in docker and as a daemon using the
default command line, enable both syslog and stdout/stderr output by
default. Now that falco dups stdout/stderr to /dev/null when
daemonizing, the stdout/stderr is just thrown away. And when running in
docker, the syslog output will just be discarded unless someone plumbs
the container's syslog output.

Update README.md to reflect that specifying the falco command is not
necessary.
2016-05-11 17:35:02 -07:00
Mark Stemm
c761218bfe Don't let databases spawn processes after startup.
This will detect the result of some sql injection attacks where the
injected query tries to spawn a process.

We don't include web servers in this list for now due to things like
mod_perl, mod_php, etc. Maybe we can add it once we make exceptions for
those modules.
2016-05-11 15:36:48 -07:00
Mark Stemm
343e694ca4 Add back detection for mysql and sensitive files.
Add back detection for mysql and sensitive files that was removed in the
previous commit. A new macro proc_is_new adds a condition on how long a
process has been running.

A new rule triggers if the process is not new and tries to open a
sensitive file. This handles cases like mysql, where it *does* read
/etc/passwd on startup but shouldn't really open it afterward.
2016-05-11 15:36:48 -07:00
Mark Stemm
f64ea7def5 Add addl groups of binary programs.
Add some new groups of binary programs as macros and start using them in
the set of rules:

 - docker_binaries: docker and exe (which is a temporary process name
   for processes like docker-proxy)
 - http_server_binaries: httpd, nginx, and similar
 - db_server_binaries: mysql for now, we'll add more later
 - server_binaries: all of the above
 - userexec_binaries: sudo and su.

Start using these groups in the rules. Most of the time, changing from
the inline lists of processes to macros was a no-op. There are some
actual changes, though:

 - docker and exe are now allowed to read 'sensitive' files. They may
   not actually do so, but it's not really harmful.
 - lighttpd is now allowed to read 'sensitive' files, via inclusion in
   http_server_binaries.
 - su, lighttpd, and docker can now setuid.
 - http-foreground is included as a http server wrt non-port 80/443 ports.

I'm going to use these macros in some of the following rules.

This actually prevents detection of mysql reading sensitive files, which
is one of the demo scenarios (sql injection). I plan on adding this
detection back in the next commit.
2016-05-11 15:36:48 -07:00
Mark Stemm
f43e5e6c3d Merge pull request #52 from draios/add-license
Add license
2016-05-11 08:54:59 -07:00
Mark Stemm
6476a55ecc Add CLA section.
Add CLA section, using the sysdig CLA section and licenses as a
reference. The entity remains sysdig, but falco is used in the
signature.
2016-05-11 08:50:22 -07:00
Mark Stemm
8902257e81 Add license.
Licensed as GPLv2 like sysdig.
2016-05-11 08:50:22 -07:00
Mark Stemm
92c4c8f622 Merge pull request #50 from draios/cmdline-opts-daemonize
Clean up handling cmdline options wrt config file.
2016-05-11 08:46:59 -07:00
Henri DF
f0263285c3 Merge pull request #53 from draios/fix-lua-install-path
Fix install path for Lua files
2016-05-10 22:12:24 -07:00
Mark Stemm
4949da5835 Merge pull request #51 from draios/fix-remaining-falco-rules-conf
Fix remaining falco_rules.conf references.
2016-05-10 21:08:25 -07:00
Henri DF
451b450869 Fix install path for Lua files 2016-05-10 20:54:20 -07:00
Henri DF
56f806b7ea Update README.md
Add instructions for uninstallation
2016-05-10 20:27:26 -07:00
Mark Stemm
13fc4ca77a Fix remaining falco_rules.conf references.
Did a find looking for references to falco_rules.conf. Renamed to falco_rules.yaml.
2016-05-10 16:12:32 -07:00
Mark Stemm
79f9843256 Clean up handling cmdline options wrt config file.
Remove the old use of the '-o' command line option, it wasn't being
used.

Allow any config file option to be overridden on the command line, via
--option/-o. These options are applied to the configuration object after
reading the file, ensuring the command line options override anything in
the config file.

To support this, add some methods to yaml_configuration that allows you
to set the value for a top level key or key + subkey, and methods to
falco_configuration that allow providing a set of command line arguments
alongside the config file.

Ensure that any fatal error is always printed to stderr even if stderr
logging is not enabled. This makes sure that falco won't silently exit
on an error. This is especially important when daemonizing and when an
initial fatal error occurs first.

As a part of this, change all fatal errors to throw exceptions instead,
so all fatal errors get routed through the exception handler.

Improve daemonization by reopening stdin/stdout/stderr to /dev/null so
you don't have to worry about writing to a closed stderr on exit.
2016-05-10 15:52:59 -07:00
Henri DF
5263181b15 Merge pull request #49 from draios/rules-conf-to-yaml
Config file: falco_rules.{yaml,conf}
2016-05-10 13:53:06 -07:00
Henri DF
dbd50b8c26 Config file: falco_rules.{yaml,conf} 2016-05-10 20:52:02 +00:00
Henri DF
fae2c330dd Merge pull request #47 from draios/pre-release-documentation
Fill out README.md
2016-05-10 13:47:59 -07:00
Henri DF
492148d880 Running instructions 2016-05-10 13:47:30 -07:00
Henri DF
4e525e3114 Document general configuration 2016-05-10 20:42:25 +00:00
Henri DF
1c3ae275d7 Rewrite "rules" section 2016-05-10 20:41:49 +00:00
Henri DF
cd82f6935d Adjust heading levels 2016-05-10 20:41:49 +00:00
Henri DF
bcc7521e4e Add "how you use it" section
Quick & simple outline to make things concrete upfront.
2016-05-10 20:41:49 +00:00
Henri DF
9d306e5a1c Add ToC and move things around 2016-05-10 20:41:49 +00:00
Henri DF
ab80b4ce13 Move installation instructions down 2016-05-10 20:41:49 +00:00
Henri DF
ca182a2dc8 Add installation instructions 2016-05-10 20:41:49 +00:00
Mark Stemm
d5726aea04 Merge pull request #44 from draios/demo-rule-changes
Update rules to work on demo scenarios.
2016-05-10 11:43:06 -07:00
Mark Stemm
c23229263c Update rules to work on demo scenarios.
Make changes to falco_rules.yaml to make sure they work on the demo
scenarios without too many false positives. The specific changes are:

- Add /etc/ld.so.cache as an allowed shared library to open.
- Comment out the shared library check for now--there are lots of
  locations below /usr/lib for things like python, perl, etc and I want
  to get a fuller categorization first.
- Add a few additional parent processes that can spawn shells, write
  sensitive files, and call setuid. Also allow bash shells with no
  parent to spawn shells. We may want to disallow this but I suspect a
  better place to detect is the parent-less bash shell becoming a
  session leader.
- Add rules for fs-bash (falco-safe bash), which is used in the curl
  <url> | bash installer demo. The idea is that fs-bash has restrictions
  on what it and child proceses can do.
- Add trailing '/' characters to path names in bin_dir_* so paths like
  /tmp/binary don't accidentally match '/bin'

Note that as process names are truncated to 15 characters, long process
names like 'httpd-foregroun' are intentionally truncated.
2016-05-10 11:37:25 -07:00
Mark Stemm
1d94d3aaed Merge pull request #43 from draios/package-as-service
Package as service
2016-05-09 17:29:24 -07:00
Mark Stemm
6203c6be74 Change output options in file as well.
Also change output options in falco config to reflect default behavior
of being started via a service.
2016-05-09 17:18:20 -07:00
Mark Stemm
58d730c62a Don't start by default on debian.
This makes the behavior consistent on debian and redhat.
2016-05-09 17:17:39 -07:00
Mark Stemm
3fa12ee794 Merge pull request #45 from draios/allow-missing-output-fields
Allow missing output fields.
2016-05-09 10:30:26 -07:00
Mark Stemm
594d3d66d5 Allow missing output fields.
Add a leading * to the format string so output with missing fields is
just displayed with '<NA>' values instead of being aborted.

This fixes #42.
2016-05-08 14:27:08 -07:00
Mark Stemm
fda5162061 Merge pull request #41 from draios/error-on-filtered-syscall
Error on filtered syscall
2016-05-07 09:18:44 -07:00
Mark Stemm
7389e05852 Handle both ignored events and syscalls.
Henri pointed out that events may also be flagged as ignored. So
populate a second table with the set of ignored events, rename
check_for_ignored_syscalls to check_for_ignored_syscalls_events, and
separately check each table based on whether the LHS of the expression
is evt.type or syscall.type.
2016-05-06 18:12:46 -07:00