Detection Rules
The built-in detection rules, and how to clone them or write your own.
A detection rule counts matching events in one source over a window, per group, and raises a signal for each group that reaches its threshold. For example: in Traces, where the response code is 401 or 403, count events per source IP and service; at least 30 in 5 minutes raises a High signal.
Open Security → Signals, then the Detection rules tab. The list shows each rule's condition and filters, severity, source, when its signals end, and whether it is built in or custom. The switch turns a rule on or off.
Built-in Rules
| Rule | Reads | Raises a signal when | Severity |
|---|---|---|---|
| Scanner probe answered with success | Scanner probes | A service answered a scanner path with 2xx (1 or more distinct paths per source IP and service in 10 minutes). A single-page app that answers every path with its index page does this too: suppress that service. | High |
| Authentication brute force | Traces | 30 or more 401/403 answers per source IP and service in 5 minutes | High |
| Aggressive scanner | Scanner probes | One source IP probed 50 or more distinct paths in 10 minutes | Medium |
| Scanner sweeping services | Scanner probes | One source IP probed 3 or more services in 30 minutes | Medium |
| Debug or server-info endpoint probed | Scanner probes | Any probe for a framework debug console or a server-info page (/server-status, /actuator/env, …), per source IP and service, in 10 minutes | Medium |
| Secret file or source control probed | Scanner probes | Any probe for secret files or source control metadata (/.env, /.aws/credentials, /.git/config), per source IP and service, in 10 minutes | Low |
| Repeated authentication failures in logs | Logs | A service logged 20 or more authentication failures ("authentication failed", "invalid password", "login failed", "invalid credentials") in 5 minutes | Medium |
| Credential stuffing | Traces | 20 or more different source IPs got 401/403 answers from one service's sign-in endpoints (a route ending in login, log-in, signin, sign_in, sign-in, authenticate, or token at the root or after an auth segment or a version, such as /oauth/token or /oauth2/v1/token, but not /users/me/token; also as login.php and the like, or wp-login.php, j_security_check, NextAuth's callback/credentials) in 10 minutes: a login attack spread over many addresses. Routes that answer 401 to anyone signed out, such as /auth/me or /token/refresh, don't count. A 400 doesn't count either: an OAuth token endpoint answers a wrong password with 400 (invalid_grant), but it answers an expired refresh token the same way, and a span doesn't say which grant it carried. | Medium |
| Attack tool user agent | Traces | Any request from a tool made for attacking web apps (sqlmap, nikto, nuclei, wpscan, ffuf, …), per source IP and service, in 10 minutes | Medium |
| Attack payload in a request | Traces | Any request whose URL carries an attack payload, per source IP and service, in 10 minutes (see below) | Low |
| Attack payload not rejected | Traces | The same, answered 2xx or 5xx rather than refused. A 2xx may mean the payload worked; a 5xx that it broke the code it reached. A page that echoes any query, such as a search page, answers 2xx too: suppress that service. | Medium |
| SQL syntax errors in logs | Logs | A service logged 10 or more SQL syntax errors in 10 minutes (MySQL, PostgreSQL, SQL Server, Oracle and SQLite messages). An injected quote breaks an app's queries, so an injection attempt shows up as a burst of these; so does a bug in a query. | Medium |
| Attack payload in logs | Logs | A service logged a Log4Shell lookup (${jndi:), a request for /etc/passwd (after ../, or as a query parameter's value) or a PHP pearcmd inclusion, as sent or URL-encoded: usually a request line the app logged. A bare /etc/passwd, as security agents and entrypoints log it, doesn't count. | Low |
A service in these rules is one service in one domain and namespace: a same-named service in another namespace or domain is counted on its own, with its own signal.
Attack payloads
The two payload rules read the request's URL, decoded twice so a payload matches however it was encoded, and only for HTTP (with or without TLS). They never see the body. The query string is there when the tracer keeps it: the eBPF sensor does (a very long URL is cut at its capture size), while OpenTelemetry instrumentations that report a route (http.route) send the path alone. A 4xx request that KubeSense recognizes as a scanner probe is counted by the scanner rules instead. The rules look for:
| Attack | For example |
|---|---|
| SQL injection | UNION SELECT (also with comments or brackets), ' OR '1'='1, admin'--, sleep(5), information_schema |
| Cross-site scripting | <script>, a tag with an event handler (<img onerror=…>), a javascript: URL that calls something |
| Path traversal and file inclusion | ../../../, ../../etc/ (also proc, windows, boot, WEB-INF), ..;/, /etc/passwd, php://, file:// |
| Command injection | ;cat /etc/hosts, $(whoami), &&id, /bin/sh |
| Template and Log4Shell injection | ${jndi:, ${::-j}, {{7*7}} |
| Server-side request forgery | 169.254.169.254, also written as one number (decimal, hex or octal), dotted octal or hex, a short form (169.254.43518) or IPv4-mapped IPv6; AWS's fd00:ec2::254 and instance-data, ECS's 169.254.170.2, metadata.google.internal, gopher:// |
Ordinary URLs are left alone: a relative ../ or two (../../home/), a matrix parameter (;id=42), a list (fields=name|id), a | or a line break in search text (dogs|cat food), a < in a filter (where=a<b) or javascript:void(0). The attack tool rule needs the request's user agent on the span: OpenTelemetry and Datadog tracing record it when the app's instrumentation does.
Built-in rules are read-only, as in Datadog: you can switch one off, or Clone it into a custom rule and change the copy. An upgrade may tune a built-in rule; a rule you switched off stays off.
Custom Rules
Click New rule, or Clone on any rule. A custom rule can be edited and deleted from its row's menu.
| Field | What it sets |
|---|---|
| Name, Description | How the rule is listed, and what it detects and what to do about it |
| Reads | The source: Scanner probes, Traces or Logs |
| Where | Conditions on the source's rows, all of which must hold (none: every row). Up to 20. |
| Count | Events, or Distinct values of a field (for example distinct paths) |
| Per | The fields that make a group: one signal per distinct set of their values, such as one per source IP and service. 1 to 5 fields. |
| At least, In | The threshold, and the window it is counted over (5 minutes to 1 day) |
| Severity | Critical, High, Medium, Low or Info |
| Ends after no events for, Or at most after | When its signals end — see below |
| Title | The signal's title. {{field}} is the group's value of a Per field, by its key (see below), and {{value}} the count, for example {{source_ip}} got {{value}} errors from {{service}}. Empty: the rule's name. |
| Enabled | A disabled rule raises no signals; its signals stay |
Fields
| Source | Fields |
|---|---|
| Scanner probes | Source IP, Service, Domain, Namespace, Signature, Path, Response code, Method, User agent, Server |
| Traces | Source IP, Service, Domain, Namespace, Response code, Endpoint, URL, Raw URL, User agent, Protocol |
| Logs | Service, Domain, Namespace, Host, Level, Body |
In a title, use a field's key: source_ip, service, cluster (Domain), namespace, signature, path, return_code, method, http_user_agent (User agent), server, endpoint, url, url_raw (Raw URL), protocol_type (Protocol), host, level or body.
Endpoint is the route with its ids folded (/users/{id}); URL is the request as sent, with its query string when the tracer keeps it, decoded; Raw URL is the same before decoding (%3Cscript%3E as such). Only HTTP spans have them.
Conditions are checked in the order you list them where ClickHouse can: put cheap ones (Protocol, Response code) before a regular expression on URL or Body, so most spans skip the expensive check.
Operators
| Operator | Matches |
|---|---|
| is / is not | Any of the values exactly |
| matches / does not match | A regular expression |
| starts with | Any of the prefixes |
| has the word | Text fields only (Body, Path, User agent, Endpoint, URL, Raw URL, Server): any of the words, as a whole word |
Type a value and press Enter to add it. A comma also separates values, except in a regular expression, which may contain one.
When Signals End
| Setting | Default | Range |
|---|---|---|
| Ends after no events for | 1 hour, or the rule's window if longer | At least the rule's window, at most 1 day |
| Or at most after | 1 day | At least the first setting, at most 7 days |
After either, the group's next breach raises a new signal. These are Datadog's keep alive and maximum signal duration.
Changing a custom rule's source or Per fields ends its open signals: no breach can reach their groups again. An upgrade that regroups a built-in rule (one you haven't cloned) ends its open signals the same way.
Limits
- A rule raises at most 200 signals per evaluation.
- Groups with an unknown source IP are left out of rules that group by source IP.