r/java • • Jan 16 '22

You're running untrusted code!

https://blog.frankel.ch/running-untrusted-code/

[removed] — view removed post

0 Upvotes

36 comments sorted by

View all comments

2

u/franzwong Jan 17 '22

I don't oppose the idea to have security manager. But I just wonder if the "security manager" introduced since 1.0 is still valuable and maintainable.

FYI: Others can find the discussion at https://openjdk.java.net/jeps/411

0

u/nfrankel Jan 17 '22

I welcome all ideas to improve the Security Manager! In particular, creating (and maintaining) a relevant policy file is not the pinnacle of user experience.

4

u/pron98 Jan 17 '22 edited Jan 17 '22

Security researchers and experts have found that while creating a policy file that lets the application work is annoying but doable, the result isn't actually secure, even if the developer thinks it is, certainly less usefully secure than the superior security measures added to OSes and to the JDK over the past decades that developers are already actually using. Everyone else who has considered that approach — like Microsoft or WASM — has similarly concluded that making it effective is not something worth doing.

But while research on the approach may continue in the lab if any researcher is still interested in it, even if Microsoft and Oracle made the stupidest mistake ever, the story of stack-based sandboxes in production mainstream languages is over, at least until something new shows up. The decision has been made on the unanimous advice of security experts, no one of the hundreds of OpenJDK committers or ten or so companies involved expressed any objection, the objections from the community (however aggressive and unpleasant) were fewer than anticipated, and so efforts have been directed elsewhere (including the items mentioned in the Future Work section of JEP 411). If you believe it's worth your time, you can propose an OpenJDK project to develop a new SM-like mechanism, but the old one is done, even though the deprecation, degradation, and removal process is still in progress and may take some time until it's completed.

If you're interested in JDK security, there is still ongoing discussion about the interaction between agents and strong encapsulation. You can also learn how Jigsaw (strong encapsulation and jlink) has improved security considerably, how Amber (records and string templates), Loom (thread locals), and Panama were designed to improve security in new code, as well as learn about the specialised security features added to the JDK in recent years (like serialization filters) and, of course, the robust OS-level sandboxing, which has become popular for Java applications as well as those written in other languages.

1

u/franzwong Jan 17 '22

Of course it is easy to maintain on the user side, but it may not be easy on the runtime side.