Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2026/09/14"
integration = ["endpoint"]
maturity = "production"
updated_date = "2026/10/08"
updated_date = "2026/11/22"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -139,7 +139,7 @@ event.category : "process" and event.type : "start" and event.action:(start or e
) and not process.command_line : (
*pip install* or *pip3 install* or *pipx install* or *uv pip install* or *uv tool install* or
*go get* or *go install* or *go build* or *go test* or *npm install* or *--help* or *--version* or
*git clone* or *pytest* or "*site-packages/pip*"
*git clone* or *pytest* or *site-packages/pip*
) and not process.parent.name : (dpkg or rpm or apt or yum or dnf or brew or pip or pip3)
'''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2026/09/14"
integration = ["endpoint"]
maturity = "production"
updated_date = "2026/10/23"
updated_date = "2026/11/22"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -172,7 +172,7 @@ event.category : "process" and event.type : "start" and event.action : (start or
process.name : (kubectl or kubectl.exe) and
process.command_line : (*delete*--all* or *delete namespace* or *delete ns*)
)
) and not process.args : ("--dry-run*" or "--help*" or "-help*" or "-h" or "help" or "--version*")
) and not process.args : (--dry-run* or --help* or -help* or -h or help or --version*)
'''

[[rule.threat]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2026/06/15"
integration = ["endpoint", "network_traffic", "zeek", "suricata", "azure", "gcp"]
maturity = "production"
updated_date = "2026/09/18"
updated_date = "2026/11/22"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -171,36 +171,36 @@ type = "query"

query = '''
http.request.method:POST and
url.path:("*splunkd/__raw/v1/postgres/recovery/*" or "/v1/postgres/recovery/*") and
url.path:(*splunkd/__raw/v1/postgres/recovery/* or /v1/postgres/recovery/*) and
(
http.request.body.content:(
"*\"backupFile\"*../*" or
"*\"backupFile\"*/dev/shm/*" or
"*\"backupFile\"*/etc/cron*" or
"*\"backupFile\"*/home/*/.ssh/*" or
"*\"backupFile\"*/opt/splunk/bin/scripts/*" or
"*\"backupFile\"*/opt/splunk/etc/apps/*" or
"*\"backupFile\"*/root/*" or
"*\"backupFile\"*/tmp/*" or
"*\"backupFile\"*/var/tmp/*" or
"*\"backupFile\"*authorized_keys*" or
"*\"database\"*dbname=*" or
"*\"database\"*host=*" or
"*\"database\"*hostaddr=*" or
"*\"database\"*passfile=*" or
"*\"database\"*password=*" or
"*\"database\"*port=*" or
"*\"database\"*service=*" or
"*\"database\"*sslmode=*" or
"*\"database\"*user=*" or
"*/opt/splunk/etc/apps/*" or
"*/opt/splunk/var/packages/data/postgres/.pgpass*"
*\"backupFile\"*../* or
*\"backupFile\"*/dev/shm/* or
*\"backupFile\"*/etc/cron* or
*\"backupFile\"*/home/*/.ssh/* or
*\"backupFile\"*/opt/splunk/bin/scripts/* or
*\"backupFile\"*/opt/splunk/etc/apps/* or
*\"backupFile\"*/root/* or
*\"backupFile\"*/tmp/* or
*\"backupFile\"*/var/tmp/* or
*\"backupFile\"*authorized_keys* or
*\"database\"*dbname=* or
*\"database\"*host=* or
*\"database\"*hostaddr=* or
*\"database\"*passfile=* or
*\"database\"*password=* or
*\"database\"*port=* or
*\"database\"*service=* or
*\"database\"*sslmode=* or
*\"database\"*user=* or
*/opt/splunk/etc/apps/* or
*/opt/splunk/var/packages/data/postgres/.pgpass*
) or
data_stream.dataset:zeek.http and url.password:"" or
data_stream.dataset:(azure.application_gateway or gcp.loadbalancing_logs or network_traffic.http or suricata.eve or zeek.http) and
url.path:(
"*splunkd/__raw/v1/postgres/recovery/backup" or
"*splunkd/__raw/v1/postgres/recovery/restore" or
*splunkd/__raw/v1/postgres/recovery/backup or
*splunkd/__raw/v1/postgres/recovery/restore or
/v1/postgres/recovery/backup or
/v1/postgres/recovery/restore
) and
Expand Down
4 changes: 2 additions & 2 deletions rules/windows/persistence_webshell_detection.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2021/08/24"
integration = ["endpoint", "windows", "system", "sentinel_one_cloud_funnel", "m365_defender", "crowdstrike"]
maturity = "production"
updated_date = "2026/10/23"
updated_date = "2026/11/22"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -182,7 +182,7 @@ process.parent.name: (

(process.name:cmd.exe and process.args:("/V:ON" and "--header-html")) or

(process.parent.args :"E:/wamp64/bin/apache/apache*" and process.args:node*) or
(process.parent.args :E\:/wamp64/bin/apache/apache* and process.args:node*) or

(process.parent.name:"php.exe" and process.name:"cmd.exe" and process.args:("/V:ON" and "/E:ON"))
)
Expand Down
74 changes: 74 additions & 0 deletions tests/test_specific_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import unittest
from copy import deepcopy
from typing import ClassVar

import eql.ast
import kql
Expand Down Expand Up @@ -184,6 +185,79 @@ def test_new_terms_fields_unique(self):
)


class TestKqlQuotedWildcards(BaseRuleTest):
"""Regression tests for KQL values with wildcards that must not be quoted (issue #7214)."""

# rule id -> field -> wildcard values that must parse as wildcards rather than literal strings
EXPECTED_WILDCARDS: ClassVar[dict[str, dict[str, set[str]]]] = {
"2a7823db-0bc2-48f6-aa2f-e6aef233c6dc": {
"url.path": {
"*splunkd/__raw/v1/postgres/recovery/*",
"/v1/postgres/recovery/*",
"*splunkd/__raw/v1/postgres/recovery/backup",
"*splunkd/__raw/v1/postgres/recovery/restore",
},
"http.request.body.content": {
'*"backupFile"*../*',
'*"database"*dbname=*',
"*/opt/splunk/var/packages/data/postgres/.pgpass*",
},
},
"2635d2ba-51e7-404a-9b17-db413a1351d5": {
"process.args": {"--dry-run*", "--help*", "-help*", "--version*"},
},
"77c476eb-6a49-402a-a561-267ae66daa5e": {
"process.command_line": {"*site-packages/pip*"},
},
"2917d495-59bd-4250-b395-c29409b76086": {
"process.parent.args": {"E:/wamp64/bin/apache/apache*"},
},
}

@staticmethod
def walk_ast(node):
"""Yield every KQL AST node reachable from node."""
yield node
slots = {slot for cls in type(node).__mro__ for slot in getattr(cls, "__slots__", ())}
for slot in slots:
child = getattr(node, slot, None)
if isinstance(child, kql.ast.KqlNode):
yield from TestKqlQuotedWildcards.walk_ast(child)
elif isinstance(child, list):
for item in child:
if isinstance(item, kql.ast.KqlNode):
yield from TestKqlQuotedWildcards.walk_ast(item)

def test_wildcard_values_parse_as_wildcards(self):
"""Assert that the tuned values are parsed as wildcard nodes for their fields."""
rules = {rule.id: rule for rule in self.all_rules}
for rule_id, expected_fields in self.EXPECTED_WILDCARDS.items():
with self.subTest(rule_id=rule_id):
self.assertIn(rule_id, rules, f"rule {rule_id} not found")
parsed = {}
for node in self.walk_ast(rules[rule_id].contents.data.ast):
if isinstance(node, kql.ast.FieldComparison):
wildcards = {
child.value for child in self.walk_ast(node.value) if isinstance(child, kql.ast.Wildcard)
}
parsed.setdefault(str(node.field), set()).update(wildcards)
for field, expected in expected_fields.items():
missing = expected - parsed.get(field, set())
self.assertFalse(missing, f"{rule_id}: {field} is missing wildcard values {sorted(missing)}")

def test_no_quoted_wildcards(self):
"""Assert that the tuned rules have no quoted values containing a literal wildcard."""
for rule in self.all_rules:
if rule.id not in self.EXPECTED_WILDCARDS:
continue
quoted = [
node.value
for node in self.walk_ast(rule.contents.data.ast)
if isinstance(node, kql.ast.String) and "*" in node.value
]
self.assertEqual(quoted, [], f"{self.rule_str(rule)} has quoted wildcard values: {quoted}")


class TestESQLRules(BaseRuleTest):
"""Test ESQL Rules."""

Expand Down