-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Entitlements] Exclude java.desktop from system modules
#124563
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
[Entitlements] Exclude java.desktop from system modules
#124563
Conversation
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
| .stream() | ||
| .filter( | ||
| m -> systemModulesDescriptors.contains(m.getDescriptor()) | ||
| && MODULES_EXCLUDED_FROM_SYSTEM_MODULES.contains(m.getName()) == false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we filter this out of systemModuleDescriptors instead? Otherwise, that set isn't quite right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand your point; systemModuleDescriptors is a local variable. We can filter it out from systemModuleDescriptors, or from here. Am I missing something? Does it make a difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there's no functional difference, but it seems odd to create an incorrect value and then account for that incorrectness later.
It's not a huge deal, since the returned value is unaffected, as you say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, one could argue that the first line is simply collecting whatever ModuleFinder.ofSystem() returns, and it's the second line that's responsible for building the list of system modules that Entitlements needs.
So I'm ok either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, one could argue that the first line is simply collecting whatever ModuleFinder.ofSystem() returns
That's exactly what I was thinking :)
…4563) * exclude java.desktop from system modules * add IT test
…4563) * exclude java.desktop from system modules * add IT test
…4563) * exclude java.desktop from system modules * add IT test
…124620) * exclude java.desktop from system modules * add IT test
…124619) * exclude java.desktop from system modules * add IT test
…124618) * exclude java.desktop from system modules * add IT test
…4563) * exclude java.desktop from system modules * add IT test
…4563) * exclude java.desktop from system modules * add IT test
…astic#124563)" This reverts commit d844c6a.
When we realized we have missed instrumentation of
URL.openConnectionmethods, we tried to see if we could also chase usages of these functions across the codebase, as an alternative to instrumentURLConnectionclasses (the return type). There were many uses, and complex ones, so we ended up doing theURLConnectioninstrumentation, but we also realized that Elasticsearch still loads thejava.desktopmodule. Collective memory seems to remember we have it for just a couple of encoding/decoding functions; however, since we now "skip" verification for system modules, all calls to file and network operations formjava.desktopare permitted, which exposes a huge surface (there might be something exploitable there).This PR removes the
java.desktopmodule explicitly (with the ability to add more if we need to) from the set of "system modules". We should not need any entitlement forjava.desktop(we should barely use it, and not use it for any sensitive operation); however if it turns out that we need letjava.desktopperform some sensitive operation, we can explicitly add that back to the server policy, e.g. adding:to
serverScopesinEntitlementInitialization.Testing this with a IT test is difficult/impossible, as we are talking about server policies.
I've tested this manually in the following way:
(ImageIO is just a "convenient" class I found in
java.desktopjava.desktoptoMODULES_EXCLUDED_FROM_SYSTEM_MODULES--> "ImageIO Not entitled"new Scope("java.desktop", List.of(new LoadNativeLibrariesEntitlement()))toserverScopesinEntitlementInitialization--> "ImageIO Entitled"I have also:
(server)module): see next pointserver: adding the code above to a plugin works correctly (server policy + call to sensitive method from a plugin)Relates to: ES-11008