Skip to content

Updates to the ProblemChild and DGA integration packages - #3777

Merged
ajosh0504 merged 15 commits into
mainfrom
problemchild_dga_update
Aug 10, 2022
Merged

Updates to the ProblemChild and DGA integration packages#3777
ajosh0504 merged 15 commits into
mainfrom
problemchild_dga_update

Conversation

@ajosh0504

@ajosh0504 ajosh0504 commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Fixes some bugs in/arising from the ProblemChild and DGA integrations packages.
  • Some changes to improve discoverability of rules associated with the two packages.

Changes made:

  • ProblemChild integration package
    • Fix a script that was causing the inference pipeline to fail
    • Added additional tags to rules associated with the integration package for easy discoverability
    • Updated the query and influencers in problemchild-ml.json
    • Updated all rule versions to 2 since this is an actual update to the rules (there were some rules which started with a version 2, but we can probably disregard that since this is still an experimental package)
  • DGA integration package
    • Fixed a rule that was pointing to a non-existent ML job
    • Added additional tags to rules associated with the integration package for easy discoverability
    • Corrected the n-gram feature creation in dga_inference_pipeline script.
    • Updated all rule versions to 2 since this is an actual update to the rules (there were some rules which started with a version 2, but we can probably disregard that since this is still an experimental package)

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Related issues

@ajosh0504 ajosh0504 added the bug Something isn't working, use only for issues label Jul 20, 2022
@ajosh0504
ajosh0504 requested a review from mtojek July 20, 2022 21:58
@ajosh0504
ajosh0504 requested a review from a team as a code owner July 20, 2022 21:58
@elasticmachine

elasticmachine commented Jul 20, 2022

Copy link
Copy Markdown

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-08-10T21:28:35.803+0000

  • Duration: 16 min 37 sec

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.
@ajosh0504

ajosh0504 commented Jul 20, 2022

Copy link
Copy Markdown
Contributor Author

@mtojek Does this update to the packages count as a new version or the same? I was hoping for this to be a sort of bug fix PR for the existing packages.

P.S. I just noticed that some of the rules in the initial packages have some version 2s- maybe we want to reset those to 1? I can take care of that in this PR too- not sure if this breaks stuff for users who have the packages currently installed? Then again we're calling these packages "experimental" so might be better to focus on fixing things regardless, for now.

@brokensound77 Any thoughts on this^

@mtojek mtojek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please check to make sure the structure of the data_stream directory in both the packages looks correct

Please make sure that CI passes for this PR. CI uses elastic-package tool to validate against the package-spec.

Is a manifest.yml file in the data_stream/predictions directory mandatory?

Manifest describes the data stream and if you want to have data stream it's mandatory. I see that you don't have much experience with package development, so you may find this blog post helpful.

What should it contain?

As I replied to you over Slack, the content is defined by package-spec. Any property that is "legal", must be defined by spec.

Since I am adding new index mappings to the packages, is there anything else required other than this integrations PR?

I don't know, not sure what are you trying to achieve. You've implemented an incomplete data stream - just added a few fields, and modified ingest pipeline and security rules. Please sync with @alvarezmelissa87 who has already successfully contributed to Integrations.

Does this update to the packages count as a new version or the same? I was hoping for this to be a sort of bug fix PR for the existing packages.

If you want to release those changes, you need to bump up the version and add a corresponding changelog entry. There is a background job set to determine if the package version has been updated and if so, it syncs changes with Package Storage.

@ajosh0504

ajosh0504 commented Jul 21, 2022

Copy link
Copy Markdown
Contributor Author

@mtojek Thanks for the detailed response. Looks like CI is indeed failing on the missing manifests now.

I was reading your blog post but looks like the example you walk through is for a new integration, creating a new data stream. I'm working with an existing package and existing data streams, specifically the logs-* , winlogbeat-* and endgame-* data streams, based on which indices the user wants to run the ingest pipeline (defined in the top-level elasticsearch folder) on. It seems to me then that I should have the ability to define an index template asset in the top-level elasticsearch folder as well but that doesn't seem to be supported by package-spec yet.

Eitherway, I'll follow-up with @alvarezmelissa87 and see where we end up on this. Thanks!

@ajosh0504
ajosh0504 requested a review from andrewkroh July 29, 2022 14:31
@ajosh0504

Copy link
Copy Markdown
Contributor Author

Tested the packages with elastic-package to make sure that the bug fixes worked.

@ajosh0504 ajosh0504 changed the title [DRAFT] Updates to the ProblemChild and DGA integration packages Aug 2, 2022
Comment thread packages/dga/changelog.yml Outdated
if (ctx.containsKey('process') && ctx['process'].containsKey('Ext') && ctx['process']['Ext'].containsKey('code_signature') && ctx['process']['Ext']['code_signature'].containsKey('exists')) {
ctx.feature_process_signed = ctx['process']['Ext']['code_signature']['exists']
} else if (ctx.containsKey('process') && ctx['process'].containsKey('code_signature') && ctx['process']['code_signature'].containsKey('exists')) {
if (ctx.containsKey('process') && ctx['process'].containsKey('code_signature') && ctx['process']['code_signature'].containsKey('exists')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can safely be expressed as ctx.process?.code_signature?.exists != null using the null-safe operator.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could cover this in a follow-up PR, since this PR only deals with bug fixes?

Comment thread packages/problemchild/changelog.yml Outdated
"minimum_should_match": 1,
"should": [
{
"bool": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you explain why this filter isn't needed anymore?

@ajosh0504 ajosh0504 Aug 2, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The original query basically translated to checking whether the fields ["process.name", "host.hostname", "process.command_line"] were present OR if the problemchild.prediction_probability field was present.

This is not what we want to check for, I don't think. We want to check if the events being passed to the anomaly detection jobs either have a problemchild. prediction or a blocklist_label, which is what I changed the query to.

As an aside, I also cross-checked with DGA, and the query there seems to match what's in the datafeeds as well, which is basically what I've done.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is that not what the query should reflect?

@alvarezmelissa87

Copy link
Copy Markdown
Contributor

Overall LGTM. Re: the questions in the description - I don't see any data_stream changes in this PR so maybe these comments are out of date?

@ajosh0504

Copy link
Copy Markdown
Contributor Author

Overall LGTM. Re: the questions in the description - I don't see any data_stream changes in this PR so maybe these comments are out of date?

Right, updated the description.

@ajosh0504

ajosh0504 commented Aug 2, 2022

Copy link
Copy Markdown
Contributor Author

@alvarezmelissa87 Here's screenshots to prove that things are working as expected:

DGA

  • Making sure that the right version is being used for testing:

Screen Shot 2022-08-02 at 3 18 04 PM

  • This job was previously referring to the ML job experimental-high-sum-dga-probability which did not exist. Removed reference to that job and updated the rule with the correct name:

Screen Shot 2022-08-02 at 3 14 32 PM

  • DGA tag allows filtering on all DGA-related rules

Screen Shot 2022-08-02 at 3 14 05 PM

ProblemChild

  • Making sure that the right version is being used for testing:

Screen Shot 2022-08-02 at 3 26 36 PM

  • Predictions were previously not coming through due to a bug in the inference pipeline. Seeing predictions on Windows process events now:

Screen Shot 2022-08-02 at 3 11 11 PM

  • Anomaly Detection job datafeed was previously failing to start due to mapping errors. Added mappings to the component template (confirmed with @andrewkroh that this is the way to add custom mappings to existing datafeeds) and not seeing that error anymore. The warning you see here is because I don't have any malicious data on my cluster and the job only runs on malicious data:

Screen Shot 2022-08-02 at 3 21 11 PM

Screen Shot 2022-08-02 at 3 15 05 PM

  • LotL tag allows filtering for rules related to the LotL Attack Detection package:

Screen Shot 2022-08-02 at 3 11 55 PM

@alvarezmelissa87 alvarezmelissa87 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM ⚡

"DGA",
"ML",
"Supervised",
"Anomalies"

@szeitlin szeitlin Aug 9, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how is Anomalies meant to be used? Seems kinda generic?
same for ML vs. Supervised - are these intended for internal use, or to be exposed to the customer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We want to expose Anomalies vs Advanced Threats in the centralized Entity Analytics page. Anomalies would be things flagged as suspicious by individual ML jobs. Advanced Threats are things flagged as suspicious by more than one method.

For example, in ProblemChild, suspicious events are identified by a supervised model and an anomaly detection job.

ML is a generic tag for all ML jobs in the Security solution. Supervised vs Unsupervised is based on which model contributed to the event being flagged as anomalous. Now that I think about it, this might be too much information for the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This helps a lot, thank you!

I think maybe it would help to write this up in a separate doc (since it might be hard to track back to this ticket later)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok, discussed with Sourin and put a couple comments in the spreadsheet, but the short version is that as far as the product is concerned, we only need 3 kinds of tags:

  1. package tags - what rules and dashboards are tied to a package
  2. threat category (internal vs. external threat) for future product features
  3. entity tag (user vs. host)

For the others, if we want internal tags for our own tracking/packaging/debugging/support purposes, that's good to know, just want to make sure we're keeping an eye on that as we along, so we don't end up with a proliferation of unused/overlapping/incorrect tag tech debt like we have on the malware pipelines.

"ML",
"DGA"
"Unsupervised",
"Advanced Threats"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what constitutes an Advanced Threat? Do we have a list of what's included in those? (also, why am I having deja vu as I write this?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refer to the comment above.

@ajosh0504
ajosh0504 merged commit 8898ca0 into main Aug 10, 2022
orestisfl pushed a commit to orestisfl/integrations that referenced this pull request May 15, 2026
* Fixing some bugs, adding mappings, tags etc.

* Updating version numbers

* Revert "Updating version numbers"

This reverts commit 9b74911.

* Formatting yml files

* Updating changelog and version

* Update ml_dga_inference_pipeline.yml

* Updated the problemchild query

* Deleting data_stream folder since it's not necessary

* Updating rule numbers

* Updating changelog with specifics of what bugs were fixed

* Updating detector descriptions and changelog

* formatting changelog

* Adding better tags to rules, influencers where necessary

* Finalizing rule tags

* Adding missing influencers

Co-authored-by: Wei Wang <47184485+wwang500@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working, use only for issues

7 participants