Tune Runtime Threat Detection Policies

Reduce noisy false positives in the Sysdig Secure Events feed with rule exceptions. Create exceptions yourself, apply suggestions from an event, or let the auto-tuner add them.

Tuning reduces false positives by adding exceptions to Falco rules, so that expected behavior stops generating events and the lower-volume events are left for analysis.

This is especially helpful when you deploy Sysdig Secure runtime policies in a new environment. Your environment may include applications that legitimately perform actions such as running Docker clients in containers, changing namespaces, or writing below binary directories, but which trigger floods of related events in the default policies and rules provided by Sysdig.

There are three ways to add exceptions, from the most hands-on to the most automated:

All three produce the same result, an exception on a rule, which applies to every policy that uses that rule.

Work with Exceptions

Exceptions help reduce false positives and allow behaviors that should not trigger an event—either because they are expected and normal, or because they are unexpected and temporarily accepted—to reduce noise until they are addressed.

Exceptions are tied to rules. To work with them, select a rule and edit it. See Edit & Customize a Rule to understand how.

For Falco rules, both managed and custom, you can define new exceptions or add values to existing exceptions.

For AWS Behavioral Analytics, you can add values to managed exceptions.

Each exception defines the set of fields and operators that an event can be tuned with, along with values.

Exceptions can also be written in the condition in the form of and not clauses, but this would make the condition lengthy and harder to maintain.

Exceptions provide syntactic sugar to accomplish the same thing with a simpler and more straightforward structure.

An exception consists of:

  • A name
  • A set of fields
  • A set of operators, one associated with each field
  • A list called “values”, with each item containing a set of values (one per field and operator)

Example:

- name: sample_exception
  fields: [proc.name, container.image]
  comps: [=, in]
  values:
    - [my-proc, [nginx, alpine]]
    - [my-other-proc, [debian]]

