如何在 JBoss 中禁用 RMI?
由于存在各种 RMI 漏洞,而且我无论如何也不使用它,我想至少在外部禁用我的 JBoss 服务器上的 RMI,但我不确定如何在不破坏东西的情况下做到这一点。
我尝试禁用 JRMP 调用程序,这似乎有效,但问题是我无法启动和停止我的服务器,因为命令:
sudo -u $JBOSS_USER $JBOSS_HOME/bin/shutdown.sh -S
返回错误:
Exception in thread "main" javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: invoker not bound]
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1215)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:758)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jboss.Shutdown.main(Shutdown.java:214)
Caused by: javax.naming.NameNotFoundException: invoker not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:613)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1209)
... 4 more
我没有看到调用程序在 / 中的其他任何地方被引用path/to/jboss/server/default/conf/jboss-service.xml 所以我不确定需要删除哪些其他引用。
关于我做错了什么或者我只是要求相互排斥的功能有什么想法吗?
Due to various RMI exploits out there and the fact that I don't use it anyway, I'd like to disable RMI on my JBoss server at least externally, but I'm not sure how to do this without breaking things.
I've tried disabling the JRMP invoker, which seems to work but the problem is that I'm unable to then start and stop my server because the command:
sudo -u $JBOSS_USER $JBOSS_HOME/bin/shutdown.sh -S
returns the error:
Exception in thread "main" javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: invoker not bound]
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1215)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:758)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jboss.Shutdown.main(Shutdown.java:214)
Caused by: javax.naming.NameNotFoundException: invoker not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:613)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1209)
... 4 more
I don't see the invoker being referenced anywhere else in /path/to/jboss/server/default/conf/jboss-service.xml so I'm not sure what other references I would need to remove.
Any ideas on what I'm doing wrong or am I just asking for functionality that's mutually exclusive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 JBoss 4 中,有多个对 RMI 调用程序的引用:
JBoss 中的许多函数都使用 RMI,即使您的应用程序不使用 RMI。最简单的解决方案是将 JBoss 绑定到远程无法使用的地址:
更新
如果您只想在本地绑定 RMI,请编辑 jboss-service.xml 文件中的 BindAddress 和 RmiBindAddress 属性:
In JBoss 4, there are several references to the RMI invokers in:
A lot of functions in JBoss make use of RMI, even if your app doesn't. The easiest solution would be to bind JBoss to an address that isn't available remotely:
Update
If you only want RMI to be bound locally, edit the BindAddress and RmiBindAddress attributes in the jboss-service.xml file:
问题在于 shutdown.sh 使用 RMI 请求关闭,因此当您禁用 JRMPInvoker 时,您也就禁用了 shutdown.sh。
一种选择可能是使用 HTTP post 到 JMXConsole 来请求相同的内容。
看起来效果很好。
=== 更新 ===
我在该 URL 中使用的 methodIndex 是 0,用于关闭,但我确实观察到了一些问题尤其是在使用原生 APR 时。使用 methodIndex 为 2(退出)会更加干净。此外,我还添加了 timeout 和 tries 的 wget 选项。修改后的版本如下所示:
The problem is that shutdown.sh uses RMI to request a shutdown, so when you disabled the JRMPInvoker, you disabled shutdown.sh.
One option might be to use an HTTP post to JMXConsole to request the same.
It seems to work fine.
=== Update ===
The methodIndex I used in that URL was 0 which is for shutdown, but I did observe a couple of issues with that, especially when using the native APR. Using a methodIndex of 2 (exit) works much more cleanly. In addition, I added wget options for timeout and tries. The revised version looks like this: