Replies: 2 comments 3 replies
-
|
Boxtin supports coarse-grained access denial. Entire classes or packages can be denied in one step using the "denyAll" operation of the RulesBuilder. Fine-grained "allow" operations can override course-grained denials as necessary. Boxtin analyzes the immediate caller stack frame at runtime when performing security checks. This is a "shallow" check, whereas the original SecurityManager checked all the stack frames. The controller you define and pass to Boxtin is in charge of deciding what rules to select, and for which modules. Your controller needs to be aware of the ClassLoaders used by each plugin, and each will have an unnamed module instance which can be used for selecting the rules. The controller can use a set of very strict denial rules for unknown modules. You can choose to deny access to java.lang.System (as you mentioned), but this might be too restrictive. The arraycopy method is safe to use, and so denying it doesn't seem necessary. The fundamental problem is that many of the core JDK classes weren't organized properly, and so some degree of fine-grained control is necessary at times. Some of the newer features are better organized however, like the java.lang.foreign package. Defining a safe set of rules is hard, and so I anticipate Boxtin providing various "stock" rules which can be applied with little effort. Currently there's only one of these defined in the RulesApplier class. By the way, you also mention restricting access to System.out. I originally supported denying access to fields too, but it was only really applicable to the System fields. I dropped it to keep things simple. |
Beta Was this translation helpful? Give feedback.
-
Alright, it sounds like Boxtin is doing runtime checks based on the stackframe. I don't think this is exactly what we want. Instead of doing a runtime security check when somebody calls a method on java.lang.System or java.io.File I think we would want to do a "loadtime" check and deny a Plugin Classloader the ability to load these classes at all. If they do try to call any method on these classes or even reference/import these classes at all I would consider it an error and a breach of the Container contract. I guess while Boxtin is used for doing traditional stackframe-based analysis, I'm more interested in completely deny Plugins the ability to import or even reference certain classes. I understand reflection exists and understand reflection breaks all these rules. I guess the reason why Boxtin and the SecurityManager chose this runtime, stack-frame analysis approach was simply to safeguard indirect, reflective loading of classes.
I think this is okay. I'm fine with denying all access to classes like java.lang.System and providing wrappers to functionality like System.arraycopy. The only real problem with the "class denial" approach are classes like java.lang.Boolean which provide methods like getBoolean that provide access to underlying System Properties. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Boxtin is a very interesting project. It seems like it's the only way forward for reasonable sandboxing on JDK 24+. But as I dig into it I still find the API bit too fine-grained and tedious. This was the same basic problem with the SecurityManager. It seems Boxtin is about denying access to individual methods and constructors. This has always struck me as a bad idea.
Instead we'd like to simply deny any and all access to certain capabilities of the host platform. In this model Plugins (or any code loaded through an "untrusted" Classloader) should have absolutely no access to the System Console (System.out, System.in), no access to the File system, no access to Networking, no ability to create or start (Virtual) Threads. (There'll probably be additional requirements around JavaFX in the future since we also don't want plugins creating new top-level windows or dialog windows.)
Is this sort of "coarse grained" access denial something Boxtin can do?
Does Boxtin analyze the caller stack-frames at runtime to do its security checks?
But I guess what we'd really like to do is prevent certain classes from being loaded at all from a given untrusted classloader. In other words if the untrusted Plugin Classloader A attempts to load the class java.io.File or even java.lang.System we might raise an immediate error. It's less about checking whether individual methods can be called than it is about denying access to entire classes, packages, and modules.
Is this something Boxtin can do?
Beta Was this translation helpful? Give feedback.
All reactions