Skip to content

Commit c21474b

Browse files
authored
[Security Solution][Detections] Change from sha1 to sha256 (#73741)
1 parent 70d4eac commit c21474b

File tree

6 files changed

+88
-27
lines changed

6 files changed

+88
-27
lines changed

x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { AddExceptionComments } from '../add_exception_comments';
4040
import {
4141
enrichNewExceptionItemsWithComments,
4242
enrichExceptionItemsWithOS,
43+
lowercaseHashValues,
4344
defaultEndpointExceptionItems,
4445
entryHasListType,
4546
entryHasNonEcsType,
@@ -256,7 +257,7 @@ export const AddExceptionModal = memo(function AddExceptionModal({
256257
: exceptionItemsToAdd;
257258
if (exceptionListType === 'endpoint') {
258259
const osTypes = retrieveAlertOsTypes();
259-
enriched = enrichExceptionItemsWithOS(enriched, osTypes);
260+
enriched = lowercaseHashValues(enrichExceptionItemsWithOS(enriched, osTypes));
260261
}
261262
return enriched;
262263
}, [comment, exceptionItemsToAdd, exceptionListType, retrieveAlertOsTypes]);

x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
getOperatingSystems,
4141
entryHasListType,
4242
entryHasNonEcsType,
43+
lowercaseHashValues,
4344
} from '../helpers';
4445
import { Loader } from '../../loader';
4546

@@ -195,7 +196,7 @@ export const EditExceptionModal = memo(function EditExceptionModal({
195196
];
196197
if (exceptionListType === 'endpoint') {
197198
const osTypes = exceptionItem._tags ? getOperatingSystems(exceptionItem._tags) : [];
198-
enriched = enrichExceptionItemsWithOS(enriched, osTypes);
199+
enriched = lowercaseHashValues(enrichExceptionItemsWithOS(enriched, osTypes));
199200
}
200201
return enriched;
201202
}, [exceptionItemsToAdd, exceptionItem, comment, exceptionListType]);

x-pack/plugins/security_solution/public/common/components/exceptions/exceptionable_fields.json

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,32 @@
66
"Target.process.Ext.code_signature.valid",
77
"Target.process.Ext.services",
88
"Target.process.Ext.user",
9-
"Target.process.command_line",
109
"Target.process.command_line.text",
11-
"Target.process.executable",
1210
"Target.process.executable.text",
1311
"Target.process.hash.md5",
1412
"Target.process.hash.sha1",
1513
"Target.process.hash.sha256",
1614
"Target.process.hash.sha512",
17-
"Target.process.name",
1815
"Target.process.name.text",
1916
"Target.process.parent.Ext.code_signature.status",
2017
"Target.process.parent.Ext.code_signature.subject_name",
2118
"Target.process.parent.Ext.code_signature.trusted",
2219
"Target.process.parent.Ext.code_signature.valid",
23-
"Target.process.parent.command_line",
2420
"Target.process.parent.command_line.text",
25-
"Target.process.parent.executable",
2621
"Target.process.parent.executable.text",
2722
"Target.process.parent.hash.md5",
2823
"Target.process.parent.hash.sha1",
2924
"Target.process.parent.hash.sha256",
3025
"Target.process.parent.hash.sha512",
31-
"Target.process.parent.name",
3226
"Target.process.parent.name.text",
3327
"Target.process.parent.pgid",
34-
"Target.process.parent.working_directory",
3528
"Target.process.parent.working_directory.text",
3629
"Target.process.pe.company",
3730
"Target.process.pe.description",
3831
"Target.process.pe.file_version",
3932
"Target.process.pe.original_file_name",
4033
"Target.process.pe.product",
4134
"Target.process.pgid",
42-
"Target.process.working_directory",
4335
"Target.process.working_directory.text",
4436
"agent.id",
4537
"agent.type",
@@ -74,15 +66,13 @@
7466
"file.mode",
7567
"file.name",
7668
"file.owner",
77-
"file.path",
7869
"file.path.text",
7970
"file.pe.company",
8071
"file.pe.description",
8172
"file.pe.file_version",
8273
"file.pe.original_file_name",
8374
"file.pe.product",
8475
"file.size",
85-
"file.target_path",
8676
"file.target_path.text",
8777
"file.type",
8878
"file.uid",
@@ -94,10 +84,8 @@
9484
"host.id",
9585
"host.os.Ext.variant",
9686
"host.os.family",
97-
"host.os.full",
9887
"host.os.full.text",
9988
"host.os.kernel",
100-
"host.os.name",
10189
"host.os.name.text",
10290
"host.os.platform",
10391
"host.os.version",
@@ -108,40 +96,36 @@
10896
"process.Ext.code_signature.valid",
10997
"process.Ext.services",
11098
"process.Ext.user",
111-
"process.command_line",
11299
"process.command_line.text",
113-
"process.executable",
114100
"process.executable.text",
115101
"process.hash.md5",
116102
"process.hash.sha1",
117103
"process.hash.sha256",
118104
"process.hash.sha512",
119-
"process.name",
120105
"process.name.text",
121106
"process.parent.Ext.code_signature.status",
122107
"process.parent.Ext.code_signature.subject_name",
123108
"process.parent.Ext.code_signature.trusted",
124109
"process.parent.Ext.code_signature.valid",
125-
"process.parent.command_line",
126110
"process.parent.command_line.text",
127-
"process.parent.executable",
128111
"process.parent.executable.text",
129112
"process.parent.hash.md5",
130113
"process.parent.hash.sha1",
131114
"process.parent.hash.sha256",
132115
"process.parent.hash.sha512",
133-
"process.parent.name",
134116
"process.parent.name.text",
135117
"process.parent.pgid",
136-
"process.parent.working_directory",
137118
"process.parent.working_directory.text",
138119
"process.pe.company",
139120
"process.pe.description",
140121
"process.pe.file_version",
141122
"process.pe.original_file_name",
142123
"process.pe.product",
143124
"process.pgid",
144-
"process.working_directory",
145125
"process.working_directory.text",
146-
"rule.uuid"
126+
"rule.uuid",
127+
"user.domain",
128+
"user.email",
129+
"user.hash",
130+
"user.id"
147131
]

x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
entryHasListType,
2525
entryHasNonEcsType,
2626
prepareExceptionItemsForBulkClose,
27+
lowercaseHashValues,
2728
} from './helpers';
2829
import { EmptyEntry } from './types';
2930
import {
@@ -663,4 +664,48 @@ describe('Exception helpers', () => {
663664
expect(result).toEqual(expected);
664665
});
665666
});
667+
668+
describe('#lowercaseHashValues', () => {
669+
test('it should return an empty array with an empty array', () => {
670+
const payload: ExceptionListItemSchema[] = [];
671+
const result = lowercaseHashValues(payload);
672+
expect(result).toEqual([]);
673+
});
674+
675+
test('it should return all list items with entry hashes lowercased', () => {
676+
const payload = [
677+
{
678+
...getExceptionListItemSchemaMock(),
679+
entries: [{ field: 'user.hash', type: 'match', value: 'DDDFFF' }] as EntriesArray,
680+
},
681+
{
682+
...getExceptionListItemSchemaMock(),
683+
entries: [{ field: 'user.hash', type: 'match', value: 'aaabbb' }] as EntriesArray,
684+
},
685+
{
686+
...getExceptionListItemSchemaMock(),
687+
entries: [
688+
{ field: 'user.hash', type: 'match_any', value: ['aaabbb', 'DDDFFF'] },
689+
] as EntriesArray,
690+
},
691+
];
692+
const result = lowercaseHashValues(payload);
693+
expect(result).toEqual([
694+
{
695+
...getExceptionListItemSchemaMock(),
696+
entries: [{ field: 'user.hash', type: 'match', value: 'dddfff' }] as EntriesArray,
697+
},
698+
{
699+
...getExceptionListItemSchemaMock(),
700+
entries: [{ field: 'user.hash', type: 'match', value: 'aaabbb' }] as EntriesArray,
701+
},
702+
{
703+
...getExceptionListItemSchemaMock(),
704+
entries: [
705+
{ field: 'user.hash', type: 'match_any', value: ['aaabbb', 'dddfff'] },
706+
] as EntriesArray,
707+
},
708+
]);
709+
});
710+
});
666711
});

