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

[7.17][Security Solution][Endpoint] Fix artifact path file name checking utility #131085

Conversation

paul-tavares
Copy link
Contributor

Summary

  • Fixes a bug in the RegExp of the hasSimpleExecutableName() utility that was causing an infinite loop when used from Artifact Manifest manager and in turn preventing access to the entire Kibana system.

About the bug:

With long paths defined with the matches operator defined for a Trusted App, BUT having no wildcards in the path, the artifact builder task does not complete and causes a Kibana TLS handshake timeout.

Checklist

@paul-tavares paul-tavares added release_note:fix Team:Defend Workflows “EDR Workflows” sub-team of Security Solution OLM Sprint v7.17.4 labels Apr 27, 2022
@paul-tavares paul-tavares self-assigned this Apr 27, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt)

return false;
}

return /[\*\?]/.test(lastString) === false;
Copy link
Member

Choose a reason for hiding this comment

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

This can also be return !/[\*\?]/.test(lastString), but I think the current one reads better.

return false;
}

return /[\*\?]/.test(lastString) === false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use https://github.com/uhop/node-re2 here instead of the built-in RegExp library to further protect ourselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @kobelb - thanks for the comment. The change here (almost all of it) is actually a copy of the code in main - we had already altered this method in main for 8.2 and we know it works. Do you know if node-re2 can be used both in browser and server side? this utility method is used in both.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kobelb - we removed the RegEx here entirely for this 7.17.4 patch which goes out soon. We'll look into node-re2 when we've got a bit more time.

Related change: 0dc084b

value: 'c:\\folder\\one.exe',
})
).toEqual(true);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test case with a very large path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I forgot about that. I'll add one next.

Copy link
Contributor

@dasansol92 dasansol92 left a comment

Choose a reason for hiding this comment

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

Would like to see how it looks with the re2 package suggested but other than that it LGTM!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 4.6MB 4.6MB -12.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @paul-tavares

@kevinlog
Copy link
Contributor

kevinlog commented Apr 27, 2022

Checked it out and tried it.

Added several long paths with and without * with the MATCHES operator and all worked as expected.

Ex:

  • C:\ProgramData\Package Cache\sdfsds\Installers\WimMountAdkSetupAmd64.exe
  • C:\ProgramData\Package Cache\fefeef\Installers\asdasd\asdasdasd\asdasdasd\asdasdasdds\sdsds\dssd\sd\ad\dcsdsas\ds\a\sd\sasd\asdasdas\asdas\sdsdsdsd\sdsdssdsd\sd\wswswsws\asdas\asdasda\sd\WimMountAdkSetupAmd64.exe
  • C:\ProgramData\Package Cache\dwdwdw\Installers\asdasd\asdasdasd\asdasdasd\asdasdasdds\sdsds\dssd\sd\ad\dcsdsas\ds\a\sd\sasd\asdasdas\asdas\sdsdsdsd\sdsdssdsd\sd\wswswsws\asdas\asdasda\sd\*\asdasdasdas\asda\dsasd\sasdas\asda\asda\asd\asdasdasdas\asdasdas\dsdsdsd\wwsws\dsaw\dsaw\dswdwd\asdw\asdw\asdw\asd\sx\s\dw\asdwasdw\sdsdawdsdwd\asdwdasdws\s\wdasdw\sdsawedasd\wasdw\asdw\asd\wad\wasd\wdwddwdwd\asd\asd\wdsa\wdasdsdwasd\dwasdwdasdw\asdwasdawdas\wdasdwasdw\WimMountAdkSetupAmd64.exe
  • C:\ProgramData\Package Cache\dwdwd\Installers\asdasd\asdasdasd\asdasdasd\asdasdasdds\sdsds\dssd\sd\ad\dcsdsas\ds\a\sd\sasd\asdasdas\asdas\sdsdsdsd\sdsdssdsd\sd\wswswsws\asdas\asdasda\sd\sdsqwdasdwd\asdasdasdas\asda\dsasd\sasdas\asda\asda\asd\asdasdasdas\asdasdas\dsdsdsd\wwsws\dsaw\dsaw\dswdwd\asdw\asdw\asdw\asd\sx\s\dw\asdwasdw\sdsdawdsdwd\asdwdasdws\s\wdasdw\sdsawedasd\wasdw\asdw\asd\wad\wasd\wdwddwdwd\asd\asd\wdsa\wdasdsdwasd\dwasdwdasdw\asdwasdawdas\wdasdwasdw\WimMountAdkSetupAmd64.exe

image

LGTM!

EDIT:

I also verified that regular, expected wildcard scenarios still work in Trusted Apps with mimikatz.

image

@paul-tavares paul-tavares merged commit db56fec into elastic:7.17 Apr 27, 2022
@paul-tavares paul-tavares deleted the task/olm-3727-fix-artifact-path-checking-utility branch April 27, 2022 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OLM Sprint release_note:fix Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.17.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants