r/java • • Mar 21 '23

JDK 21: Disallowing the dynamic loading of agents by default

https://mail.openjdk.org/pipermail/serviceability-dev/2023-March/046868.html
60 Upvotes

95 comments sorted by

View all comments

Show parent comment

2

u/FirstAd9893 Mar 21 '23 edited Mar 21 '23

The feature that's going to be disabled by default isn't attaching, it's dynamic agent loading. This is a feature to enhance the security of the module system.

The module system provides simpler (and therefore superior) security compared to the old security manager. There's a few tasks that need to be finished before modules can fully achieve this this goal, however.

A major issue is that file and network access are still in the base module. Assuming that was resolved (and a few other items), it becomes possible to implement things like client-provided code plugins. Imagine if a client could install something like a stored procedure in a database, which is written in Java and it runs in a security sandbox. Or imagine if an applet-like system was reinvented, it too would require some sort of security sandbox.

The whole system falls apart if the client-provided code is able to load an agent which could modify all the code in the system to do whatever it wants. The only other thing guarding against that today is the security manager, but that's deprecated.

-1

u/[deleted] Mar 21 '23

Don’t get me started on the module system, that thing can kiss my ass as well. I am the developer, if I want to access internals of the java language I have a good reason for it, do not limit the language in unnecessary ways.

-1

u/blobjim Mar 21 '23

It's not about you accessing it lmao. It's about malicious code accessing it.

2

u/[deleted] Mar 21 '23

if malicious code is trying to access internals, shit already hit the fan

1

u/blobjim Mar 22 '23

This is mostly about dynamic instrumentation. As in, turned on and used from inside the application. It's another possible attack vector that some remote hack could use to extract data.

1

u/[deleted] Mar 22 '23

as mentioned, if an attacker has a viable access vector to the jvm, shit already hit the fan

1

u/blobjim Mar 22 '23

The point of a lot of these changes is that that doesn't have to be the case. You can harden the language and runtime so vulnerable Java code doesn't automatically mean passwords and keys stored in the VM are acquired by the attacker. That was part of the rationale of the Java module system (you can't access private fields from other modules). Just because someone ran vulnerable code inside your jvm inside its container doesn't mean they get access to secrets.

But having instrumentation enabled allows that, even if it isn't used, like in most cases (possibly unknown by the developer).

1

u/SocialMemeWarrior Mar 21 '23

Me and malicious code are on the same machine then. Again, that's game over. You are only neutering developer capability here.

0

u/blobjim Mar 22 '23

"neutering developer capability" as in your IDE will have to pass one extra command line argument automatically. Why are people going insane over this?

1

u/SocialMemeWarrior Mar 22 '23

The problem isn't when you're operating within a developer environment. Read the replies in this thread.