x-pack/filebeat/module/threatintel/malwarebazaar: properly handle code_sign array - #31552
Conversation
…e_sign array Previously, the code_sign field was treated as a keyword which broke handling of the structured data in the code signing details. The handling of the code signing also incorrectly assumed that only a single value could be present (in reality, this is the case for all examples in the malwarebazaar data set, but may not be in the future) by using rename rather than appending the details to the relevant x509 fields. This change maps the code_sign field as a nested field and appends into the x509 fields.
|
Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
| "sha256WithRSAEncryption" | ||
| ], | ||
| "threat.indicator.file.x509.serial_number": [ | ||
| "", |
There was a problem hiding this comment.
The cause of this empty string is here to test that the processor handles the unlikely cases where the code signing is missing fields. I attempted to conditionally not append when _ingest?._value?.<fieldname> != "" but this invariably broke the pipeline with timeouts (using a variety of candidate syntaxes).
There was a problem hiding this comment.
Unfortunately, it's not possible to access _ingest._value inside a condition as it is not visible to painless.
The only alternative I can suggest is to use a script processor to split the array of objects into separate array fields. But if we're not expecting missing fields then the current approach is good
There was a problem hiding this comment.
For illustrative purposes:
- script:
lang: painless
if: 'ctx.abusech?.malwarebazaar?.code_sign != null'
source: |
Map dest = new HashMap();
for (def obj : ctx.abusech.malwarebazaar.code_sign) {
for (def entry : obj.entrySet()) {
dest.computeIfAbsent(entry.getKey(), k -> new ArrayList()).add(entry.getValue());
}
}
ctx["_temp_"] = dest;
- rename:
field: _temp_.subject_cn
target_field: threat.indicator.file.x509.subject.common_name
ignore_missing: true
- rename:
field: _temp_.issuer_cn
target_field: threat.indicator.file.x509.issuer.common_name
ignore_missing: true
- rename:
field: _temp_.algorithm
target_field: threat.indicator.file.x509.public_key_algorithm
ignore_missing: true
- rename:
field: _temp_.valid_from
target_field: threat.indicator.file.x509.not_before
ignore_missing: true
- rename:
field: _temp_.valid_to
target_field: threat.indicator.file.x509.not_after
ignore_missing: true
- rename:
field: _temp_.serial_number
target_field: threat.indicator.file.x509.serial_number
ignore_missing: true
There was a problem hiding this comment.
Thanks. We can revisit this if we find that empty fields ever find their way into the code_sign array.
…e_sign array (#31552) Previously, the code_sign field was treated as a keyword which broke handling of the structured data in the code signing details. The handling of the code signing also incorrectly assumed that only a single value could be present (in reality, this is the case for all examples in the malwarebazaar data set, but may not be in the future) by using rename rather than appending the details to the relevant x509 fields. This change maps the code_sign field as a nested field and appends into the x509 fields. (cherry picked from commit ee5da02) # Conflicts: # x-pack/filebeat/module/threatintel/fields.go # x-pack/filebeat/module/threatintel/malwarebazaar/ingest/pipeline.yml # x-pack/filebeat/module/threatintel/malwarebazaar/test/malwarebazaar.ndjson.log-expected.json
…e_sign array (#31552) Previously, the code_sign field was treated as a keyword which broke handling of the structured data in the code signing details. The handling of the code signing also incorrectly assumed that only a single value could be present (in reality, this is the case for all examples in the malwarebazaar data set, but may not be in the future) by using rename rather than appending the details to the relevant x509 fields. This change maps the code_sign field as a nested field and appends into the x509 fields. (cherry picked from commit ee5da02)
…e_sign array (#31552) (#31598) Previously, the code_sign field was treated as a keyword which broke handling of the structured data in the code signing details. The handling of the code signing also incorrectly assumed that only a single value could be present (in reality, this is the case for all examples in the malwarebazaar data set, but may not be in the future) by using rename rather than appending the details to the relevant x509 fields. This change maps the code_sign field as a nested field and appends into the x509 fields. (cherry picked from commit ee5da02) Co-authored-by: Dan Kortschak <90160302+efd6@users.noreply.github.com>
…e_sign array (#31552) Previously, the code_sign field was treated as a keyword which broke handling of the structured data in the code signing details. The handling of the code signing also incorrectly assumed that only a single value could be present (in reality, this is the case for all examples in the malwarebazaar data set, but may not be in the future) by using rename rather than appending the details to the relevant x509 fields. This change maps the code_sign field as a nested field and appends into the x509 fields. (cherry picked from commit ee5da02) # Conflicts: # x-pack/filebeat/module/threatintel/fields.go # x-pack/filebeat/module/threatintel/malwarebazaar/ingest/pipeline.yml # x-pack/filebeat/module/threatintel/malwarebazaar/test/malwarebazaar.ndjson.log-expected.json
…e_sign array (#31552) Previously, the code_sign field was treated as a keyword which broke handling of the structured data in the code signing details. The handling of the code signing also incorrectly assumed that only a single value could be present (in reality, this is the case for all examples in the malwarebazaar data set, but may not be in the future) by using rename rather than appending the details to the relevant x509 fields. This change maps the code_sign field as a nested field and appends into the x509 fields.
What does this PR do?
Previously, the code_sign field was treated as a keyword which broke handling of
the structured data in the code signing details. The handling of the code signing
also incorrectly assumed that only a single value could be present (in reality,
this is the case for all examples in the malwarebazaar data set, but may not be
in the future) by using rename rather than appending the details to the relevant
x509 fields. This change maps the code_sign field as a nested field and appends
into the x509 fields.
Why is it important?
Previously data in the code_sign field would prevent documents from being processed.
Checklist
I have commented my code, particularly in hard-to-understand areasI have made corresponding change to the default configuration filesCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs