Commit Graph

698 Commits

Author SHA1 Message Date
Mark Stemm
33793d233b Rule(Disallowed K8s User): quote colons
It turns out if you read this rules file with falco versions 0.24.0 and
earlier, it can't parse the bare string containing colons:

(Ignore the misleading error context, that's a different problem):

```
Thu Sep 10 10:31:23 2020: Falco initialized with configuration file
/etc/falco/falco.yaml
Thu Sep 10 10:31:23 2020: Loading rules from file
/tmp/k8s_audit_rules.yaml:
Thu Sep 10 10:31:23 2020: Runtime error: found unexpected ':'
---
  source: k8s_audit
    tags: [k8s]
    # In a local/user rules file, you could override this macro to
```

I think the change in 0.25.0 to use a bundled libyaml fixed the problem,
as it also upgraded libyaml to a version that fixed
https://github.com/yaml/libyaml/pull/104.

Work around the problem with earlier falco releases by quoting the colon.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-23 17:48:36 +02:00
Mark Stemm
331b2971be rule(Delete or rename shell history):skip dockerfs
In some cases, when removing a container, dockerd will itself remove the
entire overlay filesystem, including a shell history file:

---
Shell history had been deleted or renamed (user=root type=unlinkat
command=dockerd -H fd://
... name=/var/lib/docker/overlay2/.../root/.bash_history ..
---

To avoid these FPs, skip paths starting with /var/lib/docker.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-23 17:48:36 +02:00
Hiroki Suezawa
5b926386a8 rule(macro consider_packet_socket_communication): change a value to always_true
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2020-09-18 09:47:10 +02:00
Leonardo Grasso
d2dbe64723 update: bump Falco engine version to 7
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-09-13 22:54:00 +02:00
bgeesaman
cb2439d757 Append Slash to Sensitive Mount Path startswith
Make L#1932 equivalent to L#1898

Signed-off-by: Brad Geesaman <bradgeesaman+github@gmail.com>
2020-09-11 14:50:28 +02:00
Leonardo Di Donato
e0f0db96d3 build(rules): fix rules etc dir
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-09-10 15:01:07 +02:00
Mark Stemm
7666bc3f3a rule(System ClusterRole Modified/Deleted): + role
Add system:managed-certificate-controller as a system role that can be
modified. Can be changed as a part of upgrades.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
08d38d8269 Rule(Pod Created in Kube Namespace): add images
Add several images seen in GKE environments that can run in the
kube-system namespace.

Also change the names of the lists to be more specific. The old names
are retained but are kept around for backwards compatibility.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
3fd4464dee rule(Disallowed K8s User): add known users
Seen when using K8s cluster autoscaling or addon manager.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
702d989cd0 rule(Create HostNetwork Pod): add images
Add a set of images known to run in the host network. Mostly related to
GKE, sometimes plus metrics collection.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
de9c8720c0 rule(Launch Privileged Container) add images
Most of these are seen in GKE and are uses for core routing/metrics
collection.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
534cb8e59f rule(Launch Privileged Container): sort/reorg list
Sort the items in the list falco_privileged_images alphabetically
and also separate them into individual lines. Make it easier to note
changes to the entries in the list using git blame.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
9b3adc1373 rule(Read sensitive file untrusted):google_oslogin
Related to https://github.com/GoogleCloudPlatform/guest-oslogin, full
cmdline is google_oslogin_control.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
fb5e13c694 rule(Write below root): add mysqlsh
Let mysqlsh write below /root/.mysqlsh.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
7effc02c60 rule(Write below etc): add calco exceptions
Add several calico images and command line programs that end up writing
below /etc/calico.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
7ae0ce1936 rule(Update Package Repository): restrict files
Previously any write to a file called sources.list would match the
access_repositories condition, even a file /usr/tmp/..../sources.list.

Change the macro so the files in repository_files must be somewhere
below any of repository_directories.

Also allow programs spawned by package management programs to change
these files, using package_mgmt_ancestor_procs.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
891965375d rule(Read sensitive file untrusted): linux-bench
Let programs spawned by linux-bench (CIS Linux Benchmark program) read
/etc/shadow. Tests in the benchmark check for permissions of the file
and accounts in the contents of the file.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Mark Stemm
7a4d790458 rule(Change thread namespace): Require proc name
In some cases, dropped events around the time a new container is started
can result in missing the exec/clone for a process that does a setns to
enter the namespace of a container. Here's an example from an oss
capture:

```

282273 09:01:22.098095673 30 runc:[0:PARENT] (168555) < setns res=0
282283 09:01:22.098138869 30 runc:[0:PARENT] (168555) < setns res=0
282295 09:01:22.098179685 30 runc:[0:PARENT] (168555) < setns res=0
517284 09:01:30.128723777 13 <NA> (168909) < setns res=0
517337 09:01:30.129054963 13 <NA> (168909) < setns res=0
517451 09:01:30.129560037 2 <NA> (168890) < setns res=0
524597 09:01:30.162741004 19 <NA> (168890) < setns res=0
527433 09:01:30.179786170 18 runc:[0:PARENT] (168927) < setns res=0
527448 09:01:30.179852428 18 runc:[0:PARENT] (168927) < setns res=0
535566 09:01:30.232420372 25 nsenter (168938) < setns res=0
537412 09:01:30.246200357 0 nsenter (168941) < setns res=0
554163 09:01:30.347158783 17 nsenter (168950) < setns res=0
659908 09:01:31.064622960 12 runc:[0:PARENT] (169023) < setns res=0
659919 09:01:31.064665759 12 runc:[0:PARENT] (169023) < setns res=0
732062 09:01:31.608297074 4 nsenter (169055) < setns res=0
812985 09:01:32.217527319 6 runc:[0:PARENT] (169077) < setns res=0
812991 09:01:32.217579396 6 runc:[0:PARENT] (169077) < setns res=0
813000 09:01:32.217632211 6 runc:[0:PARENT] (169077) < setns res=0
```

When this happens, it can cause false positives for the "Change thread
namespace" rule as it allows certain process names like "runc",
"containerd", etc to perform setns calls.

Other rules already use the proc_name_exists macro to require that the
process name exists. This change adds proc_name_exists to the Change
Thread Namespace rule as well.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-09-03 18:56:51 +02:00
Loris Degioanni
5d71d70a14 added brakets to three macros to make them less ambiguous
Signed-off-by: Loris Degioanni <loris@sysdig.com>
2020-08-31 18:02:10 +02:00
Chuck Schweizer
d678be5579 Adding user.loginuid to the default falco rules in any place user.name exists
This update will provide information as to which process uid intitiated the event.  This is really important for processes that are started
by a different user name.

Signed-off-by: Chuck Schweizer <chuck.schweizer.lvk2@statefarm.com>
2020-08-28 10:02:19 +02:00
Leonardo Grasso
1f1f7c16b6 chore(rules): add renameat2 to rename macro
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-08-18 11:23:24 +02:00
kaizhe
1bb0a9b44a minor fix
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-08-13 20:34:39 +02:00
kaizhe
ca3c4814fe add sematext images back
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-08-13 20:34:39 +02:00
kaizhe
50832c7990 remove non-oss images in the whitelist
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-08-13 20:34:39 +02:00
kaizhe
4eba59c3f0 keep both w/ docker.io and w/o docker.io for sysdig images
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-08-13 20:34:39 +02:00
kaizhe
3e98c2efc0 macro(user_read_sensitive_file_containers): replace endswiths with exact image repo name
macro(user_trusted_containers): replace endswiths with exact image repo name
macro(user_privileged_containers): replace endswiths with exact image repo name
macro(trusted_images_query_miner_domain_dns): replace endswiths with exact image repo name
macro(falco_privileged_containers): append "/" to quay.io/sysdig
list(falco_privileged_images): add images docker.io/sysdig/agent-slim and docker.io/sysdig/node-image-analyzer
list(falco_sensitive_mount_images): add image docker.io/sysdig/agent-slim
list(k8s_containers): prepend docker.io to images

Signed-off-by: kaizhe <derek0405@gmail.com>
2020-08-13 20:34:39 +02:00
Radu Andries
938ece8f4e macro(exe_running_docker_save): add better support for centos
dockerd and docker have "-current" suffix on centos and rhel. This
macro does not match causing false positives on multiple rules
using it

Signed-off-by: Radu Andries <radu@sysdig.com>
2020-08-13 19:43:48 +02:00
kaizhe
511ef52717 rule (EphemeralContainers Created): add new rule to detect ephemeral container created
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-08-06 22:42:18 +02:00
kaizhe
e2bf87d207 macro(trusted_pod): add new list k8s_image_list
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-07-31 10:40:48 +02:00
kaizhe
571f8a28e7 add macro user_read_sensitive_file_containers
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-07-25 08:53:06 +02:00
kaizhe
6bb0bba68a rules update(Read sensitive file untrusted): add trusted images into whitelist
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-07-25 08:53:06 +02:00
Leonardo Grasso
f1a42cf259 rule(list allowed_k8s_users): add "kubernetes-admin" user
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-07-25 08:51:13 +02:00
Nicolas Vanheuverzwijn
427c15f257 rule(macro falco_privileged_images): add 'docker.io/falcosecurity/falco'
Add 'docker.io/falcosecurity/falco' image to  'falco_privileged_images' macro. This preven messages like this when booting up falco :

```
Warning Pod started with privileged container (user=system:serviceaccount:kube-system:daemon-set-controller pod=falco-42brw ns=monitoring images=docker.io/falcosecurity/falco:0.24.0)
```

Signed-off-by: Nicolas Vanheuverzwijn <nicolas.vanheu@gmail.com>
2020-07-23 20:49:57 +02:00
kaizhe
a9b4e6c73e add sysdig/agent-slim to the user_trusted_images macro
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-07-20 23:41:47 +02:00
kaizhe
b32853798f rule update (macro: user_trusted_containers): add sysdig/node-image-analyzer to macro user_trusted_containers
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-07-20 23:41:47 +02:00
Leonardo Grasso
bca98e0419 update(rules): disable drift detection rules by default
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-07-15 18:01:57 +02:00
Nicolas Marier
32bae35de2 rule(list package_mgmt_binaries): add snapd to list
Snap is a package manager by Canonical which was not in the
`package_mgmt_binaries` list.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-07-10 10:04:26 +02:00
kaizhe
d8d218230d rules update: create placeholder macros for customization
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-07-03 20:54:36 +02:00
Antoine Deschênes
a5cadbf5fa rule(Disallowed K8s User): whitelist kube-apiserver-healthcheck
kops 1.17 adds a kube-apiserver-healthcheck user: https://github.com/kubernetes/kops/tree/master/cmd/kube-apiserver-healthcheck

Logs are currently spammed with:
```
{"output":"18:02:15.466580992: Warning K8s Operation performed by user not in allowed list of users (user=kube-apiserver-healthcheck target=<NA>/<NA> verb=get uri=/healthz resp=200)","priority":"Warning","rule":"Disallowed K8s User","time":"2020-06-29T18:02:15.466580992Z", "output_fields": {"jevt.time":"18:02:15.466580992","ka.response.code":"200","ka.target.name":"<NA>","ka.target.resource":"<NA>","ka.uri":"/healthz","ka.user.name":"kube-apiserver-healthcheck","ka.verb":"get"}}
```

Signed-off-by: Antoine Deschênes <antoine.deschenes@equisoft.com>
2020-06-30 11:44:11 +02:00
kaizhe
e29a4c8560 rule(list network_tool_binaries): add zmap to the list
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-06-29 18:17:28 +02:00
Leonardo Grasso
27037e64cc chore(rules): remove redundant condition from root_dir macro
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-06-26 19:57:18 +02:00
Leonardo Grasso
1859552834 fix(rules): correct root_dir macro to avoid unwanted matching
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-06-26 19:57:18 +02:00
Nicolas Marier
298ba29c88 rule(Change thread namespace): whitelist protokube, dockerd, tini and aws
These application binaries raise events in the `Change thread namespace`
rule as part of their normal operation.

Here are more details regarding each binary :

- `protokube` : See [this](https://github.com/kubernetes/kops/tree/master/protokube)
- `dockerd` : The `dockerd` process name is whitelisted already in this
  rule, but not if it is the parent, which will happen if you are doing
  docker-in-docker.
- `tini` : See [this](https://github.com/krallin/tini)
- `aws` : This one I noticed because Falco itself uses the AWS CLI to
  send events to SNS, which was triggering this rule.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-06-24 11:02:12 +02:00
Nicolas Marier
0272b94bb1 rule(macro exe_running_docker_save): add new cmdline
While using Falco, I noticed we were getting many events that were
virtually identical to those that were previously filtered out by the
`exexe_running_docker_save` macro, but where the `cmdline` was something
like `exe /var/run/docker/netns/cc5c7b9bb110 all false`. I believe this
is caused by the use of docker-in-docker.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-06-24 11:02:12 +02:00
Nicolas Marier
dbd86234ad rule(macro user_expected_terminal_shell_in_container_conditions): create the macro
A macro like this is useful because configuration management software
may need to run containers with an attached terminal to perform some of
its duties, and users may want to ignore this behavior.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-06-23 21:53:41 +02:00
Nicolas Marier
b69bde6bd4 rule(macro user_known_write_below_binary_dir_activities): Create the macro
This macro is useful to allow binaries to be installed under certain
circumstances. For example, it may be fine to install a binary during a
build in a ci/cd pipeline.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-06-22 16:19:07 +02:00
Leonardo Di Donato
d2f0ad7c07 fix(rules): exclude runc writing /var/lib/docker for container drift
detected rules

Co-authored-by: Lorenzo Fontana <lo@linux.com>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-06-22 12:24:59 +02:00
Omer Azaria
70b9bfe1d6 rule(Container Drift Detected): detect new exec created in a container
Signed-off-by: Omer Azaria <omer.azaria@sysdig.com>
2020-06-22 12:24:59 +02:00
kaizhe
dee0cc67f3 rule update (Anonymous Request Allowed): update to checking auth decision equals to allow
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-06-19 15:32:58 +02:00
Leonardo Grasso
578ef7f64d rule(Create files below dev): correct condition to catch openat
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-06-10 12:21:36 +02:00
Leonardo Grasso
a5ce61f03f rule(macro bin_dir_rename): correct condition to catch all variants
Since `evt.arg[1]` does not work for all syscalls, switch to:
 - `evt.arg.path` for `rmdir` and `unlink` (used by `remove` macro)
 - `evt.arg.name` for `unlinkat` (used by `remove` macro)
 - `evt.arg.oldpath/newpath` for `rename` and `renameat` (used by `rename` macro)

That ensures `Modify binary dirs` works properly.

Note that we cannot yet use `renameat2` (not supported by sinsp, see https://github.com/draios/sysdig/issues/1603 )

Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-06-10 12:21:36 +02:00
Leonardo Grasso
74ca02d199 rule(macro bin_dir_mkdir): correct condition to catch mkdirat case
Since the dir's path is found:
-  in `evt.arg[1]` for `mkdir`
-  but in `evt.arg[2]` for `mkdirat`
switch to `evt.arg.path` to catch both.
That ensures `Mkdir binary dirs` works properly.

Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2020-06-10 12:21:36 +02:00
Nicolas Marier
81e29c55ec rule(macro user_known_set_setuid_or_setgid_bit_conditions): create macro
This macro will be useful because it will make it possible to filter out
events with a higher degree of granularity than is currently possible
for the `Set Setuid or Setgid bit` rule.

For example, if some application is expected to set the setuid or the
setgid bit under a specific condition, like if it's started with a
specific command, then the `user_known_chmod_applications` list is not
enough because we don't want to filter out _all_ events by this
application, only specific ones. This macro allows that.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-05-26 10:23:31 +02:00
Mark Stemm
d1c9aae881 rule(list allowed_k8s_users): Add vertical pod autoscaler as known k8s users
https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler

Example alert:
---
K8s Operation performed by user not in allowed list of
users (user=vpa-recommender target=vpa-recommender/endpoints verb=update
uri=core/v1/namespaces/kube-system/endpoints/vpa-recommender resp=200)

K8s Operation performed by user not in allowed list of
users (user=vpa-updater target=vpa-updater/endpoints verb=update
uri=core/v1/namespaces/kube-system/endpoints/vpa-updater resp=200)
---

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-05-21 10:57:42 +02:00
Mark Stemm
986ea28279 rule(macro user_known_k8s_client_container): Allow hcp-tunnelfront torun kubectl in containers
https://stackoverflow.com/questions/50349586/what-is-hcp-tunnelfront

Example alert:

---
Docker or kubernetes client executed in container (user=root
parent=run-tunnel-fron cmdline=kubectl
--kubeconfig=/etc/kubernetes/kubeconfig/kubeconfig get secret
tunnelfront --namespace=kube-system --output json --ignore-not-found
image=mcr.microsoft.com/aks/hcp/hcp-tunnel-front)
---

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-05-21 10:57:42 +02:00
Mark Stemm
5266618689 rule(macro lvprogs_writing_conf): Add lvs as a lvm program
Example event. I'm pretty sure the full file in this case is /etc/lvm/cache:

---
File below /etc opened for writing (user=root command=lvs --noheadings
--readonly --separator=";" -a -o
lv_tags,lv_path,lv_name,vg_name,lv_uuid,lv_size parent=ceph-volume
pcmdline=ceph-volume /usr/sbin/ceph-volume inventory --format json file=/etc/lvm/c...
---

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-05-21 10:57:42 +02:00
Mark Stemm
fa3d2eb473 rule(macro trusted_logging_images): Let azure-npm image write to /var/log
"The Azure's NPM is a a daemonset that supports network policies as
defined by the Kubernetes policy specification."

Example event:

---
Log files were tampered (user=root command=azure-npm
file=/var/log/iptables.conf CID1 image=mcr.microsoft.com/containernetworking/azure-npm)
---

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-05-21 10:57:42 +02:00
Mark Stemm
acb3f94786 rule(macro trusted_logging_images): Add addl fluentd image
Openshift specific variant, example alert:

---
Log files were tampered (user=root command=fluentd /usr/bin/fluentd
--no-supervisor file=/var/log/journal.pos CID1 image=registry.redhat.io/openshift3/ose-logging-fluentd)
---

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-05-21 10:57:42 +02:00
kaizhe
d1af7e139f rule update: fix macro reference
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-05-21 10:55:53 +02:00
kaizhe
f27056c394 fix rule naming following naming convention
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-04-28 18:18:06 +02:00
Mark Stemm
357da40fc4 Only use metadata in k8s audit event for secrets
Instead of using the request object to identify service account tokens,
exclude any secrets activity by system users (e.g. users starting with
"system:"). This allows the rules to work on k8s audit events at
Metadata level instead of RequestResponse level.

Also change the example objects for automated tests to ones collected at
Metadata level.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-04-22 21:00:38 +02:00
Mark Stemm
026965bc6a Add rules to detect creating/deleting secrets
New rules K8s Secret Created/K8s Secret Deleted detect creating/deleting
secrets, following the pattern of the other "K8s XXX Created/Deleted"
rules. One minor difference is that service account token secrets are
excluded, as those are created automatically as namespaces are created.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-04-22 21:00:38 +02:00
kaizhe
f7ac7f34b7 rename rule
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-04-21 19:04:14 +02:00
kaizhe
a1145d9841 rule update: add a rule to detect reverse shell
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-04-21 19:04:14 +02:00
Nicolas Marier
91a0b510fa rule(macro user_expected_system_procs_network_activity_conditions): create the macro
It's useful to ignore some system binaries that use the network under
certain conditions, so this should be overridable by the user.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-04-14 13:22:09 +02:00
Nicolas Marier
76062b93ab rule(list known_system_procs_network_activity_binaries): add a list of known procs for convenience
This makes it more convenient to add more allowed procs and many other
rules have a similar mechanism to whitelist certain processes.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2020-04-14 13:22:09 +02:00
Vicente Herrera
9fd08ce3e4 Introduce missing allowed_full_admin_users macro so its corresponding rule is disabled by default
Signed-off-by: Vicente Herrera <vicenteherrera@vicenteherrera.com>
2020-04-14 13:19:14 +02:00
Vicente Herrera
3ce11f093f Removed default K3s admin user from list, clarified comments
Signed-off-by: Vicente Herrera <vicenteherrera@vicenteherrera.com>
2020-04-14 13:19:14 +02:00
Vicente Herrera
e7b3d7a7e0 Added four new rules, to detect k8s operation by an administrator, nodes successfully joining the cluster, nodes unsuccessfully attempt to join, creation ingress without TLS certificate
Signed-off-by: Vicente Herrera <vicenteherrera@vicenteherrera.com>
2020-04-14 13:19:14 +02:00
Vicente Herrera
2c2d126a54 Added two new rules to detect traffic to image outside local subnet and detect traffic that is not to authorized server process and port
Signed-off-by: Vicente Herrera <vicenteherrera@vicenteherrera.com>
2020-04-14 13:19:14 +02:00
Bob Aman
ffa137fc7c rule(Delete Bash History): Fix typo in tags
Signed-off-by: Bob Aman <bob@sporkmonger.com>
2020-04-14 12:54:02 +02:00
Bob Aman
534a642074 rule(Delete or rename shell history): Fix typo in tags
Signed-off-by: Bob Aman <bob@sporkmonger.com>
2020-04-14 12:54:02 +02:00
kaizhe
1548ccbc4f rule(Write below root): use pmatch to check against known root directories
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-04-09 12:32:30 +02:00
kaizhe
6834649fa5 rule(Service Account Created in Kube Namespace): only detect sa created in kube namespace with success
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-03-27 13:02:57 +01:00
kaizhe
e1cb2e9bb0 rule(Detect outbound connections to common miner pool ports): whitelist sysdig/agent and falcosecurity/falco for query miner domain dns
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-03-27 00:33:24 +01:00
Hiroki Suezawa
3067af566e rule(Change thread namespace): fix regression test
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2020-03-12 16:35:46 +01:00
Hiroki Suezawa
742538ac86 rule(Change thread namespace): change condition to detect suspicious container activity
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2020-03-12 16:35:46 +01:00
Vicente Herrera
085009ad93 Fixed use of "tag" instead of "tags" in default rules
Signed-off-by: Vicente Herrera <vicenteherrera@vicenteherrera.com>
2020-03-10 20:51:45 +01:00
kaizhe
4a8d8a049f add comments
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-03-04 09:28:43 +01:00
kaizhe
b4f2fdc439 disable cryptomining rule by default; add exception of localhost and rfc1918 ip addresses
Signed-off-by: kaizhe <derek0405@gmail.com>
2020-03-04 09:28:43 +01:00
Mark Stemm
3693b16c91 Let puma reactor spawn shells
Sample Falco alert:

```
Shell spawned by untrusted binary (user=git shell=sh parent=puma reactor
cmdline=sh -c pgrep -fl "unicorn.* worker\[.*?\]" pcmdline=puma reactor
gparent=puma ggparent=runsv aname[4]=ru...
```

https://github.com/puma/puma says it is "A Ruby/Rack web server built
for concurrency".

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-02-03 16:13:57 +01:00
Mark Stemm
48a0f512fb Let cilium-cni change namespaces
Sample Falco alert:

```
Namespace change (setns) by unexpected program (user=root
command=cilium-cni parent=cilium-cni host CID2 CID1 image=<NA>)
```

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-02-03 16:13:57 +01:00
Mark Stemm
01c9d8ba31 Let runc write to /exec.fifo
Sample Falco alert:

```
File below / or /root opened for writing (user=<NA>
command=runc:[1:CHILD] init parent=docker-runc-cur file=/exec.fifo
program=runc:[1:CHILD] CID1 image=<NA>)
```

This github issue provides some context:
https://github.com/opencontainers/runc/pull/1698

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-02-03 16:13:57 +01:00
Mark Stemm
7794e468ba Alow writes to /etc/pki from openshift secrets dir
Sample falco alert:

```
File below /etc opened for writing (user=root command=cp
/run/secrets/kubernetes.io/serviceaccount/ca.crt
/etc/pki/ca-trust/source/anchors/openshift-ca.crt parent=bash
pcmdline=bash -c #!/bin/bash\nset -euo pipefail\n\n# set by the node
image\nunset KUB...
```

The exception is conditioned on containers.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-02-03 16:13:57 +01:00
Mark Stemm
0d74f3938d Let avinetworks supervisor write some ssh cfg
Sample Falco alert:

```
File below /etc opened for writing (user=root command=se_supervisor.p
/opt/avi/scripts/se_supervisor.py -d parent=systemd pcmdline=systemd
file=/etc/ssh/ssh_monitor_config_10.24.249.200 program=se_supervisor.p
gparent=docker-containe ggparent=docker-con...
```

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-02-03 16:13:57 +01:00
Mark Stemm
e5f06e399f Let mcafee write to /etc/cma.d
Sample Falco alert:

```
File below /etc opened for writing (user=root command=macompatsvc
self_start parent=macompatsvc pcmdline=macompatsvc self_start
file=/etc/cma.d/lpc.conf program=macompatsvc gparent=macompatsvc
ggparent=systemd gggparent=<NA> CID1 image=<NA>)
```

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-02-03 16:13:57 +01:00
Mark Stemm
fa3e48ca1a Add "dsc_host" as a MS OMS program
Sample Falco alert:

```
File below /etc opened for writing (user=<NA> command=dsc_host
/opt/dsc/output PerformRequiredConfigurationChecks 1 parent=python
pcmdline=python
/opt/microsoft/omsconfig/Scripts/PerformRequiredConfigurationChecks.py
file=/etc/opt/omi/conf/omsconfig/con...
```

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2020-02-03 16:13:57 +01:00
Leonardo Di Donato
572ac46d85 build: include GNUInstallDirs module
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2020-01-17 19:09:31 +01:00
Hiroki Suezawa
cd94d05cd9 rule(list network_tool_binaries): delete ssh from the list
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-16 22:27:12 +01:00
Hiroki Suezawa
23a7203e50 rule(list network_tool_binaries): add network tool names
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-16 22:27:12 +01:00
Hiroki Suezawa
93fdf8ef61 rule(macro user_known_k8s_client_container): Rephrase the comment
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-11 12:53:06 +01:00
Hiroki Suezawa
bcc84c47c6 rule(macro user_known_k8s_client_container): have more strict condition to avoid false positives
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-11 12:53:06 +01:00
Nicolas Marier
13931ab5d7 rule(Write below etc): whitelist automount writing under /etc
This commit allows automount to write under /etc/mtab without flagging
it as an error.

Signed-off-by: Nicolas Marier <nmarier@coveo.com>
2019-12-05 19:27:18 +01:00
Hiroki Suezawa
559b7e1bb1 rule(The docker client is executed in a container): modify condition to reduce false positive
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-05 14:32:22 +01:00
Hiroki Suezawa
fc58ac7356 rule update: modify rule to detect connection to K8S API Server from a container
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-05 10:59:05 +01:00
Jean-Philippe Lachance
418bcf2177 Apply Kaizhe's code review
Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-04 03:36:04 +01:00
Jean-Philippe Lachance
f97a33d40a Exclude exe_running_docker_save in the "Update Package Repository" rule
Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-04 03:36:04 +01:00
Jean-Philippe Lachance
df7a356e1d Apply Kaizhe's code review
Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-04 03:35:11 +01:00
Jean-Philippe Lachance
03e8b7f53d Exclude exe_running_docker_save in the "Modify Shell Configuration File" rule
Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-04 03:35:11 +01:00
Jean-Philippe Lachance
146343e5f0 Update the exe_running_docker_save macro to support docker in docker
Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-04 02:20:21 +01:00
Hiroki Suezawa
7da245e902 rule update: Modify rule to detect raw packets creation
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-04 00:19:26 +00:00
Hiroki Suezawa
d0e6279bb2 rule update: Modify condition for raw packets creation
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-04 00:19:26 +00:00
Hiroki Suezawa
8b2d4e1fe6 rule update: Fix condition for raw packets creation and renamed
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-04 00:19:26 +00:00
Hiroki Suezawa
ebec520ebc rule update: Add rules to detect raw packets creation
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-04 00:19:26 +00:00
kaizhe
2f8caf99cd rule update: align sensitive mount macro between k8s_audit rules and syscall rules
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-12-03 12:58:21 -08:00
Hiroki Suezawa
0b402e2326 rule update: Rename rule for Cloud Metadata access again
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-03 20:15:33 +00:00
Hiroki Suezawa
54329a64cd rule update: Rename rule for Cloud Metadata access
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-03 20:15:33 +00:00
rung
89d8259860 rule update: Add consider_gce_metadata_access macro for rule to detect GCE Metadata access
Signed-off-by: rung <suezawa@gmail.com>
2019-12-03 20:15:33 +00:00
Hiroki Suezawa
e70febc8db rule update: Add rules for GCE Metadata detection
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-03 20:15:33 +00:00
kaizhe
722ab4f2f9 minor changes
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-12-03 19:37:01 +00:00
kaizhe
6c9bce6f73 update k8s audit rule
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-12-03 19:37:01 +00:00
kaizhe
7c33fafe89 minor changes
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-12-03 19:37:01 +00:00
kaizhe
18acea4a73 minor changes
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-12-03 19:37:01 +00:00
kaizhe
8011fe7ce7 rules update: add more sensitive host path to sensitive_host_mount macro
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-12-03 19:37:01 +00:00
Jean-Philippe Lachance
80d69917ea * Rename the macro to user_known_package_manager_in_container
+ Add a comment to explain how we should use this macro

Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-03 00:03:35 +01:00
Jean-Philippe Lachance
3713f7a614 + Add a simple user_known_package_manager_in_container_conditions macro
* Use the user_known_package_manager_in_container_conditions macro in the "Launch Package Management Process in Container" rule

Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-03 00:03:35 +01:00
Jean-Philippe Lachance
79cb75dcd1 ! Exclude exe_running_docker_save in the "Set Setuid or Setgid bit" rule
Signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2019-12-02 23:54:53 +01:00
Hiroki Suezawa
c736a843a0 rule update: Add kubelet to user_known_chmod_applications list
Signed-off-by: Hiroki Suezawa <suezawa@gmail.com>
2019-12-01 23:27:04 +01:00
kaizhe
cf8395c7ed minor changes
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-11-08 10:38:47 +01:00
kaizhe
f16c744779 rules update: add hyperkube to the whitelist of rule Set Setuid or Setgit bit
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-11-08 10:38:47 +01:00
kaizhe
4ed581853a rules update: add docker-runc-cur to container_entrypoint macro
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-11-08 10:38:47 +01:00
David de Torres
ed767561ac Added list k8s_client_binaries
Added accidentally deleted lines for the list of k8s client binaries.

Signed-off-by: David de Torres <detorres.david@gmail.com>
2019-11-08 09:49:09 +01:00
David de Torres
98becedebb Added rule to detect k8s client tool in container
The rule detects the execution of the k8s client tool in a container and
logs it with WARNING priority.

Signed-off-by: David de Torres <detorres.david@gmail.com>
2019-11-08 09:49:09 +01:00
kaizhe
b38db99449 rules update: add calico/node to trusted privileged container list; add calico_node_write_envvars macro to exception list of write below etc
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-10-25 15:18:32 +02:00
kaizhe
5c61276695 rules update: expand list allowed_k8s_users
Signed-off-by: kaizhe <derek0405@gmail.com>

add comments

Signed-off-by: kaizhe <derek0405@gmail.com>
2019-10-24 13:46:23 +02:00
Mark Stemm
154dd18c8f JSON/K8s Audit Evts extract multiple typed values
Refactor how JSON event/k8s audit events extract values in two important
ways:

1. An event can now extract multiple values.
2. The extracted value is a class json_event_value instead of a simple
string.

The driver for 1. was that some filtercheck fields like
"ka.req.container.privileged" actually should extract multiple values,
as a pod can have multiple containers and it doesn't make sense to
summarize that down to a single value.

The driver for 2. is that by having an object represent a single
extracted value, you can also hold things like numbers e.g. ports, uids,
gids, etc. and ranges e.g. [0:3]. With an object, you can override
operators ==, <, etc. to do comparisons between the numbers and ranges,
or even set membership tests between extracted numbers and sets of
ranges.

This is really handy for a lot of new fields implemented as a part of
PSP support, where you end up having to check for overlaps between the
paths, images, ports, uids, etc in a K8s Audit Event and the acceptable
values, ranges, path prefixes enumerated in a PSP.

Implementing these changes also involve an overhaul of how aliases are
implemented. Instead of having an optional "formatting" function, where
arguments to the formatting function were expressed as text within the
index, define optional extraction and indexing functions. If an
extraction function is defined, it's responsible for taking the full
json object and calling add_extracted_value() to add values. There's a
default extraction function that uses a list of json_pointers with
automatic iteration over array values returned by a json pointer.

There's still a notion of filter fields supporting indexes--that's
simply handled within the default extraction or custom extraction
function. And for most fields, there won't be a need to write a custom
extraction function simply to implement indexing.

Within a json_event_filter_check object, instead of having a single
extracted value as a string, hold a vector of extracted json_event_value
objects (vector because order matters) and a set of json_event_value
objects (for set comparisons) as m_evalues. Values on the right hand
side of the expression are held as a set m_values.

json_event_filter_check::compare now supports IN/INTERSECTS as set
comparisons. It also supports PMATCH using path_prefix_search objects,
which simplifies checks like ka.req.pod.volumes.hostpath--now they can
be expressed as "ka.req.pod.volumes.hostpath intersects (/proc,
/var/run/docker.sock, /, /etc, /root)" instead of
"ka.req.volume.hostpath[/proc]=true or
ka.req.volume.hostpath[/root]=true or ...".

Define ~10 new filtercheck fields that extract pod properties like
hostIpc, readOnlyRootFilesystem, etc. that are relevant for PSP validation.

As a part of these changes, also clarify the names of filter fields
related to pods to always have a .pod in the name. Furthermore, fields
dealing with containers in a pod always have a .pod.containers prefix in
the name.

Finally, change the comparisons for existing k8s audit rules to use
"intersects" and/or "in" when appropriate instead of a single equality
comparison.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-10-15 19:45:31 +02:00
Felipe Bessa Coelho
8353a0b22e Ignore sensitive mounts from ecs-agent
Without this, as ecs-agent starts we get a bunch of errors that look
like this (reformatted for readability):

  Notice Container with sensitive mount started (
    user=root
    command=init -- /agent ecs-agent (id=19d4e98bb0dc)
    image=amazon/amazon-ecs-agent:latest
    mounts=/proc:/host/proc:ro:false:rprivate,$lotsofthings
  )

ecs-agent needs those to work properly, so this can cause lots of false
positives when starting a new instance.

Signed-off-by: Felipe Bessa Coelho <fcoelho.9@gmail.com>
2019-10-09 16:30:36 +02:00
Lorenzo Fontana
c76518c681 update: license headers
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-10-08 16:02:26 +02:00
kaizhe
cdb5d71eb6 rule update: add more comments
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-10-03 10:16:28 +02:00
kaizhe
e81decac13 rule update: fix missing entries
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-10-03 10:16:28 +02:00
kaizhe
a43ae037a9 rules update: add back rule Delete Bash History for backport compatibility
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-10-03 10:16:28 +02:00
kaizhe
79a10ad90e rules update: add fluent/fluentd-kubernetes-daemonset to clear log trusted images
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-09-26 13:56:59 +03:00
Leonardo Di Donato
a019b54fe6 docs: specify labels that apply to each area
If this work as intended PR will automatically get the area labels depending on the files he modified.
In case the user wants it can still apply other areas manually, by slash command, or editing the PR template during the opening of the PR.

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-09-16 10:11:25 +02:00
Lorenzo Fontana
39b51562ed fix(rules): modification of a file should trigger as if it was opened or created
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-08-20 09:45:08 +02:00
Lorenzo Fontana
e229cecbe1 fix(rules): make chmod rules enabled by default
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-08-16 10:23:28 +02:00
Lorenzo Fontana
3ea98b05dd fix(rules/Set Setuid or Setgid bit): use chmod syscalls instead of chmod command
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-08-16 10:23:28 +02:00
kaizhe
1fc509d78b rule update: fine grained sending to mining domain
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-08-12 17:37:01 +02:00
kaizhe
a7ee01103d rule update: add rules for crypto mining
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-08-12 17:37:01 +02:00
Lorenzo Fontana
03fbf432f1 fix: make sure that when deleting shell history the system call is taken into account
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-08-07 15:38:22 +02:00
kaizhe
3dbd43749a rule update: add exception for write below rpm (#745)
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-08-01 20:07:24 +02:00
Jonathan McGowan
bcf83057fa Fix for Write below root error triggering on GKE
GKE regularly calls /exec.fifo from both a system level, and within
individual falco pods.  As is this triggers errors multiple times every
hour.  This change adds /exec.fifo to the expected files below root that
will be called.

Signed-off-by: Jonathan McGowan <jonnymcgow7@gmail.com>
2019-07-30 18:27:17 +02:00
ntimo
d7956a2a09 add docker.io/prom/node-exporter to falco_sensitive_mount_images
Signed-off-by: Timo Nowitzki <git@nowitzki.me>
2019-07-24 16:25:47 +02:00
ntimo
9308c1ee55 add docker.io/google/cadvisor to falco_sensitive_mount_images
Signed-off-by: Timo Nowitzki <git@nowitzki.me>
2019-07-24 16:25:47 +02:00
kaizhe
d6c089c917 add netdata/netdata to falco_sensitive_mount_images
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-07-23 18:50:23 +02:00
kaizhe
9ab718c100 rules update:
Add trusted_logging_images macro for rule Clear Log Hisotry as exception

Signed-off-by: kaizhe <derek0405@gmail.com>
2019-07-23 18:50:23 +02:00
Spencer Krum
5acdb16e89 Fix shell_procs macro
Extra parentheses broke the Terminal check

Co-Authored-By: Michael Ducy <michael@ducy.org>
Signed-off-by: Spencer Krum <skrum@us.ibm.com>
2019-07-22 04:43:26 -07:00
Leonardo Di Donato
cb5a3a14e6 new: k8s.gcr.io/kube-proxy addition to falco trusted images
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
2019-07-10 16:43:41 +02:00
Mattia Pagnozzi
a32870ae1d Add runc to the list of possible container entrypoint parents
Docker versions >= 18.09 removed the "docker-" prefix, so include runc
in the list.

Signed-off-by: Mattia Pagnozzi <mattia.pagnozzi@gmail.com>
2019-07-09 14:31:49 +02:00
kaizhe
16bd8919ab rule update: fix syntax error
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-07-01 10:33:20 +02:00
kaizhe
6ce17d6fcb add rfc_1918_address macro
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-07-01 10:33:20 +02:00
kaizhe
c12052e03d add openshift image to whitelist
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-07-01 10:33:20 +02:00
kaizhe
8ed33a04fd rule update: add placeholder for rules write below root/etc
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-07-01 10:33:20 +02:00
kaizhe
d158d99800 rule update: add exception for rule change thread namespace
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-06-20 12:12:05 -07:00
kaizhe
88ed98ce81 update to macro
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-06-17 21:41:00 +02:00
kaizhe
18960b01b0 more comment
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-06-17 21:41:00 +02:00
kaizhe
5beddf5320 rule update: add back trusted_containers list for backport compatibility
Signed-off-by: kaizhe <derek0405@gmail.com>
2019-06-17 21:41:00 +02:00
Kaizhe Huang
cfaa52f522 rule update:
1. Extend macro mkdir with syscall mkdirat (#337)
2. add placeholder for whitelist in rule Clear Log Activities (#632)

Signed-off-by: kaizhe <derek0405@gmail.com>

add docker.io/ to the trusted images list

Signed-off-by: kaizhe <derek0405@gmail.com>

rule update: add container.id and image in the rule output except those rules with "not container" in condition

Signed-off-by: kaizhe <derek0405@gmail.com>

Remove empty line

Signed-off-by: Kaizhe Huang<derek0405@gmail.com>
2019-06-13 22:27:59 +02:00
Mark Stemm
097e3b4769 Start using falco_ prefix for default lists/macros
Start using a falco_ prefix for falco-provided lists/macros. Not
changing existing object names to retain compatibility.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-06-11 20:06:51 +02:00
Mark Stemm
5d0bccbbfb Define always_true/never_true macros for k8s evts
Define macros k8s_audit_always_true/k8s_audit_never_true that work for
k8s audit events. Use them in macros that were asserting true/false values.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-06-11 20:06:51 +02:00
Mark Stemm
e8c08b9a77 Clean up privileged/sens mount container rules
Previously, the exceptions for Launch Privileged Container/Launch
Sensitive Mount Container came from a list of "trusted" images and/or a
macro that defined "trusted" containers. We want more fine-grained
control over the exceptions for these rules, so split them into
exception lists/macros that are specific to each rule. This defines:

 - falco_privileged_images: only those images that are known to require
   privileged=true
 - falco_privileged_containers: uses privileged_images and (for now) still
   allows all openshift images
 - user_privileged_containers: allows user exceptions
 - falco_sensitive_mount_images: only thoe images that are known to perform
   sensitive mounts
 - falco_sensitive_mount_containers: uses sensitive_mount_images
 - user_sensitive_mount_containers: allows user exceptions

For backwards compatibility purposes only, we keep the trusted_images
list and user_trusted_containers macro and they are still used as
exceptions for both rules. Comments recommend using the more
fine-grained alternatives, though.

While defining these lists, also do another survey to see if they still
require these permissions and remove them if they didn't. Removed:
 - quay.io/coreos/flannel
 - consul

Moved to sensitive mount only:
 - gcr.io/google_containers/hyperkube
 - datadog
 - gliderlabs/logspout

Finally, get rid of the k8s audit-specific lists of privileged/sensitive
mount images, relying on the ones in falco_rules.yaml.

Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
2019-06-11 20:06:51 +02:00
Lorenzo Fontana
be9c6b4ccc new: initial owners files for Falco
Signed-off-by: Lorenzo Fontana <lo@linux.com>
2019-06-10 18:40:27 -07:00
Kaizhe Huang
780129fa1b add exception for coreos/pod-checkpointer 2019-06-07 13:47:00 -07:00
Kaizhe Huang
3026f3946e rule update: improve rancher macro
Signed-off-by: Kaizhe Huang <derek0405@gmail.com>
2019-06-07 13:47:00 -07:00
Kaizhe Huang
cd32cceff8
rule update: update image check from rancher_write_conf macro (#648)
* rule update: remove image check from rancher_write_conf macro

* remove healthcheck from rancher_writing_conf

* add image check for healthcheck

* add image check

* update nginx_writing_conf macro
2019-06-05 22:08:11 -07:00
Kaizhe Huang
68211daffa
Rule updates 2019 05.v3 (#637)
* rule update: reduce noise for oc

* revert back macro openshift_writing_conf

* minor fix
2019-06-05 15:38:45 -07:00
Spencer Krum
de8b92fa05 Add rules for running with IBM Cloud Kubernetes Service (#634)
* Allow containerd to start containers

Needed for IBM Cloud Kubernetes Service

* Whitelist state checks for galley(istio)

Galley is a component of istio
https://istio.io/docs/reference/commands/galley/

* Whitelist calcio scratching /status.json

This is the observed behaviour on IBM Cloud Kubernetes Service

* Add whitelisting for keeaplived config file
2019-06-05 11:30:58 -07:00
Chris Northwood
24b4d83eec Allow Ansible to run using Python 3 (#625)
Some newer distros default to Python 3 by default, not 2, which causes Ansible to trigger these rules.

falco-CLA-1.0-contributing-entity: 1500 Services Ltd
falco-CLA-1.0-signed-off-by: Chris Northwood <chris.northwood@1500cloud.com>
2019-06-05 11:28:49 -07:00
Dario Martins Silva
7a56f1c2d9 fix egrep rule and ncat rule (#617)
* fix egrep rule and ncat rule
falco-CLA-1.0-signed-off-by: Dario Martins Silva <dmsilva@protonmail.com>

* add space after arguments, add --lua-exec
falco-CLA-1.0-signed-off-by: Dario Martins Silva <dmsilva@protonmail.com>
2019-06-05 11:26:22 -07:00
Stefan Thies
e91bc497ac Add Sematext Monitoring & Logging agents to trusted k8s containers (#594)
Please note
registry.access.redhat.com/sematext/agent,
registry.access.redhat.com/sematext/logagent
are not available yet, but we are in the process of certification ...
2019-06-05 11:23:29 -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
Kaizhe Huang
3306941cce
rule update: add launch remote file copy tool in container (#600) 2019-05-15 16:53:10 -07: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
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
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
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
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
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
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
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
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
Kaizhe Huang
50c6515da5 kh: improve mount on /var/lib/kubelet rule (#509) 2019-01-30 14:13:19 -08: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
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
Mark Stemm
cd53c58808
Make k8s-audit rules and main rules compatible (#464)
Add k8s audit rules to falco's config so they are read by default.

Rename some generic macros like modify, create, delete in the k8s audit
rules so they don't overlap with macros in the main rules file.
2018-11-09 12:56:05 -08:00
Mark Stemm
c6169e1aaa
Rule updates 2018 11.v1 (#455)
* Add sensitive mount of mouting to /var/lib/kubelet*

* Fix GKE/Istio false positives

- Allow kubectl to write below /root/.kube
- Allow loopback/bridge (e.g. /home/kubernetes/bin/) to setns.
- Let istio pilot-agent write to /etc/istio.
- Let google_accounts(_daemon) write user .ssh files.
- Add /health as an allowed file below /.

This fixes https://github.com/falcosecurity/falco/issues/439.

* Improve ufw/cloud-init exceptions

Tie them to both the program and the file being written.

Also move the cloud-init exception to monitored_directory.
2018-11-09 11:51:15 -08:00
Julien
b79670a79a adding few executables in corresponding groups (#445)
* merge with testing environment

* extra valid executables

* cleaning unused code or duplicate
2018-11-09 10:25:55 -08:00
Mark Stemm
1f28f85bdf
K8s audit evts (#450)
* Add new json/webserver libs, embedded webserver

Add two new external libraries:

 - nlohmann-json is a better json library that has stronger use of c++
   features like type deduction, better conversion from stl structures,
   etc. We'll use it to hold generic json objects instead of jsoncpp.

 - civetweb is an embeddable webserver that will allow us to accept
   posted json data.

New files webserver.{cpp,h} start an embedded webserver that listens for
POSTS on a configurable url and passes the json data to the falco
engine.

New falco config items are under webserver:
  - enabled: true|false. Whether to start the embedded webserver or not.
  - listen_port. Port that webserver listens on
  - k8s_audit_endpoint: uri on which to accept POSTed k8s audit events.

(This commit doesn't compile entirely on its own, but we're grouping
these related changes into one commit for clarity).

* Don't use relative paths to find lua code

You can look directly below PROJECT_SOURCE_DIR.

* Reorganize compiler lua code

The lua compiler code is generic enough to work on more than just
sinsp-based rules, so move the parts of the compiler related to event
types and filterchecks out into a standalone lua file
sinsp_rule_utils.lua.

The checks for event types/filterchecks are now done from rule_loader,
and are dependent on a "source" attribute of the rule being
"sinsp". We'll be adding additional types of events next that come from
sources other than system calls.

* Manage separate syscall/k8s audit rulesets

Add the ability to manage separate sets of rules (syscall and
k8s_audit). Stop using the sinsp_evttype_filter object from the sysdig
repo, replacing it with falco_ruleset/falco_sinsp_ruleset from
ruleset.{cpp,h}. It has the same methods to add rules, associate them
with rulesets, and (for syscall) quickly find the relevant rules for a
given syscall/event type.

At the falco engine level, there are new parallel interfaces for both
types of rules (syscall and k8s_audit) to:
  - add a rule: add_k8s_audit_filter/add_sinsp_filter
  - match an event against rules, possibly returning a result:
    process_sinsp_event/process_k8s_audit_event

At the rule loading level, the mechanics of creating filterchecks
objects is handled two factories (sinsp_filter_factory and
json_event_filter_factory), both of which are held by the engine.

* Handle multiple rule types when parsing rules

Modify the steps of parsing a rule's filter expression to handle
multiple types of rules. Notable changes:

 - In the rule loader/ast traversal, pass a filter api object down,
   which is passed back up in the lua parser api calls like nest(),
   bool_op(), rel_expr(), etc.
 - The filter api object is either the sinsp factory or k8s audit
   factory, depending on the rule type.
 - When the rule is complete, the complete filter is passed to the
   engine using either add_sinsp_filter()/add_k8s_audit_filter().

* Add multiple output formatting types

Add support for multiple output formatters. Notable changes:

 - The falco engine is passed along to falco_formats to gain access to
   the engine's factories.
 - When creating a formatter, the source of the rule is passed along
   with the format string, which controls which kind of output formatter
   is created.

Also clean up exception handling a bit so all lua callbacks catch all
exceptions and convert them into lua errors.

* Add support for json, k8s audit filter fields

With some corresponding changes in sysdig, you can now create general
purpose filter fields and events, which can be tied together with
nesting, expressions, and relational operators. The classes here
represent an instance of these fields devoted to generic json objects as
well as k8s audit events. Notable changes:

 - json_event: holds a json object, used by all of the below

 - json_event_filter_check: Has the ability to extract values out of a
   json_event object and has the ability to define macros that associate
   a field like "group.field" with a json pointer expression that
   extracts a single property's value out of the json object. The basic
   field definition also allows creating an index
   e.g. group.field[index], where a std::function is responsible for
   performing the indexing. This class has virtual void methods so it
   must be overridden.

 - jevt_filter_check: subclass of json_event_filter_check and defines
   the following fields:
     - jevt.time/jevt.rawtime: extracts the time from the underlying json object.
     - jevt.value[<json pointer>]: general purpose way to extract any
       json value out of the underlying object. <json pointer> is a json
       pointer expression
     - jevt.obj: Return the entire object, stringified.

 - k8s_audit_filter_check: implements fields that extract values from
   k8s audit events. Most of the implementation is in the form of macros
   like ka.user.name, ka.uri, ka.target.name, etc. that just use json
   pointers to extact the appropriate value from a k8s audit event. More
   advanced fields like ka.uri.param, ka.req.container.image use
   indexing to extract individual values out of maps or arrays.

 - json_event_filter_factory: used by things like the lua parser api,
   output formatter, etc to create the necessary objects and return
   them.

  - json_event_formatter: given a format string, create the necessary
    fields that will be used to create a resolved string when given a
    json_event object.

* Add ability to list fields

Similar to sysdig's -l option, add --list (<source>) to list the fields
supported by falco. With no source specified, will print all
fields. Source can be "syscall" for inspector fields e.g. what is
supported by sysdig, or "k8s_audit" to list fields supported only by the
k8s audit support in falco.

* Initial set of k8s audit rules

Add an initial set of k8s audit rules. They're broken into 3 classes of
rules:

 - Suspicious activity: this includes things like:
    - A disallowed k8s user performing an operation
    - A disallowed container being used in a pod.
    - A pod created with a privileged pod.
    - A pod created with a sensitive mount.
    - A pod using host networking
    - Creating a NodePort Service
    - A configmap containing private credentials
    - A request being made by an unauthenticated user.
    - Attach/exec to a pod. (We eventually want to also do privileged
      pods, but that will require some state management that we don't
      currently have).
    - Creating a new namespace outside of an allowed set
    - Creating a pod in either of the kube-system/kube-public namespaces
    - Creating a serviceaccount in either of the kube-system/kube-public
      namespaces
    - Modifying any role starting with "system:"
    - Creating a clusterrolebinding to the cluster-admin role
    - Creating a role that wildcards verbs or resources
    - Creating a role with writable permissions/pod exec permissions.
 - Resource tracking. This includes noting when a deployment, service,
    - configmap, cluster role, service account, etc are created or destroyed.
 - Audit tracking: This tracks all audit events.

To support these rules, add macros/new indexing functions as needed to
support the required fields and ways to index the results.

* Add ability to read trace files of k8s audit evts

Expand the use of the -e flag to cover both .scap files containing
system calls as well as jsonl files containing k8s audit events:

If a trace file is specified, first try to read it using the
inspector. If that throws an exception, try to read the first line as
json. If both fail, return an error.

Based on the results of the open, the main loop either calls
do_inspect(), looping over system events, or
read_k8s_audit_trace_file(), reading each line as json and passing it to
the engine and outputs.

* Example showing how to enable k8s audit logs.

An example of how to enable k8s audit logging for minikube.

* Add unit tests for k8s audit support

Initial unit test support for k8s audit events. A new multiplex file
falco_k8s_audit_tests.yaml defines the tests. Traces (jsonl files) are
in trace_files/k8s_audit and new rules files are in
test/rules/k8s_audit.

Current test cases include:

- User outside allowed set
- Creating disallowed pod.
- Creating a pod explicitly on the allowed list
- Creating a pod w/ a privileged container (or second container), or a
  pod with no privileged container.
- Creating a pod w/ a sensitive mount container (or second container), or a
  pod with no sensitive mount.
- Cases for a trace w/o the relevant property + the container being
  trusted, and hostnetwork tests.
- Tests that create a Service w/ and w/o a NodePort type.
- Tests for configmaps: tries each disallowed string, ensuring each is
  detected, and the other has a configmap with no disallowed string,
  ensuring it is not detected.
- The anonymous user creating a namespace.
- Tests for all kactivity rules e.g. those that create/delete
  resources as compared to suspicious activity.
- Exec/Attach to Pod
- Creating a namespace outside of an allowed set
- Creating a pod/serviceaccount in kube-system/kube-public namespaces
- Deleting/modifying a system cluster role
- Creating a binding to the cluster-admin role
- Creating a cluster role binding that wildcards verbs or resources
- Creating a cluster role with write/pod exec privileges

* Don't manually install gcc 4.8

gcc 4.8 should already be installed by default on the vm we use for
travis.
2018-11-09 10:15:39 -08:00
Mark Stemm
6ca316a7cc
Rule updates 2018 08.v1 (#398)
* Add additional rpm writing programs

rhn_check, yumdb.

* Add 11-dhclient as a dhcp binary

* Let runuser read below pam

It reads those files to check permissions.

* Let chef write to /root/.chef*

Some deployments write directly below /root.

* Refactor openshift privileged images

Rework how openshift images are handled:

Many customers deploy to a private registry, which would normally
involve duplicating the image list for the new registry. Now, split the
image prefix search (e.g. <host>/openshift3) from the check of the image
name. The prefix search is in allowed_openshift_registry_root, and can
be easily overridden to add a new private registry hostname. The image
list check is in openshift_image, is conditioned on
allowed_openshift_registry_root, and does a contains search instead of a
prefix match.

Also try to get a more comprehensive set of possible openshift3 images,
using online docs as a guide.

* Also let sdchecks directly setns

A new macro python_running_sdchecks is similar to
parent_python_running_sdchecks but works on the process itself.

Add this as an exception to Change thread namespace.
2018-10-12 19:44:24 -07:00
Guido García
7fa6fc1b70 fix: use succeeded instead of completed to filter cronjob pods (#441)
Signed-off-by: Guido García <guido.garciabernardo@telefonica.com>
2018-10-12 19:43:27 -07:00
Mark Stemm
6445cdb950
Better copyright notices (#426)
* Use correct copyright years.

Also include the start year.

* Improve copyright notices.

Use the proper start year instead of just 2018.

Add the right owner Draios dba Sysdig.

Add copyright notices to some files that were missing them.
2018-09-26 19:49:19 -07:00
Mark Stemm
2352b96d6b
Change license to Apache 2.0 (#419)
Replace references to GNU Public License to Apache license in:

 - COPYING file
 - README
 - all source code below falco
 - rules files
 - rules and code below test directory
 - code below falco directory
 - entrypoint for docker containers (but not the Dockerfiles)

I didn't generally add copyright notices to all the examples files, as
they aren't core falco. If they did refer to the gpl I changed them to
apache.
2018-09-20 11:47:10 -07:00
Mark Stemm
d63542d8ff
Rule updates 2018 07.v1 (#388)
* Add dpkg-divert as a debian package mgmt program.

* Add pip3 as a package mgmt program.

* Let ucpagent write config

Since the name is fairly generic (apiserver), require that it runs in a
container with image docker/ucp-agent.

* Let iscsi admin programs write config

* Add parent to some output strings

Will aid in addressing false positives.

* Let update-ca-trust write to pki files

* Add additional root writing programs

- zap: web application security tool
- airflow: apache app for managing data pipelines
- rpm can sometimes write below /root/.rpmdb
- maven can write groovy files

* Expand redis etc files

Additional program redis-launcher.(sh) and path /etc/redis.

* Add additional root directories

/root/workspace could be used by jenkins, /root/oradiag_root could be
used by Oracle 11 SQL*Net.

* Add pam-config as an auth program

* Add additional trusted containers

openshift image inspector, alternate name for datadog agent, docker ucp
agent, gliderlabs logspout.

* Add microdnf as a rpm binary.

https://github.com/rpm-software-management/microdnf

* Let coreos update-ssh-keys write /home/core/.ssh

* Allow additional writes below /etc/iscsi

Allow any path starting with /etc/iscsi.

* Add additional /root write paths

Additional files, with /root/workspace changing from a directory to a
path prefix.

* Add additional openshift trusted container.

* Also allow grandparents for ms_oms_writing_conf

In some cases the program spawns intermediate shells, for example:

07:15:30.756713513: Error File below /etc opened for writing (user= command=StatusReport.sh /opt/microsoft/omsconfig/Scripts/StatusReport.sh D34448EA-363A-42C2-ACE0-ACD6C1514CF1 EndTime parent=sh pcmdline=sh -c /opt/microsoft/omsconfig/Scripts/StatusReport.sh D34448EA-363A-42C2-ACE0-ACD6C1514CF1 EndTime file=/etc/opt/omi/conf/omsconfig/last_statusreport program=StatusReport.sh gparent=omiagent ggparent=omiagent gggparent=omiagent) k8s.pod= container=host k8s.pod= container=host

This should fix #387.
2018-07-24 13:14:35 -07:00
Mark Stemm
c5523d89a7
Rule updates 2018 04.v2 (#366)
* Add alternatives as a binary dir writer

It can set symlinks below binary dirs.

* Let userhelper read sens.files/write below /etc

Part of usermode package, can be used by oVirt.

* Let package mgmt progs urlgrabber pki files

Some package management programs run urlgrabber-ext-{down} to update pki
files.

* Add additional root directory

for Jupyter-notebook

* Let brandbot write to /etc/os-release

Used on centos

* Add an additional veritas conf directory.

Also /etc/opt/VRTS...

* Let appdynamics spawn shells

Java, so we look at parent cmdline.

* Add more ancestors to output

In an attempt to track down the source of some additional shell
spawners, add additional parents.

* Let chef write below bin dirs/rpm database

Rename an existing macro chef_running_yum_dump to python_running_chef
and add additional variants.

Also add chef-client as a package management binary.

* Remove dangling macro.

No longer in use.

* Add additional volume mgmt progs

Add pvscan as a volume management program and add an additional
directory below /etc. Also rename the macro to make it more generic.

* Let openldap write below /etc/openldap

Only program is run-openldap.sh for now.

* Add additional veritas directory

Also /etc/vom.

* Let sed write /etc/sedXXXXX files

These are often seen in install scrips for rpm/deb packages. The test
only checks for /etc/sed, as we don't have anything like a regex match
or glob operator.

* Let dse (DataStax Search) write to /root

Only file is /root/tmp__.

* Add additional mysql programs and directories

Add run-mysqld and /etc/my.cnf.d directory.

* Let redis write its config below /etc.

* Let id program open network connections

Seen using port 111 (sun-rpc, but really user lookups).

* Opt-in rule for protecting tomcat shell spawns

Some users want to consider any shell spawned by tomcat suspect for
example, protecting against the famous apache struts attack
CVE-2017-5638, while others do not.

Split the difference by adding a macro
possibly_parent_java_running_tomcat, but disabling it by default.

*  added ossec-syscheckd to read_sensitive_file_binaries

* Add "Write below monitored directory"

Take the technique used by "Write below binary dir", and make it more
general, expanding to a list of "monitored directories". This contains
common directories like /boot, /lib, etc.

It has a small workaround to look for home ssh directories without using
the glob operator, which has a pending fix in
https://github.com/draios/sysdig/pull/1153.

* Fix FPs

Move monitored_dir to after evt type checks and allow mkinitramfs to
write below /boot

* Addl boot writers.
2018-07-06 13:17:17 -07:00
Mark Stemm
6be4830342
Improve compatibility with falco 0.9.0 (#357)
* Improve compatibility with falco 0.9.0

Temporarily remove some rules features that are not compatible with
falco 0.9.0. We'll release a new falco soon, after which we'll add these
rules features back.

* Disable the unexpected udp traffic rule by default

Some applications will connect a udp socket to an address only to
test connectivity. Assuming the udp connect works, they will follow
up with a tcp connect that actually sends/receives data.

This occurs often enough that we don't want to update the Unexpected UDP
Traffic rule by default, so add a macro do_unexpected_udp_check which is
set to never_true. To opt-in, override the macro to use the condition
always_true.
2018-04-24 11:23:16 -07:00
Mark Stemm
e6bf402117
Rule updates 2018 04.v1 (#350)
* added new command lines for rabbitMQ

* added httpd_writing_ssl_conf macro and add it to write_etc_common

*  modified httpd_writing_ssl_conf to add additional files

* added additional command to httpd_writing_ssl_conf

* Wrap condition

Wrap condition with folded style.

* Consolidate test connect ports into one list

There were several exceptions for apps that do a udp connect on an
address simply to see if it works, folllowed by a tcp connect that
actually sends/receives data.

Unify these exceptions into a single list test_connect_ports, and add
port 9 (discard, used by dockerd).
2018-04-24 09:24:50 -07:00
Mark Stemm
b6b490e26e
Add Rule for unexpected udp traffic (#320)
* Add Rule for unexpected udp traffic

New rule Unexpected UDP Traffic checks for udp traffic not on a list of
expected ports. Currently blocked on
https://github.com/draios/falco/issues/308.

* Add sendto/recvfrom in inbound/outbound macros

Expand the inbound/outbound macros to handle sendfrom/recvto events, so
they can work on unconnected udp sockets. In order to avoid a flood of
events, they also depend on fd.name_changed to only consider
sendto/recvfrom when the connection tuple changes.

Also make the check for protocol a positive check for udp instead of not tcp,
to avoid a warning about event type filters potentially appearing before
a negative condition. This makes filtering rules by event type easier.

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

* Add additional restrictions for inbound/outbound

 - only look for fd.name_changed on unconnected sockets.
 - skip connections where both ips are 0.0.0.0 or localhost network.
 - only look for successful or non-blocking actions that are in progress

* Add a combined inbound/outbound macro

Add a combined inbound/outbound macro so you don't have to do all the
other net/result related tests more than once.

* Fix evt generator for new in/outbound restrictions

The new rules skip localhost, so instead connect a udp socket to a
non-local port. That still triggers the inbound/outbound macros.

* Address FPs in regression tests

In some cases, an app may make a udp connection to an address with a
port of 0, or to an address with an application's port, before making a
tcp connection that actually sends/receives traffic. Allow these
connects.

Also, check both the server and client port and only consider the
traffic unexpected if neither port is in range.
2018-04-18 10:07:22 -07:00
Mattia Pagnozzi
96b4ff0ee5 Fix/Expand "Modify bin dirs" rule (#353)
* Also check evt.abspath in "Modify binary dirs" rule
For unlinkat evt.arg[1] is not the path of the file/dir removed.

* Monitor renameat too in "Modify binary dirs" rule
2018-04-13 15:17:23 -07:00
Mark Stemm
c5b3097a65
Add ability to read rules files from directories (#348)
* Add ability to read rules files from directories

When the argument to -r <path> or an entry in falco.yaml's rules_file
list is a directory, read all files in the directory and add them to the
rules file list. The files in the directory are sorted alphabetically
before being added to the list.

The installed falco adds directories /etc/falco/rules.available and
/etc/falco/rules.d and moves /etc/falco/application_rules.yaml to
/etc/falco/rules.available. /etc/falco/rules.d is empty, but the idea is
that admins can symlink to /etc/falco/rules.available for applications
they want to enable.

This will make it easier to add application-specific rulesets that
admins can opt-in to.

* Unit test for reading rules from directory

Copy the rules/trace file from the test multiple_rules to a new test
rules_directory. The rules files are in rules/rules_dir/{000,001}*.yaml,
and the test uses a rules_file argument of rules_dir. Ensure that the
same events are detected.
2018-04-05 17:03:37 -07:00
Mark Stemm
1516fe4eac
Rule updates 2018 02.v3 (#344)
* add common fluentd command, let docker modify

Add a common fluentd command, and let docker operations modify bin dir

* Add abrt-action-sav(...) as a rpm program

https://linux.die.net/man/1/abrt-action-save-package-data

* Add etc writers for more ms-on-linux svcs

Microsoft SCX and Azure Network Watcher Agent.

* Let nginx write its own config.

* Let chef-managed gitlab write gitlab config

* Let docker container fsen outside of containers

The docker process can also be outside of a container when doing actions
like docker save, etc, so drop the docker requirement.

* Expand the set of haproxy configs.

Let the parent process also be haproxy_reload and add an additional
directory.

* Add an additional node-related file below /root

For node cli.

* Let adclient read sensitive files

Active Directory Client.

* Let mesos docker executor write shells

* Add additional privileged containers.

A few more openshift-related containers and datadog.

* Add a kafka admin command line as allowed shell

In this case, run by cassandra

* Add additional ignored root directories

gradle and crashlytics

* Add back mesos shell spawning binaries back

This list will be limited only to those binaries known to spawn
shells. Add mesos-slave/mesos-health-ch.

* Add addl trusted containers

Consul and mesos-slave.

* Add additional config writers for sosreport

Can also write files below /etc/pki/nssdb.

* Expand selinux config progs

Rename macro to selinux_writing_conf and add additional programs.

* Let rtvscand read sensitive files

Symantec av cli program.

* Let nginx-launch write its own certificates

Sometimes directly, sometimes by invoking openssl.

* Add addl haproxy config writers

Also allow the general prefix /etc/haproxy.

* Add additional root files.

Mongodb-related.

* Add additional rpm binaries

rpmdb_stat

* Let python running get-pip.py modify binary files

Used as a part of directly running get-pip.py.

* Let centrify scripts read sensitive files

Scripts start with /usr/share/centrifydc

* Let centrify progs write krb info

Specifically, adjoin and addns.

* Let ansible run below /root/.ansible

* Let ms oms-run progs manage users

The parent process is generally omsagent-<version> or scx-<version.

* Combine & expand omiagent/omsagent macros

Combine the two macros into a single ms_oms_writing_conf and add both
direct and parent binaries.

* Let python scripts rltd to ms oms write binaries

Python scripts below /var/lib/waagent.

* Let google accounts daemon modify users

Parent process is google_accounts(_daemon).

* Let update-rc.d modify files below /etc

* Let dhcp binaries write indirectly to etc

This allows them to run programs like sed, cp, etc.

* Add istio as a trusted container.

* Add addl user management progs

Related to post-install steps for systemd/udev.

* Let azure-related scripts write below etc

Directory is /etc/azure, scripts are below /var/lib/waagent.

* Let cockpit write its config

http://www.cockpit-project.org/

* Add openshift's cassandra as a trusted container

* Let ipsec write config

Related to strongswan (https://strongswan.org/).

* Let consul-template write to addl /etc files

It may spawn intermediate shells and write below /etc/ssl.

* Add openvpn-entrypo(int) as an openvpn program

Also allow subdirectories below /etc/openvpn.

* Add additional files/directories below /root

* Add cockpit-session as a sensitive file reader

* Add puppet macro back

Still used in some people's user rules files.

* Rename name= to program=

Some users pointed out that name= was ambiguous, especially when the
event includes files being acted upon. Change to program=.

* Also let omiagent run progs that write oms config

It can run things like python scripts.

* Allow writes below /root/.android
2018-04-02 18:10:11 -07:00
Mark Stemm
947faca334
Rule updates 2018 02.v2 (#326)
* Let OMS agent for linux write config

Programs are omiagent/omsagent/PerformInventor/in_heartbeat_r* and files
are below /etc/opt/omi and /etc/opt/microsoft/omsagent.

* Handle really long classpath lines for cassandra

Some cassandra cmdlines are so long the classpath truncates the cmdline
before the actual entry class gets named. In those cases also look for
cassandra-specific config options.

* Let postgres binaries read sensitive files

Also add a couple of postgres cluster management programs.

* Add apt-add-reposit(ory) as a debian mgmt program

* Add addl info to debug writing sensitive files

Add parent/grandparent process info.

* Requrire root directory files to contain /

In some cases, a file below root might be detected but the file itself
has no directory component at all. This might be a bug with dropped
events. Make the test more strict by requiring that the file actually
contains a "/".

* Let updmap read sensitive files

Part of texlive (https://www.tug.org/texlive/)

* For selected rules, require proc name to exist

Some rules such as reading sensitive files and writing below etc have
many exceptions that depend on the process name. In very busy
environments, system call events might end up being dropped, which
causes the process name to be missing.

In these cases, we'll let the sensitive file read/write below etc to
occur. That's handled by a macro proc_name_exists, which ensures that
proc.name is not "<NA>" (the placeholder when it doesn't exist).

* Let ucf write generally below /etc

ucf is a general purpose config copying program, so let it generally
write below /etc, as long as it in turn is run by the apt program
"frontend".

* Add new conf writers for couchdb/texmf/slapadd

Each has specific subdirectories below /etc

* Let sed write to addl temp files below /etc

Let sed write to additional temporary files (some directory + "sed")
below /etc. All generally related to package installation scripts.

* Let rabbitmq(ctl) spawn limited shells

Let rabbitmq spawn limited shells that perform read-only tasks like
reading processes/ifaces.

Let rabbitmqctl generally spawn shells.

* Let redis run startup/shutdown scripts

Let redis run specific startup/shutdown scripts that trigger at
start/stop. They generally reside below /etc/redis, but just looking for
the names redis-server.{pre,post}-up in the commandline.

* Let erlexec spawn shells

https://github.com/saleyn/erlexec, "Execute and control OS processes
from Erlang/OTP."

* Handle updated trace files

As a part of these changes, we updated some of the positive trace files
to properly include a process name. These newer trace files have
additional opens, so update the expected event counts to match.

* Let yum-debug-dump write to rpm database

* Additional config writers

Symantec AV for Linux, sosreport, semodule (selinux), all with their
config files.

* Tidy up comments a bit.

* Try protecting node apps again

Try improving coverage of run shell untrusted by looking for shells
below node processes again. Want to see how many FPs this causes before
fully committing to it.

* Let node run directly by docker count as a service

Generally, we don't want to consider all uses of node as a service wrt
spawned shells. But we might be able to consider node run directly by
docker as a "service". So add that to protected_shell_spawner.

* Also add PM2 as a protected shell spawner

This should handle cases where PM2 manages node apps.

* Remove dangling macros/lists

Do a pass over the set of macros/lists, removing most of those that are
no longer referred to by any macro/list. The bulk of the macros/lists
were related to the rule Run Shell Untrusted, which was refactored to
only detect shells run below specific programs. With that change, many
of these exceptions were no longer neeeded.

* Add a "never_true" macro

Add a never_true macro that will never match any event. Useful if you
want to disable a rule/macro/etc.

* Add missing case to write_below_etc

Add the macro veritas_writing_config to write_below_etc, which was
mistakenly not added before.

* Make tracking shells spawned by node optional

The change to generally consider node run directly in a container as a
protected shell spawner was too permissive, causing false
positives. However, there are some deployments that want to track shells
spawned by node as suspect. To address this, create a macro
possibly_node_in_container which defaults to never matching (via the
never_true) macro. In a user rules file, you can override the macro to
remove the never_true clause, reverting to the old behavior.

* Add some dangling macros/lists back

Some macros/lists are still referred to by some widely used user rules
files, so add them back temporarily.
2018-02-26 13:26:28 -05:00
Jean-Philippe Lachance
52e8c16903 + Add the user_known_change_thread_namespace_binaries list to simplify "Change thread namespace" rule tweaks (#324)
sysdig-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>
2018-02-20 11:53:25 -05:00
Mark Stemm
414c9a0eed
Rule updates 2018 02.v1 (#321)
* Add additional allowed files below root.

These are related to node.js apps.

* Let yum-config-mana(ger) write to rpm database.

* Let gugent write to (root) + GuestAgent.log

vRA7 Guest Agent writes to GuestAgent.log with a cwd of root.

* Let cron-start write to pam_env.conf

* Add additional root files and directories

All seen in legitimate cases.

* Let nginx run aws s3 cp

Possibly seen as a part of consul deployments and/or openresty.

* Add rule for disallowed ssh connections

New rule "Disallowed SSH Connection" detects ssh connection attempts
other than those allowed by the macro allowed_ssh_hosts. The default
version of the macro allows any ssh connection, so the rule never
triggers by default.

The macro could be overridden in a local/user rules file, though.

* Detect contacting NodePort svcs in containers

New rule "Unexpected K8s NodePort Connection" detects attempts to
contact K8s NodePort services (i.e. ports >=30000) from within
containers.

It requires overridding a macro nodeport_containers which specifies a
set of containers that are allowed to use these port ranges. By default
every container is allowed.
2018-02-20 10:06:13 -05:00
Mark Stemm
1564e87177
Rule updates 2018.01.v1 (#319)
* Remove remaining fbash references.

No longer relevant after all the installer rules were removed.

* Detect contacting EC2 metadata svc from containers

Add a rule that detects attempts to contact the ec2 metadata service
from containers. By default, the rule does not trigger unless a list of
explicitly allowed containers is provided.

* Detect contacting K8S API Server from container

New rule "Contact K8S API Server From Container" looks for connections
to the K8s API Server. The ip/port for the K8s API Server is in the
macro k8s_api_server and contains an ip/port that's not likely to occur
in practice, so the rule is effectively disabled by default.
2018-01-25 16:06:15 -08:00
Mark Stemm
1feae90c74
Rule updates vdec2 (#315)
* Additional rpm writers, root directories

salt-minion can also touch the rpm database, and some node packages
write below /root/.config/configstore.

* Add smbd as a protected shell spawner.

It's a server-like program.

* Also handle .ash_history

default shell for alpine linux

* Add exceptions for veritas

Let many veritas programs write below /etc/vx.

Let one veritas-related perl script read sensitive files.

* Allow postgres to run wal-e

https://github.com/wal-e/wal-e, archiving program for postgres.

* Let consul (agent) run addl scripts

Also let consul (agent, but the distinction is in the command line args)
to run nc in addition to curl. Also rename the macro.

* Let postgres setuid to itself

Let postgres setuid to itself. Seen by archiving programs like wal-e.

* Also allow consul to run alert check scripts

"sh -c /bin/consul-alerts watch checks --alert-addr 0.0.0.0:9000 ..."

* Add additional privileged containers.

Openshift's logging support containers generally run privileged.

* Let addl progs write below /etc/lvm

Add lvcreate as a program that can write below /etc/lvm and rename the
macro to lvprogs_writing_lvm_archive.

* Let glide write below root

https://glide.sh/, package management for go.

* Let sosreport read sensitive files.

* Let scom server read sensitive files.

Microsoft System Center Operations Manager (SCOM).

* Let kube-router run privileged.

https://github.com/cloudnativelabs/kube-router

* Let needrestart_binaries spawns shells

Was included in prior version of shell rules, adding back.

* Let splunk spawn shells below /opt/splunkforwarder

* Add yum-cron as a rpm binary

* Add a different way to run denyhosts.

Strange that the program is denyhosts.py but observed in actual
environments.

* Let nrpe setuid to nagios.

* Also let postgres run wal-e wrt shells

Previously added as an exception for db program spawned process, need to
add as an exception for run shell untrusted.

* Remove installer shell-related rules

They aren't used that often and removing them cleans up space for new
rules we want to add soon.
2018-01-17 20:29:45 -08:00
Mark Stemm
db0d913acc
Rule updates vdec (#307)
* Let kubelet running loopback spawn shells

Seen by @JPLachance, thanks for the heads up!

* Let docker's "exe" broadly write to files.

As a part of some docker commands like "docker save", etc, the program
exe can write from files on the host filesystem /var/lib/docker/... to a
variety of files within the container.

Allow this via a macro exe_running_docker_save that checks the
commandline as well as the parent and use it as an exclusion for the
write below binary dir/root/etc rules.

* Let chef perform more tasks

- Let chef-client generally read sensitive files and write below /etc.
- Let python running a chef script yum-dump.py write the rpm database.
2017-12-11 22:34:50 -08:00
Mark Stemm
af564f17a6
Add ability to override shell spawning binaries (#304)
Rename user_known_container_shell_spawn_binaries to
user_known_shell_spawn_binaries (the container distinction doesn't exist
any longer) and add it as an exception for run shell untrusted.

That way others can easily exclude shell spawning programs in a second
rules file.
2017-12-01 12:30:04 -08:00
Mark Stemm
d6d975e28c
Refactor shell rules (#301)
* Refactor shell rules to avoid FPs.

Refactoring the shell related rules to avoid FPs. Instead of considering
all shells suspicious and trying to carve out exceptions for the
legitimate uses of shells, only consider shells spawned below certain
processes suspicious.

The set of processes is a collection of commonly used web servers,
databases, nosql document stores, mail programs, message queues, process
monitors, application servers, etc.

Also, runsv is also considered a top level process that denotes a
service. This allows a way for more flexible servers like ad-hoc nodejs
express apps, etc to denote themselves as a full server process.

* Update event generator to reflect new shell rules

spawn_shell is now a silent action. its replacement is
spawn_shell_under_httpd, which respawns itself as httpd and then runs a
shell.

db_program_spawn_binaries now runs ls instead of a shell so it only
matches db_program_spawn_process.

* Comment out old shell related rules

* Modify nodejs example to work w/ new shell rules

Start the express server using runit's runsv, which allows falco to
consider any shells run by it as suspicious.

* Use the updated argument for mkdir

In https://github.com/draios/sysdig/pull/757 the path argument for mkdir
moved to the second argument. This only became visible in the unit tests
once the trace files were updated to reflect the other shell rule
changes--the trace files had the old format.

* Update unit tests for shell rules changes

Shell in container doesn't exist any longer and its functionality has
been subsumed by run shell untrusted.

* Allow git binaries to run shells

In some cases, these are run below a service runsv so we still need
exceptions for them.

* Let consul agent spawn curl for health checks

* Don't protect tomcat

There's enough evidence of people spawning general commands that we
can't protect it.

* Reorder exceptions, add rabbitmq exception

Move the nginx exception to the main rule instead of the
protected_shell_spawner macro. Also add erl_child_setup (related to
rabbitmq) as an allowed shell spawner.

* Add additional spawn binaries

All off these are either below nginx, httpd, or runsv but should still
be allowed to spawn shells.

* Exclude shells when ancestor is a pkg mgmt binary

Skip shells when any process ancestor (parent, gparent, etc) is a
package management binary. This includes the program needrestart. This
is a deep search but should prevent a lot of other more detailed
exceptions trying to find the specific scripts run as a part of
installations.

* Skip shells related to serf

Serf is a service discovery tool and can in some cases be spawned by
apache/nginx. Also allow shells that are just checking the status of
pids via kill -0.

* Add several exclusions back

Add several exclusions back from the shell in container rule. These are
all allowed shell spawns that happen to be below
nginx/fluentd/apache/etc.

* Remove commented-out rules

This saves space as well as cleanup. I haven't yet removed the
macros/lists used by these rules and not used anywhere else. I'll do
that cleanup in a separate step.

* Also exclude based on command lines

Add back the exclusions based on command lines, using the existing set
of command lines.

* Add addl exclusions for shells

Of note is runsv, which means it can directly run shells (the ./run and
./finish scripts), but the things it runs can not.

* Don't trigger on shells spawning shells

We'll detect the first shell and not any other shells it spawns.

* Allow "runc:" parents to count as a cont entrypnt

In some cases, the initial process for a container can have a parent
"runc:[0:PARENT]", so also allow those cases to count as a container
entrypoint.

* Use container_entrypoint macro

Use the container_entrypoint macro to denote entering a container and
also allow exe to be one of the processes that's the parent of an
entrypoint.
2017-11-28 07:04:37 -08:00
Mark Stemm
60af4166de
Rule updates vnov (#300)
* Let supervisor write more generally below /etc

* Let perl+plesk scripts run shells/write below etc

* Allow spaces after some cmdlines

* Add additional shell spawner.

* Add addl package mgmt binaries.

* Add addl cases for java + jenkins

Addl jar files to consider.

* Add addl jenkins-related cmdlines

Mostly related to node scripts run by jenkins

* Let python running some mesos tasks spawn shells

In this case marathon run by python

* Let ucf write below etc

Only below /etc/gconf for now.

* Let dpkg-reconfigur indirectly write below /etc

It may run programs that modify files below /etc

* Add files/dirs/prefixes for writes below root

Build a set of acceptable files/dirs/prefixes for writes below
/root. Mostly triggered by apps that run directly as root.

* Add addl shell spawn binaries.

* Also let java + sbt spawn shells in containers

Not seen only at host level

* Make sure the file below etc is /etc/

Make sure the file below /etc is really below the directory etc aka
/etc/xxx. Otherwise it would match a file /etcfoo.

* Let rancher healthcheck spawn shells

The name healthcheck is relatively innocuous so also look at the parent
process.

* Add addl shell container shell spawn binaries

* Add addl x2go binaries

* Let rabbitq write its config files

* Let rook write below /etc

toolbox.sh is fairly generic so add a condition based on the image name.

* Let consul-template spawn shells

* Add rook/toolbox as a trusted container

Their github pages recommend running privileged.

* Add addl mail binary that can setuid

* Let plesk autoinstaller spawn shells

The name autoinstaller is fairly generic so also look at the parent.

* Let php handlers write its config

* Let addl pkg-* binary write to /etc indirectly

* Add additional shell spawning binaries.

* Add ability to specify user trusted containers

New macro user_trusted_containers allows a user-provided set of
containers that are trusted and are allowed to run privileged.

* If npm runs node, let node spawn shells

* Let python run airflow via a shell.

* Add addl passenger commandlines (for shells)

* Add addl ways datadog can be run

* Let find run shells in containers.

* Add rpmq as a rpm binary

* Let httpd write below /etc/httpd/

* Let awstats/sa-update spawn shells

* Add container entrypoint as a shell

Some images have an extra shell level for image entrypoints.

* Add an additional jenkins commandline

* Let mysql write its config

* Let openvpn write its config

* Add addl root dirs/files

Also move /root/.java to be a general prefix.

* Let mysql_upgrade/opkg-cl spawn shells

* Allow login to perform dns lookups

With run with -h <host> to specify a remote host, some versions of login
will do a dns lookup to try to resolve the host.

* Let consul-template write haproxy config.

* Also let mysql indirectly edit its config

It might spawn a program to edit the config in addition to directly.

* Allow certain sed temp files below /etc/

* Allow debian binaries to indirectly write to /etc

They may spawn programs like sed, touch, etc to change files below /etc.

* Add additional root file

* Let rancher healthcheck be run more indirectly

The grandparent as well as parent of healthcheck can be tini.

* Add more cases for haproxy writing config

Allow more files as well as more scripts to update the config.

* Let vmtoolsd spawn shells on the host

* Add an additional innocuous entrypoint shell

* Let peer-finder (mongodb) spawn shells

* Split application rules to separate file.

Move the contents of application rules, which have never been enabled by
default, to a separate file. It's only installed in the mail falco packages.

* Add more build-related command lines

* Let perl running openresty spawn shells

* Let countly write nginx config

* Let confd spawn shells

* Also let aws spawn shells in containers.
2017-11-16 12:12:31 -08:00
Mark Stemm
15ed651da9 Add additional spawned shells for docker 2017-11-10 12:15:25 -08:00
Mark Stemm
7441052b9a Let consul spawn shells 2017-11-10 12:15:25 -08:00
Mark Stemm
69ede8a785 Let addl progs read sensitive files
They only display file meta-information.
2017-11-10 12:15:25 -08:00
Mark Stemm
8dd34205a8 Let java write specific config files below /etc 2017-11-10 12:15:25 -08:00
Mark Stemm
f379e97124 Let haproxy installation write its config files
The direct or parent process starts with update-haproxy- and the file is
below /etc/haproxy.
2017-11-10 12:15:25 -08:00
Mark Stemm
109f86cd85 Let ruby running pups spawn shells 2017-11-10 12:15:25 -08:00
Mark Stemm
e51fbd6569 Let python/mesos health checks spawn shells 2017-11-10 12:15:13 -08:00
Mark Stemm
060bf78ed8 Add conda as a scripting binary for builds
conda == python packaging tool
2017-11-10 12:05:28 -08:00
Mark Stemm
a2a4cbf586 Let endeca spawn shells in containers also 2017-11-09 14:17:38 -08:00
Mark Stemm
b4bd11bf70 Let nsrun spawn shells in containers. 2017-11-09 14:16:52 -08:00
Mark Stemm
d5869599f7 Add additional innocuous command lines. 2017-11-09 14:16:24 -08:00
Mark Stemm
b0bc00224c Also let terminal shells run innocuous cmdlines
The terminal shell in container rule has always been less permissive
than the other shell rules, mostly because we expect terminal-attached
shells to be less common. However, they might run innocuous commands,
especially from scripting languages like python. So allow the innocuous
commands to run.
2017-11-09 14:13:04 -08:00
Mark Stemm
2f4b39ae6f Let find spawn shells 2017-11-09 14:12:41 -08:00
Mark Stemm
326fb2998a Let curl write below the pki db
Seems to do these writes on redhat?
2017-11-09 14:11:36 -08:00
Mark Stemm
e3ef7a2ed4 Be more flexible about perl Makefile.PL
Allow the command line to start with that command.
2017-11-09 14:10:35 -08:00
Mark Stemm
43f7ee00fb Add an additional ics script ics_status.sh 2017-11-09 14:10:14 -08:00
Mark Stemm
8bcd0e8f05 Add additional cron binaries. 2017-11-09 14:09:36 -08:00
Mark Stemm
85f51cf38c Let salt-minion read sensitive files. 2017-11-08 13:42:24 -08:00
Mark Stemm
2467766f07 Add addl shell spawn conditions
flock can spawn shells, new allowed shell cmdline.
2017-11-08 13:41:43 -08:00
Mark Stemm
2cbff6ff70 Add addl safe root directories 2017-11-08 13:40:56 -08:00
Mark Stemm
e02135f9f0 Let datadog write its config files 2017-11-08 13:40:36 -08:00
Mark Stemm
c1de3dfe7a Let ovsdb-server write below /etc/openvswitch 2017-11-08 13:39:20 -08:00
Mark Stemm
27df0ad29b Add nagios as a monitoring binary
Runs lots of shells
2017-11-08 13:38:07 -08:00
Mark Stemm
e7c2068267 Add addl ruby binary when run by bundle 2017-11-08 13:13:00 -08:00
Mark Stemm
ffed7ef63c Add additional rpm binaries. 2017-11-08 09:28:45 -08:00
Mark Stemm
fe283dcd76 Add exceptions for /root, / writes
Java running as root as well as oracle.
2017-11-08 09:21:17 -08:00
Mark Stemm
4a0ec07235 Let celeryd spawn shells
Parent process name is strange with leading [ and trailing :, so quote
it.
2017-11-08 08:12:35 -08:00
Mark Stemm
fdebfb5b6c Add N_scheduler binaries for mesos
I believe these are related to the equivalent of docker exec for mesos
containers, and aren't specifically related to rabbitmq.
2017-11-08 08:05:42 -08:00
Mark Stemm
0b775fa722 Let java running endeca spawn shells 2017-11-07 11:19:24 -08:00