Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Rule] Threat intel indicator match rule #1133

Merged
merged 16 commits into from
Apr 26, 2021
Merged

[New Rule] Threat intel indicator match rule #1133

merged 16 commits into from
Apr 26, 2021

Conversation

peasead
Copy link
Contributor

@peasead peasead commented Apr 20, 2021

Issues

Resolves #1065
Resolves https://github.com/elastic/protections-team/issues/368

Summary

This adds an Indicator Match rule for the Detection Engine. The indicators are provided by the Threat Intel Filebeat module from the following sources:

  • Abuse Malware
  • Abuse URL
  • Anomali Limo
  • AlienVault OTX
  • Malware Bazaar
  • MISP

Of note, currently, the Indicator Match rule type isn't in the detection_rules module, so this rule was exported from the Detection Engine and converted to TOML manually. This will likely need some massaging to pass unit tests.

Contributor checklist

@brokensound77
Copy link
Collaborator

brokensound77 commented Apr 21, 2021

👋

Some other dependencies before this will pass

A separate PR will be added for CLI support of the rule type

brokensound77 and others added 6 commits April 22, 2021 12:49
Co-authored-by: Ross Wolf <31489089+rw-access@users.noreply.github.com>
Co-authored-by: Ross Wolf <31489089+rw-access@users.noreply.github.com>
Co-authored-by: Ross Wolf <31489089+rw-access@users.noreply.github.com>
@brokensound77 brokensound77 changed the title [New Rule] Add Indicator Match Rule [New Rule] Threat intel indicator match rule Apr 22, 2021
"""


[[rule.threat_filters]]
Copy link
Collaborator

@brokensound77 brokensound77 Apr 22, 2021

Choose a reason for hiding this comment

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

I had to manually lint/format this @rw-access . There appears to be an issue with the MarshmallowDataclassMixin.to_dict method on schema.dump, but I think it is only happening on threat_match rules, so it may not be rendering the schema properly. As of now, it strips a lot of fields

@@ -174,6 +174,9 @@ def get_beats_sub_schema(schema: dict, beat: str, module: str, *datasets: str):
dataset_dir = module_dir.get("folders", {}).get(dataset, {})
flattened.extend(get_field_schema(dataset_dir, prefix=module + ".", include_common=True))

# we also need to capture (beta?) fields which are directly within the module _meta.files.fields
flattened.extend(get_field_schema(module_dir, include_common=True))
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... is this the right call?
IIRC, this blew up the schema significantly before and added more fields that shouldn't be there.
do you have a sense what new fields and how many were added?

Copy link
Collaborator

Choose a reason for hiding this comment

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

not for every module, but threatintel.indicator* (and some other threatintel.* specifically was entirely embedded under this. Not sure if this is actually where beta fields are stuffed, but it seems consistent. Without it, validation will fail on threatintel.indicator*

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, i'm following that this is the only way for this rule to be validated.
we should double check the impact on the schema and validation in general. i think for other beats and modules, this brings in more fields than is correct

Copy link
Collaborator

@brokensound77 brokensound77 Apr 22, 2021

Choose a reason for hiding this comment

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

Here is a full dump of what's included per beats/module in the base directory only:

beats-module-base-fields.txt

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

tags = ["Elastic", "Windows", "Elastic Endgame", "Network", "Continuous Monitoring", "SecOps", "Monitoring"]
type = "threat_match"

threat_index = [ "filebeat-*"]
Copy link
Contributor

Choose a reason for hiding this comment

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

it's kinda too bad that this all get flattened, but that's more of a kibana API thing
i think it would be nicer if the fields were all namespaced by type instead of jammed together

detection_rules/main.py Outdated Show resolved Hide resolved
brokensound77 and others added 2 commits April 22, 2021 17:23
Co-authored-by: Ross Wolf <31489089+rw-access@users.noreply.github.com>
Copy link
Collaborator

@brokensound77 brokensound77 left a comment

Choose a reason for hiding this comment

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

Successfully exported and imported into Kibana
image

If all of the rule data looks accurate to you @peasead, then LGTM to merge 👍

@peasead
Copy link
Contributor Author

peasead commented Apr 22, 2021

Solid.

The indicator match timeline template should be in 7.13, would that be a timeline UUID I could add now?

@brokensound77
Copy link
Collaborator

Solid.

The indicator match timeline template should be in 7.13, would that be a timeline UUID I could add now?

yep, just find the guid and timeline title (and test 🙂 )

@brokensound77 brokensound77 added the v7.13.0 7.13 rules release package label Apr 23, 2021
@peasead
Copy link
Contributor Author

peasead commented Apr 23, 2021

@brokensound77
Copy link
Collaborator

add this to the rule and upload it to a stack that has that template

timeline_id = "495ad7a7-316e-4544-8a0f-9c098daee76e"
timeline_title = "Generic Threat Match Timeline"

Unit tests/validation may need to be updated to pass

@brokensound77
Copy link
Collaborator

92562bc

FYSA @rw-access in a separate PR we can start removing irrelevant tests and moving others to within the marshmallow schema validation under TOMLRuleContents.

peasead and others added 2 commits April 23, 2021 18:02
Co-authored-by: Justin Ibarra <brokensound77@users.noreply.github.com>
@peasead peasead merged commit 92eaa5b into main Apr 26, 2021
@peasead peasead deleted the issue-1065 branch April 26, 2021 12:07
austinsonger added a commit to austinsonger/detection-rules that referenced this pull request Apr 26, 2021
[New Rule] Threat intel indicator match rule (elastic#1133)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Endpoint Domain: Network OS: Linux OS: macOS OS: Windows windows related rules Rule: New Proposal for new rule v7.13.0 7.13 rules release package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Rule] Threat Intel Filebeat Module Indicator Match
3 participants