Skip to content

[Rule Tuning] Fix quoted KQL wildcards in four rules - #7216

Open
LiamCarPer wants to merge 1 commit into
elastic:mainfrom
LiamCarPer:fix/7214-kql-quoted-wildcards
Open

LiamCarPer wants to merge 1 commit into
elastic:mainfrom
LiamCarPer:fix/7214-kql-quoted-wildcards

Conversation

@LiamCarPer

@LiamCarPer LiamCarPer commented Nov 22, 2026 •

Copy link
Copy Markdown

Issue link(s): Fixes #7214

Summary - What I changed

KQL treats * inside double quotes as a literal character, so several prebuilt rule queries contained wildcard-looking values that could never match as patterns. This PR moves the wildcards outside the quoted values in the four affected rules:

  • rules/network/initial_access_splunk_postgres_recovery_body_injection.toml — unquotes the url.path recovery endpoint gate, the http.request.body.content filename/database markers, and the two status-400 url.path values. Embedded quotes are escaped as \".
  • rules/cross-platform/impact_destructive_aws_cli_execution_by_genai_agent.toml — unquotes the process.args --dry-run*, --help*, -help*, and --version* exclusions.
  • rules/cross-platform/discovery_cloud_offensive_framework_execution.toml — unquotes the *site-packages/pip* exclusion arm.
  • rules/windows/persistence_webshell_detection.toml — unquotes the WAMP Apache parent path, escaping the literal : as E\:/....

I also bumped updated_date to 2026/11/22 for each tuned rule and added TestKqlQuotedWildcards to tests/test_specific_rules.py, which asserts the corrected values parse as Wildcard AST nodes for the intended fields and that these rules contain no quoted values with *.

How To Test

$ source env/detection-rules-build/bin/activate
$ PYTHONPATH= python -m pytest tests/test_specific_rules.py::TestKqlQuotedWildcards -q
2 passed, 4 subtests passed in 234.94s

$ PYTHONPATH= python -m pytest tests/kuery -q
86 passed in 1.93s

$ PYTHONPATH= python -m detection_rules test
431 passed, 1 skipped, 416 subtests passed in 427.45s (0:07:07)

The PYTHONPATH= prefix only clears a local ROS pytest plugin that otherwise fails to load; it does not affect the repository code under test.

Checklist

  • Added a label for the type of pr: bug, enhancement, schema, maintenance, Rule: New, Rule: Deprecation, Rule: Tuning, Hunt: New, or Hunt: Tuning so guidelines can be generated — I could not apply labels from the fork (GitHub returns 403, maintainer/admin rights required); please add Rule: Tuning.
  • Added the meta:rapid-merge label if planning to merge within 24 hours
  • Secret and sensitive material has been managed correctly (no credentials or tokens; exclusions use generic non-identifying vendor/install paths — not usernames, hostnames, org names, cluster/agent IDs, IP addresses, or internal workspace/repo trees; cloud/SaaS rules only hard-code vendor first-party or marketplace-listed app/client IDs — never tenant, subscription, account, or project IDs; sample JSON is redacted)
  • Automated testing was updated or added to match the most common scenarios
  • Documentation and comments were added for features that require explanation

Contributor checklist

Unquote wildcard values in KQL queries so the patterns match as wildcards instead of literal asterisks, as reported in elastic#7214. Escape literal colons and embedded quotes where the values are now unquoted, and add regression tests asserting these values parse as Wildcard nodes.
@LiamCarPer
LiamCarPer marked this pull request as ready for review November 22, 2026 05:50
Copilot AI balanced review requested due to automatic review settings November 22, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Rule Tuning] KQL rules with quoted wildcards match only the literal string

2 participants