Capsule8 Docs
Capsule8 Docs

Creating Custom Policies

Capsule8 policies may be created ‘from scratch’, allowing experts to craft their polcies as they see fit. However creation of custom policies require expert knowledge of Capsule8 Protect, linux systems, and linux security. Capsule8 has created a ‘Capsule8 Strategy Guide’ which is a reference for access to the ‘atomic’ elements that Capsule8 calls strategies. Please contact your Capsule8 technical representative for a copy.

Policies can be configured based on your environment and risk profile. You can change the policy’s rules to precisely specify what events trigger alerts by customizing the type of action and event fields, with the ability to define lists for even greater control. Each policy’s generated alert output is also configurable, as is the ability to enable automated responses to take specific action upon detection.

Configuring Policy Rules

To begin, start by selecting what type of policy you want to configure. We recommend exploring policies by Capsule8 category or MITRE ATT&CK category to determine what behavior you want to monitor at which point of the attack lifecycle.

Rule Actions

Once you’ve selected your policy type, the next step is to determine whether you prefer to default match or default ignore. You must specify a default action before adding custom rules:

action description
default match Operates as an allowlist. The policy will alert on all events that meet the behavior criteria, unless the event satisfied a previous ignore rule.
default ignore Operates as a blocklist. The policy will not alert on any events that meet the behavior criteria, unless the event satisfied a previous match rule.

Custom rules begin with either the match or ignore keyword, followed by predicates combined with event fields. A policy may have any number of match or ignore rules. If a policy has multiple rules, all rules are evaluated in order beginning from the top of the list.

Event Fields

Each policy has its own set of valid event fields, which can include metadata related to containers, images, programs, ports, files, users, groups, and more. When deciding which event fields to include from the policy’s range of valid event fields, we recommend starting with basic “known good” or “known bad” resources so you can become more familiar with configuration.

For instance, if you know that your developers frequently spawn interactive shells using the program ssh as part of their work, you should use the parentProgramName == "ssh" event field plus the ignore action to ensure alerts aren’t generated by your developers’ legitimate behaviors.


Let’s walk through the configuration of a Program Execution Policy to see rule creation in practice. We will start with the following policy configuration, which will alert on any program executing.

Program Execution Policy Example:
  policy: program
  enabled: true
  alertMessage: Unauthorized Program Executed
  comments: Example using the program policy
  priority: High
    - default match

Let’s say we want to only receive alerts on programs named, regardless of filepath. We would modify the rules to specify that we want to filter programName for, and to ignore any programs that don’t match that filter:

    - match programName == ""
    - default ignore

However, let’s say we now want to restrict alerts to only trigger when is run from the /tmp/ directory. We would modify our rules to include the path as well:

    - match programName == "/tmp/"
    - default ignore

Now, we decide we want to alert on any execution that contains the argument “malicious,” as well (in case of not-so-sneaky attackers). We can use the programArguments event field to indicate we want to see any arguments containing *malicious*.

	- match programArguments like ".*malicious.*"
    - match programName == "/tmp/"
    - default ignore

Finally, we realize that we also want to ignore any execution that originates from a bash shell, perhaps because we know that there is legitimate bash shell usage within our environment. We can create an ignore rule, using the parentProgramName event field and specifying bash:

    - ignore parentProgramName == "bash"
    - match programArguments like ".*malicious.*"
    - match programName == "/tmp/" and programArguments == "/tmp/ arg1 arg2"
    - default ignore

If we execute ls malicious within a bash shell, an alert will not be generated. However, if we switched the order of the first two rules, an alert would be generated if we executed ls malicious from within a bash shell, as it would match on the programArguments rule before the ignore bash rule was applied.


Policy rules can use lists for even more control over when and how alerts should be fired. Lists are particularly useful for configuring policies to block or allow certain behavior. Capsule8 supports four data types for lists: names, hosts, paths, and numbers (along with an experimental lineage type).


Each policy’s generated alerts can be configured using alert templates to contain specific or custom information. For teams with established processes, alert customization helps you receive precisely the data needed to conduct your triage and investigations.

Automated Responses

Each policy can be configured to trigger automated responses upon alert. Valid automated response actions include stopping a process, killing a process, killing a container, quarantining a file, and deleting a file. We recommend enabling dry runs to gain confidence in your policy’s automated responses before enabling actions to be taken on your systems.