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

JRuby Security Manager Issues (accessPackageInClass.sun.misc) #3272

Closed
andrewvc opened this issue Aug 20, 2015 · 6 comments
Closed

JRuby Security Manager Issues (accessPackageInClass.sun.misc) #3272

andrewvc opened this issue Aug 20, 2015 · 6 comments

Comments

@andrewvc
Copy link

Moved from the mailing list. As @headius put it

In general, we'd like JRuby to work out of the box when a security manager is enabled, possibly disabling features, possibly with warnings to indicate what features have been disabled. I do not believe there's a way to disable this particular logic, since we depend on the JavaPOSIX fallback when in a secured environment. We may need to find a different way to access it (other than reflection).

The usage of classes in sun.misc presents issues with the security manager. In a locked down context I'm trying to run JRuby in I get the following stack trace


Caused by: java.security.AccessControlException: access denied
("java.lang.RuntimePermission" "accessClassInPackage.sun.misc") at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
at
java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at
java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1564) at
java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:811) at
java.lang.ClassLoader.loadClass(ClassLoader.java:357) at
jnr.posix.POSIXFactory.getJavaPOSIX(POSIXFactory.java:51) at
jnr.posix.POSIXFactory.loadPOSIX(POSIXFactory.java:109) at
jnr.posix.LazyPOSIX.loadPOSIX(LazyPOSIX.java:36) at
jnr.posix.LazyPOSIX.posix(LazyPOSIX.java:32) at
jnr.posix.LazyPOSIX.isNative(LazyPOSIX.java:370) at
org.jruby.RubyGlobal.prepareStdioChannel(RubyGlobal.java:279) at
org.jruby.RubyGlobal.createGlobals(RubyGlobal.java:194) at
org.jruby.Ruby.init(Ruby.java:1240) at
org.jruby.Ruby.newInstance(Ruby.java:331) at
org.jruby.embed.internal.AbstractLocalContextProvider.getGlobalRuntime(AbstractLocalContextProvider.java:82)
at
org.jruby.embed.internal.SingletonLocalContextProvider.getRuntime(SingletonLocalContextProvider.java:99)
at
org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.runParser(EmbedRubyRuntimeAdapterImpl.java:167)
at
org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.parse(EmbedRubyRuntimeAdapterImpl.java:94)
at org.jruby.embed.ScriptingContainer.parse(ScriptingContainer.java:1238)
at
org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1298)
@suyograo
Copy link

@headius any idea when this might be targeted for?

@headius
Copy link
Member

headius commented Sep 4, 2015

Hmm...after quick inspection I don't see where jnr-posix is using sun.misc.Unsafe.

@headius
Copy link
Member

headius commented Sep 4, 2015

Can you provide a simple way I can reproduce this? It seems like the use of reflection in our Java POSIX stuff is to blame, but it's hard to tell from your report. If that is the problem, I need to know where, because most place we use reflection do have exception handling in place.

@andrewvc
Copy link
Author

andrewvc commented Sep 4, 2015

@headius unfortunately it's part of a big proprietary blob of code. The error happens merely instantiating jruby (via any of the embedding APIs).

It'll take me a while to extract a minimal test case, but I'll try to find the time over the next couple weeks.

@tduehr
Copy link
Contributor

tduehr commented Sep 5, 2015

Unsafe is used all over JRuby. Even RubyBasicObject uses it. Then again, it's been removed in jdk9. So, it's probably time to start getting rid of it. It's even possible Unsafe is the source of some heisenbugs.

@headius
Copy link
Member

headius commented Jul 8, 2020

We have made efforts to avoid using Unsafe, or to have fallbacks in most cases. In addition, we've done work to make sure we can fall back to degraded functionality on newer versions of Java that protect JDK classes using modules.

I would like to be able to run properly with a security manager in place, but without an example test case this will be difficult to do. I'm closing this as it is rather stale. If someone would like to work with us to make JRuby run better under a security manager, please open a new issue with an example case you expect to work.

@headius headius closed this as completed Jul 8, 2020
@headius headius added this to the Invalid or Duplicate milestone Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants