Skip to content

[windows] Defender - Fix pipeline for Path and add missing fields. #11529

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

Merged
merged 5 commits into from
Nov 20, 2024

Conversation

nicpenning
Copy link
Contributor

@nicpenning nicpenning commented Oct 27, 2024

It was reported in the community that the File Path will sometimes contain a process pid which is not currently processor correctly (see screenshots). This PR will resolve this issue and also add more fields that were missed in the last update.

I also added 2 more test documents to add the other potential data that would arrive.

Convo started here: https://elasticstack.slack.com/archives/C018PDGK6JU/p1729764392118379?thread_ts=1729593410.515049&cid=C018PDGK6JU

  • Bug

This will improve the integration further.

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

Screenshots

image
image

@nicpenning nicpenning marked this pull request as ready for review October 27, 2024 18:22
@nicpenning nicpenning requested review from a team as code owners October 27, 2024 18:22
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Agent Data Plane team [elastic/elastic-agent-data-plane] label Oct 28, 2024
@elasticmachine
Copy link

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@pierrehilbert pierrehilbert added the Team:Security-Windows Platform Security Windows Platform team [elastic/sec-windows-platform] label Oct 28, 2024
@elasticmachine
Copy link

Pinging @elastic/sec-windows-platform (Team:Security-Windows Platform)

@andrewkroh andrewkroh added bugfix Pull request that fixes a bug issue Integration:windows Windows labels Oct 28, 2024
@nicpenning
Copy link
Contributor Author

Came across another wrench in the pipeline. Sometimes the Path may contain multiple "Files".

Microsoft Defender Antivirus has detected malware or other potentially unwanted software.
 For more information please see the following:
https://go.microsoft.com/fwlink/?linkid=37020&name=TrojanSpy:MSIL/AgentTesla!MSR&threatid=2147753554&enterprise=1
 	Name: TrojanSpy:MSIL/AgentTesla!MSR
 	ID: 2147753554
 	Severity: Severe
 	Category: Trojan Monitoring Software
 	Path: file:_D:\autorun.inf\autorun.inf                                                                                                                                           .exe; file:_D:\autorun.inf\Protection for Autorun\Protection for Autorun                                                                                                                                .exe; file:_D:\ \                                                                                                                                                      .exe
 	Detection Origin: Local machine
 	Detection Type: Concrete
 	Detection Source: Real-Time Protection
 	User: YAMS\WIN1337
 	Process Name: C:\Windows\explorer.exe
 	Security intelligence Version: AV: 1.419.578.0, AS: 1.419.578.0, NIS: 1.419.578.0
 	Engine Version: AM: 1.1.24080.9, NIS: 1.1.24080.9

Not sure what the deal with the parsing is, but this is the raw JSON captured in Kibana. Maybe that is the actual file name. More research needed:

        "Path": "file:_D:\\autorun.inf\\autorun.inf                                                                                                                                           .exe; file:_D:\\autorun.inf\\Protection for Autorun\\Protection for Autorun                                                                                                                                .exe; file:_D:\\ \\                                                                                                                                                      .exe",

@pierrehilbert pierrehilbert requested review from leehinman and removed request for VihasMakwana October 29, 2024 08:29
@nicpenning
Copy link
Contributor Author

So this pipeline will still populate the first file.path found but won't include the others found.

How should this be handled if related.file.name does not seem to exist and file.name is supposed to be a keyword?

My thought is that I could have a custom field called windows_defender.files_detected and make it an array type.

Thoughts?

Otherwise, good to review and test.

@leehinman
Copy link
Contributor

So this pipeline will still populate the first file.path found but won't include the others found.

How should this be handled if related.file.name does not seem to exist and file.name is supposed to be a keyword?

My thought is that I could have a custom field called windows_defender.files_detected and make it an array type.

Thoughts?

Otherwise, good to review and test.

related.files might be a good approach. Similar to ECS related.ip or related.user. https://www.elastic.co/guide/en/ecs/current/ecs-related.html

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

LGTM so far. Will review again when an approach is decided on the multiple files issue.

@nicpenning
Copy link
Contributor Author

So this pipeline will still populate the first file.path found but won't include the others found.
How should this be handled if related.file.name does not seem to exist and file.name is supposed to be a keyword?
My thought is that I could have a custom field called windows_defender.files_detected and make it an array type.
Thoughts?
Otherwise, good to review and test.

related.files might be a good approach. Similar to ECS related.ip or related.user. https://www.elastic.co/guide/en/ecs/current/ecs-related.html

Would related.file.name actually work? I'm concerned this doesn't fit within the bounds of ECS since it's not called out in the reference. I would do that in a heart beat if related can be applied to any logical ECS field.

Thoughts?

@leehinman
Copy link
Contributor

So this pipeline will still populate the first file.path found but won't include the others found.
How should this be handled if related.file.name does not seem to exist and file.name is supposed to be a keyword?
My thought is that I could have a custom field called windows_defender.files_detected and make it an array type.
Thoughts?
Otherwise, good to review and test.

related.files might be a good approach. Similar to ECS related.ip or related.user. https://www.elastic.co/guide/en/ecs/current/ecs-related.html

Would related.file.name actually work? I'm concerned this doesn't fit within the bounds of ECS since it's not called out in the reference. I would do that in a heart beat if related can be applied to any logical ECS field.

Thoughts?

I was originally thinking a new field name, outside of ECS, but to use the related fields as inspiration. (Sorry I wasn't clear on that)

But maybe this is a useful enough construct that an rfc to add it would be a good idea?

@nicpenning
Copy link
Contributor Author

nicpenning commented Nov 4, 2024

Understood!

I will create a new field. Should I stick with winlog.*? Or should we think about moving to something more specific for the windows defender fields like I noted before: windows_defender.*

I could then migrate any others that were the generic winlog.eventdata and map to this new subfield.

Also, that RFC process looks pretty daunting at this time so I won't pursue that but I do think it is a good idea to include related.file.*

@nicpenning
Copy link
Contributor Author

Alright, I had to sync other changes to the integration and then use a new windows_defender field. Please review!

@nicpenning
Copy link
Contributor Author

Please test.

@jamiehynds
Copy link

@leehinman are you ok to continue with the review here, or prefer if @marc-gr takes over as it's security releated?

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

LGTM

@leehinman
Copy link
Contributor

@leehinman are you ok to continue with the review here, or prefer if @marc-gr takes over as it's security releated?

LGTM and approved but if @marc-gr could do a double check that would be good. I'm rusty when it comes to integrations :-)

@nicpenning
Copy link
Contributor Author

Hello, could we get some eyes on this again? Getting a bit stale :)

@marc-gr
Copy link
Contributor

marc-gr commented Nov 20, 2024

/test

Copy link

@elasticmachine
Copy link

💚 Build Succeeded

@marc-gr marc-gr merged commit 792f10a into elastic:main Nov 20, 2024
5 checks passed
@elastic-vault-github-plugin-prod

Package windows - 2.3.1 containing this change is available at https://epr.elastic.co/package/windows/2.3.1/

@nicpenning
Copy link
Contributor Author

Thank you!

qcorporation pushed a commit that referenced this pull request Feb 3, 2025
…11529)

* Fix pipeline for Path and add missing fields.

* change log PR update

* Add windows_defender.evidence paths for multiple hits, add anotehr test case, generate new expected and README
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
…lastic#11529)

* Fix pipeline for Path and add missing fields.

* change log PR update

* Add windows_defender.evidence paths for multiple hits, add anotehr test case, generate new expected and README
qcorporation pushed a commit that referenced this pull request Feb 4, 2025
…11529)

* Fix pipeline for Path and add missing fields.

* change log PR update

* Add windows_defender.evidence paths for multiple hits, add anotehr test case, generate new expected and README
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
…lastic#11529)

* Fix pipeline for Path and add missing fields.

* change log PR update

* Add windows_defender.evidence paths for multiple hits, add anotehr test case, generate new expected and README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Pull request that fixes a bug issue Integration:windows Windows Team:Elastic-Agent-Data-Plane Agent Data Plane team [elastic/elastic-agent-data-plane] Team:Security-Windows Platform Security Windows Platform team [elastic/sec-windows-platform]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants