Commit Graph

1098 Commits

Author SHA1 Message Date
Mark Stemm
21ba0eeb11
Set dropping mode after open so it is effective (#635)
For a while, falco has set the inspector drop mode to 1, which should
discard several classes of events that weren't necessary to use most
falco rules.

However, it was mistakenly being called before the inspector was opened,
which meant it wasn't actually doing anything.

Fix this by setting the dropping mode after the inspector open.

On some spot testing on a moderately loaded environment, this results in
a 30-40% drop in the number of system calls processed per second, and
should result in a nice boost in performance.
2019-05-30 18:31:31 -07:00
Kaizhe Huang
7a25405ed5 rules update: add create symlinks over sensitive file and directories 2019-05-29 15:43:45 -07:00
Kaizhe Huang
ddd7e5b93f rule update: add exception for write below etc (etcd-manager updating dns) 2019-05-29 15:43:45 -07:00
Nataly
45241e74c8 falco-CLA-1.0-signed-off-by: Nataly Sheinin <sheininn@gmail.com> (#593)
correcting typo and including google accounts daemons in Read sensitive file untrusted
2019-05-29 15:17:14 -07:00
Carlos Panato
12d0f4589e fix travis ci badges
falco-CLA-1.0-signed-off-by: Carlos Panato <ctadeu@gmail.com>
2019-05-25 17:21:55 +02:00
Leonardo Di Donato
8bd98c16e9 chore(examples/k8s_audit_config): shebang + prevent globbing and word splitting 2019-05-24 18:42:26 +02:00
toc-me[bot]
93d5164efe Update ToC for examples/k8s_audit_config/README.md 2019-05-24 18:42:26 +02:00
Leonardo Di Donato
c844b5632f docs(examples/k8s_audit_config): toc 2019-05-24 18:42:26 +02:00
Leonardo Di Donato
537e4b7e8d chore(examples/k8s_audit_config): shebang + prevent globbing and word splitting 2019-05-24 18:42:26 +02:00
Leo Di Donato
f3e4d7cce0 docs(examples): k8s audit config 2019-05-24 18:42:26 +02:00
Mark Stemm
f2adedec2f Also include ResponseStarted
Required to grab pod exec actions.
2019-05-24 18:42:26 +02:00
Mark Stemm
35a8392e6f Fix typo. 2019-05-24 18:42:26 +02:00
Mark Stemm
78b9bd6e98 Also support a mix of dynamic + static log
Useful when you want to show both dynamic audit sinks as well as logging
to a file.
2019-05-24 18:42:26 +02:00
Mark Stemm
6a6342adc6 Add instructions for k8s audit support in >= 1.13
In K8s 1.13, there's a new mechanism for k8s audit logs using Audit
Sinks, which can be created and managed like other k8s objects.

Add instructions for enabling k8s audit logging for 1.13. The patching
script is still required, as dynamic audit is not a GA feature and needs
to be enabled. Also, the audit sink config is a template and needs to be
filled in with the cluster ip address, like the webhook config for 1.11.
2019-05-24 18:42:26 +02:00
Lorenzo Fontana
bd0ca4f5a7 docs: add lorenzo and leonardo as maintainers
Signed-off-by: Lorenzo Fontana <lo@linux.com>

Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
2019-05-24 16:50:25 +02:00
Kaizhe Huang
3306941cce
rule update: add launch remote file copy tool in container (#600) 2019-05-15 16:53:10 -07:00
Leo Di Donato
f561f41065 docs: changelog missing cri-o container metadata caching (#603) 2019-05-13 18:17:21 -07:00
Mark Stemm
50a19207ab
Prepare CHANGELOG/README for 0.15.0 (#602)
* Prepare CHANGELOG/README for 0.15.0

* Fix typo.
2019-05-13 13:44:06 -07:00
Leo Di Donato
ff5d000736 CRI flag (#599)
* update(integrations): CRI flag

Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>

* fix(integrations): set the containerd socket

Co-Authored-By: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-05-13 12:45:49 -07:00
Néstor Salceda
52329f83b2 Fix security issues reported by GitHub on Anchore integration (#592) 2019-05-13 10:59:26 -07:00
Lorenzo Fontana
5736ed6ba6
Add ash to the list of shell binaries (#597)
Add `ash` to the list of shell binaries
2019-05-12 23:45:38 +02:00
Mehran Kholdi
f365056b89 Add ash to the list of shell binaries
It is specifically used a lot in alpine-based images.

falco-CLA-1.0-signed-off-by: Mehran Kholdi <semekh@hamravesh.com>
2019-05-12 20:13:23 +04:30
Michael Ducy
9a5efd6073
add cri to long_options, fix typo (#591) 2019-05-01 16:59:34 -07:00
Mark Stemm
010083538f
Rule updates 2019 05.v1 (#590)
* Fix parentheses for rpm_procs macro

Ensures a preceding not will apply to the whole macro

* Let anything write to /etc/fluent/configs.d

It looks like a lot of scripted programs (shell scripts running cp, sed,
arbitrary ruby programs) are run by fluentd to set up config. They're
too generic to identify, so jut add /etc/fluent/configs.d to
safe_etc_dirs, sadly.

* Let java setup write to /etc/passwd in containers

/opt/jboss/container/java/run/run-java.sh and /opt/run-java/run-java.sh
write to /etc/passwd in a contaner, probably to add a user. Add an
exception for them.
2019-05-01 10:40:12 -07:00
Mark Stemm
772d4f9515
Update engine fields checksum for fd.dev.* (#589)
* Update engine fields checksum for fd.dev.*

New fields fd.dev.*, so updating the fields checksum.

* Print a message why the trace file can't be read.

At debug level only, but better than nothing.

* Adjust tests to match new container_started macro

Now that the container_started macro works either on the container event
or the first process being spawned in a container, we need to adjust the
counts for some rules to handle both cases.
2019-04-30 12:46:25 -07:00
Mark Stemm
0e1c436d14
Add jenkins checks (#584)
* Supporting files to build/test via jenkins

Changes to build/test via jenkins, which also means running all tests in
a container instead of directly on the host:

- Jenkinsfile controls the stages, build.sh does the build and
  run-tests.sh does the regression tests.

- Create a new container falcosecurity/falco-tester that includes the
  dependencies required to run the regression tests. This is a different
  image than falco-builder because it doesn't need to be centos 6 based,
  doesn't install any compiler/etc, and installs the test running
  framework we use (avocado). We now use a newer version of avocado,
  which resulted in some small changes to how it is run and how yaml
  options are parsed.

- Modify run_regression_tests.sh to download trace files to the build
  directory and only if not present. Also honor BUILD_TYPE/BUILD_DIR,
  which is provided via the docker run cmd.

- The package tests are now moved to a separate falco_tests_package.yaml
  file. They will use rpm installs by default instead of debian
  packages. Also add the ability to install rpms in addition to debian
  packages.

- Automate the process of creating the docker local package by: 1)
  Adding CMake rules to copy the Dockerfile, entrypoint to the build
  directory and 2) Copy test trace files and rules into the build
  directory. This allows running the docker build command from
  build/docker/local instead of the source directory.

- Modify the way the container test is run a bit to use the trace
  files/rules copied into the container directly instead of host-mounted
  trace files.

* Use container builder + tester for travis

We'll probably be using jenkins soon, but this will allow switching back
to travis later if we want.

* Use download.draios.com for binutils packages

That way we won't be dependent on snapshot.debian.org.
2019-04-26 12:24:15 -07:00
Spencer Krum
6572423544 Add containerd related flags (#585)
Signed-off-by: Spencer Krum <nibz@spencerkrum.com>

sysdig-CLA-1.0-contributing-entity: International Business Machines
sysdig-CLA-1.0-signed-off-by: Spencer Krum <skrum@us.ibm.com>
2019-04-26 08:31:28 -07:00
Michael Ducy
05bb4a84ca
Fix errors when building via docker from MacOS (#582)
* fix docker builder on macos

* remove extra comments
2019-04-17 04:14:16 -07:00
Michael Ducy
acb582af15
fix regression that broke json output (#581) 2019-04-16 13:26:21 -07:00
Mark Stemm
0e31ae5bad
Rules changes 2019 04.v6 (#580)
* Remove netstat as a generic network program

We'll try to limit the list to programs that can broadly see activity or
actually create traffic.

* Rules for inbound conn sources, not outbound

Replace "Unexpected outbound connection source" with "Unexpected inbound
connection source" to watch inbound connections by source instead of
outbound connections by source. The rule itself is pretty much unchanged
other than switching to using cip/cnet instead of sip/snet.

Expand the supporting macros so they include outbound/inbound in the
name, to make it clearer.
2019-04-12 11:40:52 -07:00
Kaizhe Huang
23d5e5a968 Rule updates 2019 04.v4 mitre persistence (#578)
* rules update: add rules for mitre framework

* rules update: add mitre persistence rules

* minor changes

* add exclude hidden directories list

* limit hidden files creation in container

* minor fix

* minor fix

* tune rules to have only_check_container macro

* rules update: add rules for remove data from disk and clear log

* minor changes

* minor fix rule name

* add check_container_only macro

* addresses comments

* add rule for updating package repos

* Don't consider dd a bulk writer

Threre are enough legitimate cases to exclude it.

* Make cron/chmod policies opt-in

They have enough legitimate uses that we shouldn't run by default.

* minor fix
2019-04-11 22:22:34 -07:00
Mark Stemm
afa1e02c57
Rule updates 2019 04.v5 (#579)
* Fix mistake in always_true macro

comparison operator was wrong.

* Whitespace diffs

* Add opt-in rules for interp procs + networking

New rules "Interpreted procs inbound network activity" and "Interpreted
procs outbound network activity" check for any network activity being
done by interpreted programs like ruby, python, etc. They aren't enabled
by default, as there are many legitimate cases where these programs
might perform inbound or outbound networking. Macros
"consider_interpreted_inbound" and "consider_interpreted_outbound" can
be used to enable them.

* Opt-in rule for running network tools on host

New rule Lauch Suspicious Network Tool on Host is similar to "Lauch
Suspicious Network Tool in Container" [sic] but works on the host. It's
not enabled by default, but can be enabled using the macro
consider_network_tools_on_host.

* Add parens around container macro

* Make Modify User Context generic to shell configs

Rename Modify User Context to Modify Shell Configuration File to note
that it's limited to shell configuration files, and expand the set of
files to cover a collection of file names and files for zsh, csh, and
bash.

* Also prevent shells from directly opening conns

Bash can directly open network connections by writing to
/dev/{tcp,udp}/<addr>/<port>. These aren't actual files, but are
interpreted by bash as instructions to open network connections.

* Add rule to detect shell config reads

New rule Read Shell Configuration File is analogous to Write Shell
Configuration File, but handles reads by programs other than shell
programs. It's also disabled by default using consider_shell_config_reads.

* Add rule to check ssh directory/file reads

New rule Read ssh information looks for any open of a file or directory
below /root/.ssh or a user ssh directory. ssh binaries (new list
ssh_binaries) are excluded.

The rule is also opt-in via the macro consider_ssh_reads.

* Rule to check for disallowed ssh proxies

New rule "Program run with disallowed http proxy env" looks for spawned
programs that have a HTTP_PROXY environment variable, but the value of
the HTTP_PROXY is not an expected value.

This handles attempts to redirect traffic to unexpected locations.

* Add rules showing how to categorize outbound conns

New rules Unexpected outbound connection destination and Unexpected
outbound connection source show how to categorize network connections by
either destination or source ip address, netmask, or domain name.

In order to be effective, they require a comprehensive set of allowed
sources and/or destinations, so they both require customization and are
gated by the macro consider_all_outbound_conns.

* Add .bash_history to bash config files

* Restrict http proxy rule to specific procs

Only considering wget, curl for now.

* Shell programs can directly modify config

Most notably .bash_history.

* Use right system_procs/binaries

system_binaries doesn't exist, so use system_procs + an additional test
for shell_binaries.
2019-04-11 21:00:55 -07:00
Kaizhe Huang
d83342aa2f
rule update: add MITRE tags for rules (#575)
* rule update: add MITRE tags for rules

* update mitre tags with all lower case and add two more rules

* add two more mitre_persistence rules plus minor changes

* replace contains with icontains

* limit search passwd in container
2019-04-10 22:48:51 -07:00
Mark Stemm
e26a9505d6
Change log timestamp to ISO8601 w/ timezone (#518)
* Add option to display times in ISO 8601 UTC

ISO 8601 time is useful when, say, running falco in a container, which
may have a different /etc/localtime than the host system.

A new config option time_format_iso_8601 controls whether log message
and event times are displayed in ISO 8601 in UTC or in local time. The
default is false (display times in local time).

This option is passed to logger init as well as outputs. For outputs it
eventually changes the time format field from %evt.time/%jevt.time to
%evt.time.iso8601/%jevt.time.iso8601.

Adding this field changes the falco engine version so increment it.

This depends on https://github.com/draios/sysdig/pull/1317.

* Unit test for ISO 8601 output

A unit test for ISO 8601 output ensures that both the log and event time
is in ISO 8601 format.

* Use ISO 8601 output by default in containers

Now that we have an option that controls iso 8601 output, use it by
default in containers. We do this by changing the value of
time_format_iso_8601 in falco.yaml in the container.

* Handle errors in strftime/asctime/gmtime

A placeholder "N/A" is used in log messages instead.
2019-04-09 09:41:00 -07:00
Mark Stemm
da6b0f16f1
Rule updates 2019 04.v2 (#573)
* Also let dockerd-current setns()

* Add additional setns programs

Let oci-umount (https://github.com/containers/oci-umount) setns().

* Let Openscap RPM probes touch rpm db

Define a list openscap_rpm_binaries containing openscap probes related
to rpm and let those binaries touch the rpm database.

* Let oc write to more directories below /etc

Make the prefix more general, allowing any path below /etc/origin/node.
2019-04-05 11:27:37 -07:00
Kaizhe Huang
b81ded44f3
rule update: exclude openshift-sdn from thread namespace change rule (#572) 2019-04-02 22:34:42 -07:00
Mark Stemm
e5a1ddb918
Include addl info to syscall event drop alerts (#571)
When creating syscall event drop alerts, instead of including just the
total and dropped event count, include all possible causes of drops as
well as whether bpf is enabled.
2019-04-02 16:43:18 -07:00
Mark Stemm
19327e0e85
Skip incomplete container info for container start (#570)
* Skip incomplete container info for container start

In the container_started macro, ensure that the container metadata is
complete after either the container event (very unlikely) or after the
exec of the first process into the container (very likely now that
container metadata fetches are async).

When using these rules with older falco versions, this macro will still
work as the synchronous container metadata fetch will result in a
repository that isn't "incomplete".

* Update test traces to have full container info

Some test trace files used for regression tests didn't have full
container info, and once we started looking for those fields, the tests
stopped working.

So update the traces, and event counts to match.
2019-04-02 15:12:31 -07:00
Mark Stemm
91954d61ce
Define GRPC_CPP_PLUGIN (#569)
Bringing over the top CMakeLists.txt change in
https://github.com/draios/sysdig/pull/1349 to define GRPC_CPP_PLUGIN so
it can be referred to when autogenerating grpc code.
2019-04-02 10:34:54 -07:00
Kaizhe Huang
9e26117e93
exclude oc on writing below root (#567)
* exclude oc on writing below root

* minor changes
2019-03-29 10:07:05 -07:00
Jean-Philippe Lachance
2fd90bf6a7 + Add a user_known_write_monitored_dir_conditions macro to allow custom conditions in the "Write below monitored dir" rule (#566)
falco-CLA-1.0-contributing-entity: Coveo Solutions Inc.
falco-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-03-28 14:17:01 -07:00
Mark Stemm
bdda640da1
Flag excess drops (#561)
* Make stats file interval configurable

New argument --stats_interval=<msec> controls the interval at which
statistics are written to the stats file. The default is 5000 ms (5 sec)
which matches the prior hardcoded interval.

The stats interval is triggered via signals, so an interval below ~250ms
will probably interfere with falco's behavior.

* Add ability to emit general purpose messages

A new method falco_outputs::handle_msg allows emitting generic messages
that have a "rule", message, and output fields, but aren't exactly tied
to any event and aren't passed through an event formatter.

This allows falco to emit "events" based on internal checks like kernel
buffer overflow detection.

* Clean up newline handling for logging

Log messages from falco_logger::log may or may not have trailing
newlines. Handle both by always adding a newline to stderr logs and
always removing any newline from syslog logs.

* Add method to get sequence from subkey

New variant of get_sequence that allows fetching a list of items from a
key + subkey, for example:

key:
  subkey:
    - list
    - items
    - here

Both use a shared method get_sequence_from_node().

* Monitor syscall event drops + optional actions

Start actively monitoring the kernel buffer for syscall event drops,
which are visible in scap_stats.n_drops, and add the ability
to take actions when events are dropped. The -v (verbose) and
-s (stats filename) arguments also print out information on dropped
events, but they were only printed/logged without any actions.

In falco config you can specify one or more of the following actions to
take when falco notes system call drops:

 - ignore (do nothing)
 - log a critical message
 - emit an "internal" falco alert. It looks like any other alert with a
   time, "rule", message, and output fields but is not related to any
   rule in falco_rules.yaml/other rules files.
 - exit falco (the idea being that the restart would be monitored
   elsewhere).

A new module syscall_event_drop_mgr is called for every event and
collects scap stats every second. If in the prior second there were
drops, perform_actions() handles the actions.

To prevent potential flooding in high drop rate environments, actions
are goverened by a token bucket with a rate of 1 actions per 30 seconds,
with a max burst of 10 seconds. We might tune this later based on
experience in busy environments.

This might be considered a fix for
https://github.com/falcosecurity/falco/issues/545. It doesn't
specifically flag falco rules alerts when there are drops, but does
make it easier to notice when there are drops.

* Add unit test for syscall event drop detection

Add unit tests for syscall event drop detection. First, add an optional
config option that artifically increments the drop count every
second. (This is only used for testing).

Then add test cases for each of the following:
 - No dropped events: should not see any log messages or alerts.
 - ignore action: should note the drops but not log messages or alert.
 - log action: should only see log messages for the dropped events.
 - alert action: should only see alerts for the dropped events.
 - exit action: should see log message noting the dropped event and exit
   with rc=1

A new trace file ping_sendto.scap has 10 seconds worth of events to
allow the periodic tracking of drops to kick in.
2019-03-27 15:50:39 -07:00
Jean-Philippe Lachance
7b0b4984eb ! Fix the prometheus_conf_writing_conf macro (#564)
* ! Fix the prometheus_conf_writing_conf macro

falco-CLA-1.0-contributing-entity: Coveo Solutions Inc.
falco-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>

* * Apply Mark Stemm's code review

falco-CLA-1.0-contributing-entity: Coveo Solutions Inc.
falco-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-03-25 16:37:50 -07:00
Kaizhe Huang
cc7fecedf7
kh: exclude rancher events (#559)
* kh: exclude rancher events
2019-03-15 12:57:15 -07:00
Jean-Philippe Lachance
d366092214 + Add "puppet" in the list of known proc.name writing below etc because Puppet often manages configurations (#563)
+ Add the user_known_write_root_conditions macro to allow custom conditions in the "Write below root" rule
+ Add the user_known_non_sudo_setuid_conditions to allow custom conditions in the "Non sudo setuid" rule

falco-CLA-1.0-contributing-entity: Coveo Solutions Inc.
falco-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-03-15 09:09:46 -07:00
Jean-Philippe Lachance
7689282621 Allow exe running Docker save to write below rpm database (#552)
falco-CLA-1.0-contributing-entity: Coveo Solutions Inc.
falco-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-03-14 09:40:29 -07:00
prsimoes
3d96ca5157 Add KUBERNETES_SERVICE_HOST (#562)
When using host network, the containers can't resolve kubernetes.default, thus not getting the metadata like pod name, namespace, etc. Using the environment variable KUBERNETES_SERVICE_HOST, which points to the current cluster API server, will allow that.
2019-03-13 17:40:41 -07:00
Mark Stemm
28622e6fdc
Rule updates 2019.02.v1 (#551)
* Let cassandra write to /root/.cassandra

* Add kubelet/kops to allowed_k8s_users
2019-03-08 19:23:18 -08:00
Mark Stemm
5740186280
Support container event to denote container starts (#550)
* Add support for container metaevent to detect container spawning

Create a new macro "container_started" to check both the old and
the new check.
Also, only look for execve exit events with vpid=1.

* Use TBB_INCLUDE_DIR for consistency w sysdig,agent

Previously it was a mix of TBB_INCLUDE and TBB_INCLUDE_DIR.

* Build using matching sysdig branch, if exists
2019-03-08 13:23:10 -08:00
Michael Ducy
3edd39e625
fix stale.yml file extension (#548)
* fix stale.yml file extension

* add help wanted label to exempt
2019-03-05 10:03:07 -05:00