x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,36 @@ export const enrichExceptionItemsWithOS = (
335335
});
336336
};
337337

338+
/**
339+
* Returns given exceptionItems with all hash-related entries lowercased
340+
*/
341+
export const lowercaseHashValues = (
342+
exceptionItems: Array<ExceptionListItemSchema | CreateExceptionListItemSchema>
343+
): Array<ExceptionListItemSchema | CreateExceptionListItemSchema> => {
344+
return exceptionItems.map((item) => {
345+
const newEntries = item.entries.map((itemEntry) => {
346+
if (itemEntry.field.includes('.hash')) {
347+
if (itemEntry.type === 'match') {
348+
return {
349+
...itemEntry,
350+
value: itemEntry.value.toLowerCase(),
351+
};
352+
} else if (itemEntry.type === 'match_any') {
353+
return {
354+
...itemEntry,
355+
value: itemEntry.value.map((val) => val.toLowerCase()),
356+
};
357+
}
358+
}
359+
return itemEntry;
360+
});
361+
return {
362+
...item,
363+
entries: newEntries,
364+
};
365+
});
366+
};
367+
338368
/**
339369
* Returns the value for the given fieldname within TimelineNonEcsData if it exists
340370
*/
@@ -413,7 +443,7 @@ export const defaultEndpointExceptionItems = (
413443
data: alertData,
414444
fieldName: 'file.Ext.code_signature.trusted',
415445
});
416-
const [sha1Hash] = getMappedNonEcsValue({ data: alertData, fieldName: 'file.hash.sha1' });
446+
const [sha256Hash] = getMappedNonEcsValue({ data: alertData, fieldName: 'file.hash.sha256' });
417447
const [eventCode] = getMappedNonEcsValue({ data: alertData, fieldName: 'event.code' });
418448
const namespaceType = 'agnostic';
419449

@@ -446,10 +476,10 @@ export const defaultEndpointExceptionItems = (
446476
value: filePath ?? '',
447477
},
448478
{
449-
field: 'file.hash.sha1',
479+
field: 'file.hash.sha256',
450480
operator: 'included',
451481
type: 'match',
452-
value: sha1Hash ?? '',
482+
value: sha256Hash ?? '',
453483
},
454484
{
455485
field: 'event.code',

x-pack/plugins/security_solution/public/detections/components/alerts_table/default_config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const requiredFieldsForActions = [
202202
'file.path',
203203
'file.Ext.code_signature.subject_name',
204204
'file.Ext.code_signature.trusted',
205-
'file.hash.sha1',
205+
'file.hash.sha256',
206206
'host.os.family',
207207
'event.code',
208208
];

0 commit comments

Comments
 (0)