is equivalent to and not ((proc.name = "my-proc" and container.image in ("nginx", "alpine")) or (proc.name = "my-other-proc and container.image = "debian")) in the condition

When the exception evaluates to true, the rule will not trigger an event.

To work on exceptions, you first need to select the Falco rule for which you want to create an exception:

  1. Select Policies > Rules > Rules Library and select a rule.

  2. The Rule Details panel opens on the right.

  3. Click Edit.

  4. If you’re in Form View, click Open Exception Editor. If you’re in YAML View, follow the manage rule exceptions in YAML section.

Create a Custom Exception

  1. Click Create Custom Exception.
  2. Define a name for the exception.
  3. Select the fields you want the exception to apply to and the corresponding operators.
  4. For each field, add a combination of values for which you don’t want the rule to trigger.

Add Values to an Exception

If you have a predefined exception, you can add other combinations of values.

  1. From an existing exception, click the pencil icon on the right.
  2. At the bottom, select Add.
  3. Populate the values for each parameter.

These parameters will define a new condition under which the rule will not produce an event.

Manage Rule Exceptions in YAML

To define a custom exception in YAML, using the Rules Editor, reference an existing rule by its name, add the exception, and specify append: true.

- rule: my custom rule
  exceptions:
    - name: cmdline_writer
      fields: [proc.cmdline, fd.directory]
      comps: [startswith, =]
  append: true

The exception above doesn’t have values. It’s possible to add them in the same element or separately, with another append, as you would do with managed exceptions.

Append Values to an Exception

You can append values to the exception by specifying the rule name and the exception name, without redefining the entire exception, just specifying also append: true.

- rule: my custom rule
  exceptions:
    - name: cmdline_writer
      values: [httpd, /etc/shadow]
  append: true

After appending the values, you would get the same result as:

- rule: my custom rule
  exceptions:
    - name: cmdline_writer
      fields: [proc.cmdline, fd.directory]
      comps: [startswith, =]
      values: [httpd, /etc/shadow]
  append: true

Tune from an Event

When you investigate an event that you know is expected behavior, you can create the exception from the event itself.

If Sysdig finds exception values that match one or more events from the same rule, the event details, in the Events feed or in Insights, show a Tunable Exceptions button. It’s not available for rule types that don’t support exceptions. To apply suggestions, you need permission to edit policies.

Each suggestion is based on an exception that the rule already declares. The exception defines the fields and operators, and Sysdig fills in the values it found in the events of that rule in the last 14 days. Suggestions are ordered by how many events they cover. You can edit the values before applying them, for example to replace prod-app-1 with prod to cover all production clusters.

When you apply a suggestion, the values are added to the rule as an append, with the author Secure UI. They take effect for every policy that includes the rule. You can also copy a suggestion as YAML or Terraform to manage it outside Sysdig.

For the steps, see Tunable Exceptions in the Events feed.

Choose Which Suggestions to Apply

You usually don’t need to apply every suggestion. The first suggestion targets the combination of the most events with the most specific set of fields and values, and generally includes the events of the other suggestions. If the number of events shown for each suggestion is the same, applying more than one probably duplicates exceptions.

Take, for example, the following suggestions for the rule Read sensitive file untrusted.

Both suggestions cover the same 708 events and the same processes: cat, httpd, and event-generator. The first suggestion, proc_file, stops the rule from triggering when these processes read exactly /etc/shadow. The second, proc_file_prefix, matches any file whose path starts with /etc/shadow, so it would also cover other files such as /etc/shadow-. Because both cover the same events, applying both duplicates the exceptions. Prefer the more specific suggestion, the first.

Auto-Tune

When auto-tune is enabled, Sysdig evaluates your policy events and adds exceptions to rules for the noisiest sets of events. It’s best used when you’re onboarding to Sysdig Secure in an environment with a lot of tooling, which can be flagged as nefarious despite being benign. A database backup tool, for example, can trigger rules that monitor for data exfiltration.

Many rules include exceptions out of the box, so you may not need auto-tune. Only users with the Admin role can use the actions on the Runtime Policy Tuning page.

Enable or Disable Auto-Tune

Auto-tune is enabled by default.

  1. Log in to Sysdig Secure as Admin and select Policies > Runtime Policy Tuning.

  2. Enable or disable the feature with the Auto Tuning toggle.

    It may take up to 24 hours for the first Applied Tuning Exceptions to appear on the left panel.

  3. Turn auto-tune off when it has addressed the most common or unnecessary events. In many cases, a week is enough, as most workloads will have taken the actions they require by then.

Turning auto-tune off doesn’t remove the exceptions it added, nor the ones you applied from event suggestions.

What Auto-Tune Does

Auto-tune runs about once an hour for your account and looks at the policy events from the previous hour. It tunes Linux workload and Kubernetes audit rules that already declare exceptions with several fields, such as proc.name and fd.filename, using the operators =, in, startswith, endswith, and contains.

It’s conservative: it only adds exceptions for commonly occurring events from a single rule with similar attributes. All the conditions must be met:

  • The rule generated more than 25 policy events in the past hour.
  • A candidate set of exception values applies to at least 25% of those events, or to at least 50 events.

For example, consider this rule, which declares the exception proc_writer:

- rule: Write below root
  desc: an attempt to write to any file directly below / or /root
  condition: root_dir and evt.dir = < and open_write
  exceptions:
    - name: proc_writer
      fields: [proc.name, fd.filename]

And a stream of events with outputs such as:

File below / or /root opened for writing (user=root user_loginuid=-1 command=/usr/local/bin/my-app-server parent=java file=/state.txt program=my-app-server container_id=a97d44bbe437 image=my-registry/app-server:latest)

Auto-tune adds the values that cover those events:

- rule: Write below root
  exceptions:
    - name: proc_writer
      values:
        - [my-app-server, /state.txt]
  append: true

When values are similar, for example commands or paths that share a long prefix, they are merged into a broader value. An exception holds up to 100 values. The exceptions are written to the tuner file shown in Applied Tuning Exceptions, and are sent to Host Shield together with the rules and policies.

Auto-tune only adds exception values. It doesn’t disable rules or change macros or lists.

For more background, see the Falco proposal on exceptions.

Review and Edit Auto-Tuned Exceptions

Auto-tune doesn’t ask for approval, so review its exceptions after the learning period:

  • On the Runtime Policy Tuning page: edit the Applied Tuning Exceptions file directly. Select Save to keep your changes, or Discard Changes to undo them. To start over, clear the text and re-enable the Auto Tuning toggle.

  • In the Rules Library: use the Modified filter to find the rules that have exceptions or appends, then open a rule. The exceptions added by auto-tune are shown as a separate block, authored by Tuner.