Skip to content

Commit cf9ff4d

Browse files
Robert Austinnkhristininkibanamachine
authored
Asset criticality alert enrichment (#171241)
## Summary This will allow analysts to filter alerts by the analyst-defined criticality of the related host or user. This introduces two new kibana fields to alerts. These fields allow us to model the criticality of the alert's most relevant host and user, in context of analyst workflows. | field name | type | description | example | | -- | -- | -- | -- | | `kibana.alert.host.criticality_level` | keyword | Contains an enum describing the criticality of the host, as defined by the analyst in a previously used workflow. Used by analysts to filter alerts by host criticality. | 'very important' | | `kibana.alert.user.criticality_level` | keyword | Contains an enum describing the criticality of the user, as defined by the analyst in a previously used workflow. Used by analysts to filter alerts by user criticality. | 'very important' | ## Design Analysts can assign criticality to their assets. These are stored in the asset criticality index (`.asset-criticality.asset-criticality-${space}`). This PR will detect user names and host names in events, query the asset criticality index for the associated criticality (if any) and then add that value to the resulting alert under `kibana.alert.host.criticality_level` or `kibana.alert.user.criticality_level` ## Design Exploration ### What if we want to filter by other criticalities? We may want to allow analysts to filter on the criticality of other entities. For example, alerts can refer to multiple users and multiple hosts. Also, we may introduce other types of entities, e.g. IP addresses, files, registry keys. If we were to follow the same approach as we did here, that could lead to a mapping explosion if we had a lot. However: * we don't think we'll add very many classes of entities. less than 8 more. * we don't necessarily want to filter alerts by other ones. ### Using keyword vs nested or flattened We could use a flattened or nested field here to store more criticalities and have them all indexed. However we don't need to sort or order alerts by their entity's criticalities so we don't see a need. ### KQL support The fields we proposed here are of `keyword` type. This type of field works intuitively for KQL and since analyst workflows are the focus of this change, this lines up well. ## How to test until asset criticality UI is not enabled let's create a mapping for asset criticality and index some docs ``` PUT .asset-criticality.asset-criticality-default { "mappings": { "properties": { "id_value": { "type": "keyword" }, "id_field": { "type": "keyword" }, "criticality_level": { "type": "keyword" }, "@timestamp": { "type": "date" }, "updated_at": { "type": "date" } } } } ``` ``` POST .asset-criticality.asset-criticality-default/_doc { "id_field": "user.name", "id_value": "User 1", "criticality_level": "very important", "@timestamp": 1701860267617 } POST .asset-criticality.asset-criticality-default/_doc { "id_field": "host.name", "id_value": "Host 3", "criticality_level": "normal", "@timestamp": 1701860267617 } ``` Then create rules, which have alerts from events with `host.name` or `user.name` which match asset criticality documents. Then add fields to the alerts table, you should see some values in those columns <img width="1201" alt="Screenshot 2023-12-07 at 11 24 24" src="https://github.com/elastic/kibana/assets/7609147/fb8c07bf-4cc6-4273-95b0-34af9d3f2e72"> ### Checklist Delete any items that are not applicable to this PR. - [ ] 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/packages/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 - [ ] [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 - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] 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 renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes&mdash;Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Nikita Khristinin <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Khristinin Nikita <[email protected]>
1 parent b40cd02 commit cf9ff4d

File tree

32 files changed

+897
-108
lines changed

32 files changed

+897
-108
lines changed

packages/kbn-alerts-as-data-utils/src/schemas/generated/security_schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const SecurityAlertOptional = rt.partial({
131131
'kibana.alert.flapping_history': schemaBooleanArray,
132132
'kibana.alert.group.id': schemaString,
133133
'kibana.alert.group.index': schemaNumber,
134+
'kibana.alert.host.criticality_level': schemaString,
134135
'kibana.alert.last_detected': schemaDate,
135136
'kibana.alert.maintenance_window_ids': schemaStringArray,
136137
'kibana.alert.new_terms': schemaStringArray,
@@ -193,6 +194,7 @@ const SecurityAlertOptional = rt.partial({
193194
),
194195
'kibana.alert.time_range': schemaDateRange,
195196
'kibana.alert.url': schemaString,
197+
'kibana.alert.user.criticality_level': schemaString,
196198
'kibana.alert.workflow_assignee_ids': schemaStringArray,
197199
'kibana.alert.workflow_reason': schemaString,
198200
'kibana.alert.workflow_status': schemaString,
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { AlertWithCommonFields800 } from '@kbn/rule-registry-plugin/common/schemas/8.0.0';
9+
import type {
10+
ALERT_HOST_CRITICALITY,
11+
ALERT_USER_CRITICALITY,
12+
} from '../../../../../field_maps/field_names';
13+
import type {
14+
Ancestor8120,
15+
BaseFields8120,
16+
EqlBuildingBlockFields8120,
17+
EqlShellFields8120,
18+
NewTermsFields8120,
19+
} from '../8.12.0';
20+
21+
/* DO NOT MODIFY THIS SCHEMA TO ADD NEW FIELDS. These types represent the alerts that shipped in 8.13.0.
22+
Any changes to these types should be bug fixes so the types more accurately represent the alerts from 8.13.0.
23+
If you are adding new fields for a new release of Kibana, create a new sibling folder to this one
24+
for the version to be released and add the field(s) to the schema in that folder.
25+
Then, update `../index.ts` to import from the new folder that has the latest schemas, add the
26+
new schemas to the union of all alert schemas, and re-export the new schemas as the `*Latest` schemas.
27+
*/
28+
29+
export type { Ancestor8120 as Ancestor8130 };
30+
31+
export interface BaseFields8130 extends BaseFields8120 {
32+
[ALERT_HOST_CRITICALITY]: string | undefined;
33+
[ALERT_USER_CRITICALITY]: string | undefined;
34+
}
35+
36+
export interface WrappedFields8130<T extends BaseFields8130> {
37+
_id: string;
38+
_index: string;
39+
_source: T;
40+
}
41+
42+
export type GenericAlert8130 = AlertWithCommonFields800<BaseFields8130>;
43+
44+
export type EqlShellFields8130 = EqlShellFields8120 & BaseFields8130;
45+
46+
export type EqlBuildingBlockFields8130 = EqlBuildingBlockFields8120 & BaseFields8130;
47+
48+
export type NewTermsFields8130 = NewTermsFields8120 & BaseFields8130;
49+
50+
export type NewTermsAlert8130 = NewTermsFields8120 & BaseFields8130;
51+
52+
export type EqlBuildingBlockAlert8130 = AlertWithCommonFields800<EqlBuildingBlockFields8120>;
53+
54+
export type EqlShellAlert8130 = AlertWithCommonFields800<EqlShellFields8130>;
55+
56+
export type DetectionAlert8130 =
57+
| GenericAlert8130
58+
| EqlShellAlert8130
59+
| EqlBuildingBlockAlert8130
60+
| NewTermsAlert8130;

x-pack/plugins/security_solution/common/api/detection_engine/model/alerts/index.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ import type { DetectionAlert860 } from './8.6.0';
1212
import type { DetectionAlert870 } from './8.7.0';
1313
import type { DetectionAlert880 } from './8.8.0';
1414
import type { DetectionAlert890 } from './8.9.0';
15+
import type { DetectionAlert8120 } from './8.12.0';
1516
import type {
16-
Ancestor8120,
17-
BaseFields8120,
18-
DetectionAlert8120,
19-
EqlBuildingBlockFields8120,
20-
EqlShellFields8120,
21-
NewTermsFields8120,
22-
WrappedFields8120,
23-
} from './8.12.0';
17+
Ancestor8130,
18+
BaseFields8130,
19+
DetectionAlert8130,
20+
EqlBuildingBlockFields8130,
21+
EqlShellFields8130,
22+
NewTermsFields8130,
23+
WrappedFields8130,
24+
} from './8.13.0';
2425

2526
// When new Alert schemas are created for new Kibana versions, add the DetectionAlert type from the new version
2627
// here, e.g. `export type DetectionAlert = DetectionAlert800 | DetectionAlert820` if a new schema is created in 8.2.0
@@ -31,14 +32,15 @@ export type DetectionAlert =
3132
| DetectionAlert870
3233
| DetectionAlert880
3334
| DetectionAlert890
34-
| DetectionAlert8120;
35+
| DetectionAlert8120
36+
| DetectionAlert8130;
3537

3638
export type {
37-
Ancestor8120 as AncestorLatest,
38-
BaseFields8120 as BaseFieldsLatest,
39-
DetectionAlert8120 as DetectionAlertLatest,
40-
WrappedFields8120 as WrappedFieldsLatest,
41-
EqlBuildingBlockFields8120 as EqlBuildingBlockFieldsLatest,
42-
EqlShellFields8120 as EqlShellFieldsLatest,
43-
NewTermsFields8120 as NewTermsFieldsLatest,
39+
Ancestor8130 as AncestorLatest,
40+
BaseFields8130 as BaseFieldsLatest,
41+
DetectionAlert8130 as DetectionAlertLatest,
42+
WrappedFields8130 as WrappedFieldsLatest,
43+
EqlBuildingBlockFields8130 as EqlBuildingBlockFieldsLatest,
44+
EqlShellFields8130 as EqlShellFieldsLatest,
45+
NewTermsFields8130 as NewTermsFieldsLatest,
4446
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { alertsFieldMap840 } from '../8.4.0';
9+
import { ALERT_HOST_CRITICALITY, ALERT_USER_CRITICALITY } from '../field_names';
10+
11+
export const alertsFieldMap8130 = {
12+
...alertsFieldMap840,
13+
/**
14+
* Stores the criticality level for the host, as determined by analysts, in relation to the alert.
15+
* The Criticality level is copied from the asset criticality index.
16+
*/
17+
[ALERT_HOST_CRITICALITY]: {
18+
type: 'keyword',
19+
array: false,
20+
required: false,
21+
},
22+
/**
23+
* Stores the criticality level for the user, as determined by analysts, in relation to the alert.
24+
* The Criticality level is copied from the asset criticality index.
25+
*/
26+
[ALERT_USER_CRITICALITY]: {
27+
type: 'keyword',
28+
array: false,
29+
required: false,
30+
},
31+
} as const;
32+
33+
export type AlertsFieldMap8130 = typeof alertsFieldMap8130;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { AlertsFieldMap8130 } from './alerts';
9+
import { alertsFieldMap8130 } from './alerts';
10+
export type { AlertsFieldMap8130 };
11+
export { alertsFieldMap8130 };

x-pack/plugins/security_solution/common/field_maps/field_names.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const ALERT_THRESHOLD_RESULT = `${ALERT_NAMESPACE}.threshold_result` as c
1717
export const ALERT_THRESHOLD_RESULT_COUNT = `${ALERT_THRESHOLD_RESULT}.count` as const;
1818
export const ALERT_NEW_TERMS = `${ALERT_NAMESPACE}.new_terms` as const;
1919
export const ALERT_NEW_TERMS_FIELDS = `${ALERT_RULE_PARAMETERS}.new_terms_fields` as const;
20+
export const ALERT_HOST_CRITICALITY = `${ALERT_NAMESPACE}.host.criticality_level` as const;
21+
export const ALERT_USER_CRITICALITY = `${ALERT_NAMESPACE}.user.criticality_level` as const;
2022

2123
export const ALERT_ORIGINAL_EVENT = `${ALERT_NAMESPACE}.original_event` as const;
2224
export const ALERT_ORIGINAL_EVENT_ACTION = `${ALERT_ORIGINAL_EVENT}.action` as const;

x-pack/plugins/security_solution/common/field_maps/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* 2.0.
66
*/
77

8-
import type { AlertsFieldMap840 } from './8.4.0';
9-
import { alertsFieldMap840 } from './8.4.0';
8+
import type { AlertsFieldMap8130 } from './8.13.0';
9+
import { alertsFieldMap8130 } from './8.13.0';
1010
import type { RulesFieldMap } from './8.0.0/rules';
1111
import { rulesFieldMap } from './8.0.0/rules';
12-
export type { AlertsFieldMap840 as AlertsFieldMap, RulesFieldMap };
13-
export { alertsFieldMap840 as alertsFieldMap, rulesFieldMap };
12+
export type { AlertsFieldMap8130 as AlertsFieldMap, RulesFieldMap };
13+
export { alertsFieldMap8130 as alertsFieldMap, rulesFieldMap };

x-pack/plugins/security_solution/public/detections/configurations/security_solution_detections/columns.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
*/
77

88
import type { EuiDataGridColumn } from '@elastic/eui';
9+
import {
10+
ALERT_HOST_CRITICALITY,
11+
ALERT_USER_CRITICALITY,
12+
} from '../../../../common/field_maps/field_names';
913
import type { LicenseService } from '../../../../common/license';
1014
import type { ColumnHeaderOptions } from '../../../../common/types';
1115

@@ -72,6 +76,18 @@ const getBaseColumns = (
7276
id: 'user.risk.calculated_level',
7377
}
7478
: null,
79+
isPlatinumPlus
80+
? {
81+
columnHeaderType: defaultColumnHeaderType,
82+
id: ALERT_HOST_CRITICALITY,
83+
}
84+
: null,
85+
isPlatinumPlus
86+
? {
87+
columnHeaderType: defaultColumnHeaderType,
88+
id: ALERT_USER_CRITICALITY,
89+
}
90+
: null,
7591
{
7692
columnHeaderType: defaultColumnHeaderType,
7793
id: 'process.name',

x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/factories/utils/build_alert.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ import {
8080
ALERT_RULE_THREAT,
8181
ALERT_RULE_EXCEPTIONS_LIST,
8282
ALERT_RULE_IMMUTABLE,
83+
ALERT_HOST_CRITICALITY,
84+
ALERT_USER_CRITICALITY,
8385
} from '../../../../../../common/field_maps/field_names';
8486
import type { CompleteRule, RuleParams } from '../../../rule_schema';
8587
import { commonParamsCamelToSnake, typeSpecificCamelToSnake } from '../../../rule_management';
@@ -256,6 +258,9 @@ export const buildAlert = (
256258
'kibana.alert.rule.risk_score': params.riskScore,
257259
'kibana.alert.rule.severity': params.severity,
258260
'kibana.alert.rule.building_block_type': params.buildingBlockType,
261+
// asset criticality fields will be enriched before ingestion
262+
[ALERT_HOST_CRITICALITY]: undefined,
263+
[ALERT_USER_CRITICALITY]: undefined,
259264
};
260265
};
261266

x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/utils/enrichments/__mocks__/alerts.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ import {
6868
ALERT_RULE_TIMELINE_TITLE,
6969
ALERT_RULE_INDICES,
7070
ALERT_RULE_TIMESTAMP_OVERRIDE,
71+
ALERT_HOST_CRITICALITY,
72+
ALERT_USER_CRITICALITY,
7173
} from '../../../../../../../common/field_maps/field_names';
7274

7375
export const createAlert = (
@@ -194,6 +196,8 @@ export const createAlert = (
194196
rule_name_override: undefined,
195197
timestamp_override: undefined,
196198
},
199+
[ALERT_HOST_CRITICALITY]: undefined,
200+
[ALERT_USER_CRITICALITY]: undefined,
197201
...data,
198202
},
199203
});

0 commit comments

Comments
 (0)