Commit Graph

1008 Commits

Author SHA1 Message Date
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
Jean-Philippe Lachance
e486af6d09 Puppet module fixes (#546)
! Make sure we add the Sysdig repo and call an update before trying to install Falco
! Remove the require in the service class to fix a dependencies loop
* Bump the version to 0.4.0

falco-CLA-1.0-contributing-entity: Coveo Solutions Inc.
falco-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-03-01 10:53:37 -08:00
Xiang Dai
04b1b4da67 delete all duplicate empty blanks (#542)
falco-CLA-1.0-signed-off-by: Xiang Dai <764524258@qq.com>
2019-02-27 11:53:40 -05:00
Jorge Salamero Sanz
a6c5926336 Adds packaging for RHEL (#544) 2019-02-26 10:44:20 -05:00
Mark Stemm
0429883d99
Update version to 0.3.0 (#543)
0.2.0 was released as a part of testing an early version in
https://github.com/falcosecurity/falco/pull/537, and can't be
overwritten, so publish as 0.3.0.
2019-02-21 10:50:15 -08:00
Jean-Philippe Lachance
9c574732f2 Update the Puppet module (#537)
* Update the Puppet module:
* Apply puppet-lint recommendations
* Update the README since the project moved from draios to falcosecurity in GitHub
* Move parameters in their own file
+ Add the DEB repository automatically
+ Add the EPEL repository automatically
+ Add a logrotate configuration
* Update the configuration file with all the latest updates

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

* * Set required modules versions properly
* Set dependencies between classes
* Set the class order
* Apply mstemm's code review

* * Drop the Puppet 3 support
* Use a working version of puppetlabs-apt
* Use dependencies to be compatible with Puppet 4.7 and above
2019-02-21 10:40:11 -08:00
Mark Stemm
0b29b122e1
falco.yaml: change default program_output action (#507) (#541)
falco-CLA-1.0-signed-off-by: Xiang Dai <764524258@qq.com>1
2019-02-20 09:32:14 -08:00
Mark Stemm
135fafb56b
fix k8s install issue (#506) (#540)
falco-CLA-1.0-signed-off-by: Xiang Dai <764524258@qq.com>
2019-02-20 09:23:31 -08:00
Néstor Salceda
a31c3c0eb9 Move kubernetes-response-engine to falcosecurity/kubernetes-response-engine (#539)
* Move kubernetes-response-engine to falcosecurit/kubernetes-response-engine

As long as Falco and Response Engine have different release cycle, they
are separated.

* Add a README explaining that repository has been moved

@mfdii is absolutely right about this on #539
2019-02-20 11:13:59 -05:00
Mark Stemm
d7568ac42f
Add gcc back from manual packages (#536)
Related to https://github.com/falcosecurity/falco/pull/526, it turns out
attempting to build a kernel module on the default debian-based ami used
by kops tries to invoke gcc-6:

-----
* Setting up /usr/src links from host
* Unloading falco-probe, if present
* Running dkms install for falco

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j8 KERNELRELEASE=4.9.0-7-amd64 -C /lib/modules/4.9.0-7-amd64/build
M=/var/lib/dkms/falco/0.14.0/build...(bad exit status: 2)
Error! Bad return status for module build on kernel:
4.9.0-7-amd64 (x86_64)
Consult /var/lib/dkms/falco/0.14.0/build/make.log for more information.
* Running dkms build failed, dumping
  /var/lib/dkms/falco/0.14.0/build/make.log
  DKMS make.log for falco-0.14.0 for kernel 4.9.0-7-amd64 (x86_64)
  Wed Feb 13 01:02:01 UTC 2019
  make: Entering directory '/host/usr/src/linux-headers-4.9.0-7-amd64'
  arch/x86/Makefile:140: CONFIG_X86_X32 enabled but no binutils support
  /host/usr/src/linux-headers-4.9.0-7-common/scripts/gcc-version.sh:
  line 25: gcc-6: command not found
-----

So manually add back gcc-6 and its dependencies.
2019-02-13 08:18:07 -08:00
Mark Stemm
c1b7356ac3
Add k8s audit instructions for kops (#535)
Also reorder the steps so falco is fully deployed before modifying the
apiserver configuration.
2019-02-12 18:53:20 -08:00
Michael Ducy
79d408f472 Add HTTP output handler (#523) 2019-02-11 14:20:19 -08:00
Mark Stemm
7b71eb875f
Docker-based way to build falco (#522)
To allow for a more portable build environment, create a builder image
that is based on centos 6 with devtoolset-2 for a refrence g++.

In that image, install all required packages and run a script that can
either run cmake or make.

The image depends on the following parameters:

FALCO_VERSION: the version to give any built packages
BUILD_TYPE: Debug or Release
BUILD_DRIVER/BPF: whether or not to build the kernel module/bpf program when
   building. This should usually be OFF, as the kernel module would be
   built for the files in the centos image, not the host.
BUILD_WARNINGS_AS_ERRORS: consider all build warnings fatal
MAKE_JOBS: passed to the -j argument of make

A typical way to run this builder is the following. Assumes you have
checked out falco and sysdig to directories below /home/user/src, and
want to use a build directory of /home/user/build/falco:

$ docker run --user $(id -u):$(id -g) -v /etc/passwd:/etc/passwd:ro -e MAKE_JOBS=4 -it -v /home/user/src:/source -v /home/user/build/falco:/build falco-builder cmake
$ docker run --user $(id -u):$(id -g) -v /etc/passwd:/etc/passwd:ro -e MAKE_JOBS=4 -it -v /home/user/src:/source -v /home/user/build/falco:/build falcosecurity/falco-builder package
2019-02-11 13:27:47 -08:00
Xiang Dai
29b8dc8cf0 Update contribute doc (#524)
falco-CLA-1.0-signed-off-by: Xiang Dai <764524258@qq.com>
2019-02-11 13:22:00 -08:00
Mark Stemm
26eba69ec4
Remove gcc 6. (#526)
Debian:unstable recently removed gcc 6, so remove it from our Dockerfiles.
2019-02-10 14:56:09 -08:00
Mark Stemm
ca7106c652
Update for 0.14.0 (#519)
Changelog and README.
2019-02-06 16:37:55 -08:00
Mark Stemm
5e9bbd139c
Add support bundle (#517)
* Expose required_engine_version when loading rules

When loading a rules file, have alternate methods that return the
required_engine_version. The existing methods remain unchanged and just
call the new methods with a dummy placeholder.

* Add --support argument to print support bundle

Add an argument --support that can be used as a single way to collect
necessary support information, including the falco version, config,
commandline, and all rules files.

There might be a big of extra structure to the rules files, as they
actually support an array of "variants", but we're thinking ahead to
cases where there might be a comprehensive library of rules files and
choices, so we're adding the extra structure.
2019-02-06 16:36:33 -08:00
Mark Stemm
bd4c3ffa39
Add additional k8s rbac resources (#514)
Falco also needs to list/watch replicasets, daemonsets, and deployments,
so add them to the resources list.
2019-02-06 15:51:57 -08:00
Mattia Pagnozzi
477fcb56f1 Update rules to use more reliable container image predicates (#513)
Instead of using container.image, that always reports the raw string
used to spawn the container, switch to the more reliable
container.image.{repository,tag}, since they are guaranteed to report
the actual repository/tag of the container image.
This also give a little performance improvement since a single 'in'
predicate can now be used instead of a sequence of startswith.
2019-02-01 10:00:26 -08:00
Marky Jackson
c111f282dd 1) Changing ssh to minikube ssh 2) Noting the step to create /falco-config (#503) 2019-01-31 08:52:16 -08:00
Kaizhe Huang
50c6515da5 kh: improve mount on /var/lib/kubelet rule (#509) 2019-01-30 14:13:19 -08:00
Michael Ducy
9e0e3da617
add config for stale issue tracker (#500) 2019-01-30 10:44:42 -06:00
Mark Stemm
513cf2ed8b
Rules versioning (#492)
* Add ability to print field names only

Add ability to print field names only instead of all information about
fields (description, etc) using -N cmdline option.

This will be used to add some versioning support steps that check for a
changed set of fields.

* Add an engine version that changes w/ filter flds

Add a method falco_engine::engine_version() that returns the current
engine version (e.g. set of supported fields, rules objects, operators,
etc.). It's defined in falco_engine_version.h, starts at 2 and should be
updated whenever a breaking change is made.

The most common reason for an engine change will be an update to the set
of filter fields. To make this easy to diagnose, add a build time check
that compares the sha256 output of "falco --list -N" against a value
that's embedded in falco_engine_version.h. A mismatch fails the build.

* Check engine version when loading rules

A rules file can now have a field "required_engine_version N". If
present, the number is compared to the falco engine version. If the
falco engine version is less, an error is thrown.

* Unit tests for engine versioning

Add a required version: 2 to one trace file to check the positive case
and add a new test that verifies that a too-new rules file won't be loaded.

* Rename falco test docker image

Rename sysdig/falco to falcosecurity/falco in unit tests.

* Don't pin falco_rules.yaml to an engine version

Currently, falco_rules.yaml is compatible with versions <= 0.13.1 other
than the required_engine_version object itself, so keep that line
commented out so users can use this rules file with older falco
versions.

We'll uncomment it with the first incompatible falco engine change.
2019-01-29 12:43:15 -08:00
lorenzo-david
a78212cc62
Merge pull request #480 from lorenzo-david/lorenzod-k8s-audit-dev
Implementing required gen_event virtual methods
2019-01-28 15:59:33 -08:00
Dave Strebel
074a906af3 Fixed Heading Formatting (#502)
Needed a space in the heading to display properly. Smallest commit ever!
2019-01-25 11:46:15 -08:00
Michael Ducy
4fcd44e73a Allow SSL for k8s audit endpoint (#471)
* Allow SSL for k8s audit endpoint

Allow enabling SSL for the Kubernetes audit log web server. This
required adding two new configuration options: webserver.ssl_enabled and
webserver.ssl_certificate. To enable SSL add the below to the webserver
section of the falco.yaml config:

webserver:
  enabled: true
  listen_port: 8765s
  k8s_audit_endpoint: /k8s_audit
  ssl_enabled: true
  ssl_certificate: /etc/falco/falco.pem

Note that the port number has an s appended to indicate SSL
for the port which is how civetweb expects SSL ports be denoted. We
could change this to dynamically add the s if ssl_enabled: true.

The ssl_certificate is a combination SSL Certificate and corresponding
key contained in a single file. You can generate a key/cert as follows:

$ openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
$ cat certificate.pem key.pem > falco.pem
$ sudo cp falco.pem /etc/falco/falco.pem

fix ssl option handling

* Add notes on how to create ssl certificate

Add notes on how to create the ssl certificate to the config comments.
2019-01-23 20:21:37 -08:00
Michael Ducy
ec07f7c240 Add /etc mount for falco container (#475) 2019-01-23 19:13:05 -08:00
Mark Stemm
b8a25c6e71
Add gcc 5 by hand rather than from debian unstable (#501)
gcc 5 is no longer included in debian unstable, but we need it to build
centos kernels, which are 3.x based and explicitly want a gcc version 3,
4, or 5 compiler.

So grab copies we've saved from debian snapshots with the prefix
https://snapshot.debian.org/archive/debian/20190122T000000Z. They're
stored at downloads.draios.com and installed in a dpkg -i step after the
main packages are installed, but before any other by-hand packages are
installed.
2019-01-23 18:02:03 -08:00
Michael Ducy
edc8eb2fd8 add config for stale issue tracker 2019-01-23 15:44:30 -05:00
Michael Ducy
21c7eece25
add cii best practices badge (#499)
* add cii best practices badge

* add cii best practices badge
2019-01-23 14:04:24 -06:00
Mark Stemm
36a1cdd9bc
Add c-ares, protobuf and grpc dependencies (#498)
A recent sysdig change added support for CRI and also added new external
dependencies (cri uses grpc to communicate between the client/server).

Add those dependencies.
2019-01-21 15:51:32 -08:00
Mark Stemm
b76f60d419
Update CHANGELOG/README for 0.13.1 (#497)
Changes since last release.
2019-01-17 07:19:49 -08:00
Mark Stemm
889fcc8b50
Add falco service k8s (#496)
* Add falco service to k8s install/update labels

Update the instructions for K8s RBAC installation to also create a
service that maps to port 8765 of the falco pod. This allows other
services to access the embedded webserver within falco.

Also clean up the set of labels to use a consistent app: falco-example,
role:security for each object.

* Cange K8s Audit Example to use falco daemonset

Change the K8s Audit Example instructions to use minikube in conjunction
with a falco daemonset running inside of minikube. (We're going to start
prebuilding kernel modules for recent minikube variants to make this
possible).

When running inside of minikube in conjunction with a service, you have
to go through some additional steps to find the ClusterIP associated
with the falco service and use that ip when configuring the k8s audit
webhook. Overall it's still a more self-contained set of instructions,
though.
2019-01-16 18:12:02 -08:00
Néstor Salceda
6863675b76 Remove kubernetes-response-engine from system:masters (#488)
As long as we are using rbac for allowing actions on several resources,
we can restrict this a bit more.
2019-01-16 17:43:38 -08:00
ztz
c28892eba3 Fix missing arguments (#485)
* Fix missing arguments.

sysdig-CLA-1.0-signed-off-by: Yue Feng <ztz5651483@gmail.com>
falco-CLA-1.0-signed-off-by: Yue Feng <ztz5651483@gmail.com>

* Re-add base64 encoding feature into formats.cpp

sysdig-CLA-1.0-signed-off-by: Yue Feng <ztz5651483@gmail.com>
falco-CLA-1.0-signed-off-by: Yue Feng <ztz5651483@gmail.com>
2019-01-16 17:42:58 -08:00
Mark Stemm
5e5742f87d
Only have -pc/-pk apply to syscall rules (#495)
Currently, -pc/-pk results in extra fields added to the output field of
all rules. They should only be added for syscall rules.
2019-01-14 10:00:43 -08:00
Mark Stemm
611877e4d3
Unbuffer outputs by default (#494)
In the common case, falco doesn't generate much output, so it's
desirable to not buffer it in case you're tail -fing some logs.

So change the default for buffered outputs to false.
2019-01-14 10:00:23 -08:00
Mark Stemm
29b597dd9c
Improved inbound/outbound macros (#470)
* Improved inbound/outbound macros

Improved versions of inbound/outbound macros that add coverage for
recvfrom/recvmsg, sendto/sendmsg and also ignore non-blocking syscalls
in a different way.

* Let nginx-ingress-c(ontroller) write to /etc/nginx

Process truncated due to comm limit.

Also fix some parentheses for another write_etc_common macro.

* Let calico setns also.

* Let prometheus-conf write its config

Let prometheus-conf write its config below /etc/prometheus.

* Let openshift oc write to /etc/origin/node
2019-01-09 12:27:46 -08:00
Mark Stemm
840fc4bb41
Kh add process rules v2 (#490)
* add new rules for package management process launched and network tool process launched

* fix typo and improve readability

* v3
2018-12-27 21:15:00 -08:00
Loris Degioanni
ea303ba32f noise suppression: calico writing config files into /etc (#481) 2018-12-10 11:54:47 -08:00
Lorenzo David
3bd0081753 Implementing required gen_event virtual methods
As per https://github.com/draios/sysdig/pull/1275, the gen_event class
mandate the implementation of two new methods.

This change aims to simplify the implementation of a generic event
processing infrastructure, that could handle both sinsp and json
events.
2018-12-05 13:05:08 -08:00