Commit 613f82f
[Security Solution][Detection Engine] Adding validations for escaped wildcards on the match operator on rules exceptions (elastic#268397)
## Summary
Closes
[security-team#17120](elastic/security-team#17120).
When a user creates a rule exception with the `matches` operator and
types a value containing escaped wildcard metacharacters (`\*`, `\?`),
the UI saves silently. Under the hood, the Detection Engine passes the
value verbatim to an Elasticsearch `wildcard` query where `\` is the
escape character, so `\*` matches a literal asterisk, killing the
wildcard semantics the user expected from `matches`. The exception then
doesn't behave as intended.
This PR extends the existing wildcard-warning machinery (originally
added in elastic#182903 for the wrong-operator case) with a second signal that
fires when a `matches` entry contains a lone escaped metacharacter.
## Examples
### Valid usage of matches + `*` wildcard
<img width="1089" height="894" alt="Screenshot 2026-05-19 at 11 44 01"
src="https://github.com/user-attachments/assets/ec9e449b-333e-4bc7-868e-236571abfcc4"
/>
### Invalid usage of matches + `\*` escaped wildcard
<img width="1475" height="1009" alt="Screenshot 2026-05-19 at 10 55 55"
src="https://github.com/user-attachments/assets/926babf9-f393-4b0b-ae24-391088e1107f"
/>
### Invalid usage of matches + `\?` escaped wildcard
<img width="1476" height="1011" alt="Screenshot 2026-05-19 at 10 56 33"
src="https://github.com/user-attachments/assets/39a62fef-1b6e-4058-b9d2-82009c444a95"
/>
### Alert dialog before saving rule exception
<img width="1474" height="1014" alt="Screenshot 2026-05-19 at 10 56 54"
src="https://github.com/user-attachments/assets/a293383a-6441-4c90-b698-f1349fcfd0c8"
/>
### Supports multiple validation warnings
<img width="1475" height="1011" alt="Screenshot 2026-05-19 at 10 56 43"
src="https://github.com/user-attachments/assets/b8c5b4f6-9a73-4378-89b5-85e9d908b941"
/>
### Validation on Edti
<img width="1476" height="1008" alt="Screenshot 2026-05-19 at 11 44 38"
src="https://github.com/user-attachments/assets/976697ef-178f-4614-a0e1-69412d964cf3"
/>
### Backslashes handling are ignored
<img width="1068" height="468" alt="Screenshot 2026-05-18 at 17 12 10"
src="https://github.com/user-attachments/assets/c063fd00-089d-4ea2-8af8-2c2804d28fce"
/>
### Changes
**`@kbn/securitysolution-list-utils`**
- `hasMalformedMatchesValue(items): boolean` — validator using
negative-lookbehind regex `/(?<!\\)\\[*?]/`. Fires on lone `\*` / `\?`;
deliberately does NOT fire on `\\*` (documented Windows-path pattern,
e.g. `C:\\Windows\\*.dll`).
- `getMalformedMatchesFields(items): string[]` — companion function
returning the field name of each affected entry, used to generate
per-entry modal warnings.
**`@kbn/securitysolution-exception-list-components`**
- `<MalformedMatchesValueCallout />` — aggregate callout explaining that
escape sequences match literal characters and suggesting `is` for exact
matching.
**Both add and edit flyouts (`add_exception_flyout`,
`edit_exception_flyout`)**
- `malformedMatchesValueExists: boolean` reducer flag — submit gate: `if
(wildcardWarningExists || malformedMatchesValueExists)` shows the
confirm modal.
- `malformedMatchesFields: string[]` reducer field — list of affected
entry field names, passed to the modal to produce one warning item per
affected entry.
- Non-blocking: the modal lets the user confirm and save proceeds
unchanged.
- Applies to both create and edit flows.
**`ArtifactConfirmModal` / `CONFIRM_WARNING_MODAL_LABELS`** (shared with
endpoint track, elastic#268477)
- Added `hasMalformedMatchesValue?: string[]` to the warnings object.
When multiple AND/OR conditions each contain an escape issue, the modal
shows one warning item per affected field, leveraging the
`listOfWarnings: Array<React.ReactNode>` array introduced by elastic#268477.
**Tests**
- Unit tests in
`kbn-securitysolution-list-utils/src/helpers/index.test.ts` covering:
escaped `\*` / `\?`, documented Windows paths (negative — must not
trigger), single-backslash paths (positive), `match` entries (negative —
only `wildcard` type checked), empty entries, OR conditions, and
multiple AND entries producing per-field results.
### Exception filter behavior across rule types
Traced the full backend execution path to confirm that wildcard
exception entries (`matches` operator, `type: "wildcard"`) behave
identically across all rule types.
**Central path:**
`create_security_rule_type_wrapper.ts` builds the exception filter once
via `buildExceptionFilter()` (from `@kbn/lists-plugin`) and passes it to
every rule executor through `sharedParams.exceptionFilter`. The
resulting ES clause is:
```json
{ "wildcard": { "<field>": "<value>" } }
```
> ES|QL note:
> ES|QL uses esClient.esql.asyncQuery() instead of _search, which accepts a separate filter parameter (standard ES DSL). The exception filter is passed there unchanged; Elasticsearch applies it at the shard level before the ES|QL query runs. No translation to a WHERE clause is performed or needed.
So, the Elasticsearch wildcard semantics apply uniformly across all rule types (query, EQL, ES|QL, threshold, new terms, ML, indicator match, saved query):
- \* matches a literal asterisk, not a wildcard
- \? matches a literal question mark, not a wildcard
- \\ matches a literal backslash
### Out of scope (and maybe for a follow-up)
- For bare `*` / `?` values in `matches` (e.g., a value of just `*` matching everything) we could handle it by a separate validator with its own callout copy. The AC mentions this as a separate signal.
- Lone `\` (single backslash) and unpaired `\\` cases, could also be on a separate validator.
### Checklist
- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials -- Already in place, under: https://www.elastic.co/docs/solutions/security/detect-and-alert/add-manage-exceptions#detection-rule-exceptions
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these
situations.
- [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
- [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
### Identify risks
- [x] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
| Risk | Severity | Mitigation |
|---|---|---|
| **False positives on documented Windows paths** (e.g. `C:\\Windows\\*.dll`) | Medium → Low | Negative-lookbehind regex `(?<!\\)\\[*?]` only flags `\` immediately before `*`/`?` when not itself preceded by `\`. Test coverage explicitly asserts the documented Windows-path pattern does not trigger. |
| **Per-entry modal warnings on large exception items** | Low | `malformedMatchesFields` is bounded by the number of entries the user has added in the flyout — not a pagination or unbounded list concern. |
| **Co-firing with existing `wildcardWarningExists` callout** | Low | Both are non-blocking, use the same modal gate, and render as separate list items in the modal's `listOfWarnings`. UX copy sign-off with @approksiu recommended before marking ready for review. |
| **Behavioral change to save flow** | None | Validator only adds a confirmation step; on confirm, save proceeds via the unchanged `submitException()` path. No data shape changes. |
## Release note
Adds a warning callout and confirmation modal to the rule exceptions form when a user enters escaped characters (e.g. `\*` or `\?`) with the matches operator, indicating they may have intended wildcards instead. The warning is non-blocking, users can acknowledge and save.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>1 parent c12ca27 commit 613f82f
11 files changed
Lines changed: 391 additions & 43 deletions
File tree
- x-pack/solutions/security
- packages
- kbn-securitysolution-exception-list-components
- src/malformed_matches_value_callout
- kbn-securitysolution-list-utils/src/helpers
- plugins/security_solution/public
- detection_engine/rule_exceptions/components
- add_exception_flyout
- edit_exception_flyout
- management/components/artifact_list_page/components
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
Lines changed: 183 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
646 | 829 | | |
647 | 830 | | |
648 | 831 | | |
| |||
Lines changed: 45 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1030 | 1046 | | |
1031 | 1047 | | |
1032 | 1048 | | |
1033 | 1049 | | |
1034 | 1050 | | |
1035 | | - | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
1049 | 1054 | | |
1050 | 1055 | | |
1051 | 1056 | | |
1052 | 1057 | | |
1053 | 1058 | | |
| 1059 | + | |
1054 | 1060 | | |
1055 | | - | |
1056 | 1061 | | |
1057 | 1062 | | |
1058 | 1063 | | |
1059 | 1064 | | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
1064 | | - | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
| 1065 | + | |
| 1066 | + | |
1073 | 1067 | | |
1074 | 1068 | | |
1075 | 1069 | | |
| |||
1104 | 1098 | | |
1105 | 1099 | | |
1106 | 1100 | | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1107 | 1124 | | |
1108 | 1125 | | |
1109 | 1126 | | |
| |||
0 commit comments