Luis-Miguel Alventosa's Blog

All | Java | xVM
« Monitoring and Manag... | Main | Securing the out-of-... »
20060925 Monday September 25, 2006

Authentication and Authorization in JMX RMI connectors

The aim of this blog entry is to explain to you all the possible ways of configuring the JMX RMI connectors to perform authentication and authorization by walking through the following use cases.

Posted by lmalvent ( Sep 25 2006, 11:38:32 AM CEST ) Permalink Comments [16]

Trackback URL: http://blogs.sun.com/lmalventosa/entry/jmx_authentication_authorization
Comments:

hi, congratulations for your blog! jGuard also support since 1.0 beta 1 release,authentication and authorization for JMX, in an unified way for your standalone and webapps: user is authenticated once, and will have access to web ressources, JMX ressources, or swing resources in an unified way, based on permission granted to him. jGuard provides a Policy implementation. we've used a custom JMXAuthenticator for authentication to link it to the LoginContext class, but no changes have been required for authorization and policy. cheers, Charles GAY. http://www.jguard.net

Posted by charles gay on September 27, 2006 at 01:47 PM CEST #

Thanx, excellent article.
There still few points left not mentioned:
  • Customized authorization (customized authentication is covered pretty well).
  • MBean specific authorization (MBSFInvocationHandler performs just the server specific one).
10x once more ;o)

Posted by JabberW on October 19, 2006 at 11:55 AM CEST #

Mr. Alventosa - Your post was very helpful to me. I especially like the Custom JMXAuthenticator option. I still have a concern, however, which is pointed out in Platorm Monitoring and Management Using JMX:
WARNING: A potential security issue has been identified with password authentication for JMX remote connectors when the client obtains the remote connector from an insecure RMI registry (the default). If an attacker starts a bogus RMI registry on the target server before the legitmate one is started, then the attacker can steal clients' passwords. This scenario includes the case where you launch a JVM with remote management enabled, using the system property com.sun.management.jmxremote.port=portNum, even when SSL is enabled. Although such attacks are likely to be noticed, it is nevertheless a vulnerability.

To avoid this problem, use SSL client certificates for authentication instead of passwords, or ensure that the client obtains the remote connector object securely, for example through a secure LDAP server or a file in a shared secure filesystem.
Can you comment? Can you give an example of how to obtain "the remote connector object securely"? Are there other ways around this problem?

Thanks very much!

Steve

Posted by Steve T on November 07, 2006 at 10:11 AM CET #

Hi Steve,

The potential security issue in when running the out-of-the-box management agent in J2SE 5.0 comes from the fact that the RMI Registry is not SSL-protected and as such cannot require client auhtentication.

This has been fixed in JDK 6 by adding a new configuration property to the management.properties file that enables SSL when running the RMI Registry:

com.sun.management.jmxremote.registry.ssl=true

This property must be used in conjuction with the already existing one:

com.sun.management.jmxremote.ssl.need.client.auth=true

to make this potential security issue go away.

Have a look at the M&M documentation in JDK 6 for more detailed info:

But what about J2SE 5.0? How can this problem be solved?

Unfortunately, you will have to mimick the out-of-the-box management agent and supply your own RMIConnectorServer that you will configure using the RMIConnectorServer constructor that takes as input parameter an RMIServer which you will previously export using SSL and bind it to an RMIRegistry that already uses SSL. And here is where my blogs about securing RMI come into play.

Have a look at the following blog entries to see how to mimick the out-of-the-box management agent and combine it with the other two blog entries talking about securing the RMI Registry and binding remote objects to it. You will instantiate the RMIConnectorServer directly instead of going through the JMXConnectorServerFactory.

I'll try to write a new blog entry talking about how to do this as soon as I have some spare time.

In the meantime, I hope this helps you make some progress on your current implementation.

Regards,
Luis-Miguel Alventosa
JMX Java SE Development Team
Sun Microsystems, Inc.

Posted by Luis-Miguel Alventosa on November 08, 2006 at 12:04 PM CET #

Dear Mr. Alventosa,

Thank you, thank you, thank you! I am glad to get your expert guidance on this, and I very much appreciate your time and advice. I will read over the posts you cited and look forward to another blog entry on the subject.

Take care,

Steve

Posted by Steve T on November 09, 2006 at 01:31 AM CET #

FYI

For more detailed info on Securing the out-of-the-box management agent with an SSL/TLS-based RMI Registry you can have a look at the following blog entry:

http://blogs.sun.com/lmalventosa/entry/secure_management_agent

Regards,
Luis

Posted by Luis-Miguel Alventosa on November 17, 2006 at 05:30 PM CET #

Mr. Alventosa -

Can you recommend a resource on JAAS that has some good examples of the various LoginModules available? I'm looking for an alternative to LDAP and JNDI, but haven't found any examples that, say, avoid cleartext passwords in files (by using a CallbackHandler, as far as I can tell). I need to have something that both secures the passwords nicely and also works with JConsole...

Thanks for your help.

Steve

Posted by Steve T on December 03, 2006 at 08:26 PM CET #

Just want to say 'Thanks' to you!

Posted by 192.18.43.225 on February 21, 2007 at 06:46 AM CET #

Good article luis, following on the question by JabberW can you give a suggestion how we can derive the MBean name that a remote client is trying to access via the mbeanserver invoke? as pointed out previously setMBeanServerForwarder seems to limit us to only catching Mbeanserver's own method invocation calls. thanks and best regards.

Posted by Json on March 07, 2007 at 08:15 AM CET #

Hi Luis,

Great article!

I'm using the optional JMXMP Connector instead of the RMI Connector and I want to use a JAAS login module for server authentication.

However, the JMXMP Connector uses SASL and the credentials passed to the JMXAuthenticator.authenticate() method are the connection id and an authenticated Subject - not the user and password - so I don't have the password to supply to the JAAS login module.

Do you know if this is possible? I suspect that it may not be, as SASL uses a challenge/response protocol, so the password is not actually sent to the server.

However, in other respects the JMXMP Connector is more powerful, so I'd expect to be able to authenticate the server using LDAP.

Thanks,

Derek

Posted by Derek Baum on June 12, 2007 at 05:57 PM CEST #

Hi Derek,

The way JMXAuthenticator.authenticate() works for JMXMP is a bit different from the way it works for the RMI connector.

Authentication in the JMXMP connector is performed using SASL and the call to JMXAuthenticator.authenticate() is just a hook to let the server do a final check/modification of the Subject before the handshake is finished.

You should be able to write your own SASL provider very easily that wraps an existing JAAS Login Module.

JDK 6 ships with a JAAS LDAP Login Module:

http://java.sun.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/module/LdapLoginModule.html

In order to see how to write a SASL provider download the JSR 160 examples from the JCP website.

http://jcp.org/en/jsr/detail?id=160

Let me know if you need more detailed info.

Regards,
Luis

Posted by Luis-Miguel Alventosa on June 12, 2007 at 07:02 PM CEST #

Luis,

If I understand correctly, the SASL provider that I create must make the clear text password available to the server, so it can be used as input to the JAAS LDAP Login module CallbackHandler?

Although this should work, it means that I can not then leveage existing SASL mechanisms, such as DIGEST-MD5, that can also provide privacy without the need for SSL.

Another possibility I am investigating is using the jmx.remote.context parameter. This is an arbitary Object that is transported as part of JMXMP SASL authentication, but is not otherwise used. I could use it to transport the clear text password. This would be encryped if I was using DIGEST-MD5 or TLS.

At the server, I'd have to set com.sun.jmx.remote.profile.checker to my implementation of CheckProfiles in order to retrieve the value of the context object. Unfortunately, this does not get called until just before the end of the authentication exchange, which is too late for the password in the context object to be used in the CallbackHandler.

I can get around this by authenticating using a fake password, which always succeeds and then in checkProfiles() do the real authentication using a JAAS Login module. If this fails, I can throw an exception, which will abort the connection.

I think this scheme allows me to leverage existing SASL mechanisms and still authenticate against a JAAS Login module on the server.

Thanks again for the great article.

Derek

Posted by Derek Baum on June 13, 2007 at 08:47 PM CEST #

This article addresses cases when there is one connection per one client. But if we want to use the same connection for making requests from different clients then authentication that happens only once when connection is established doesn't help.

Is there a way to force authentication for each request thus ?

Posted by Alexander Golubev on February 20, 2008 at 12:51 PM CET #

Using method 4 above, what are the proper JVM arguments or configuration? If I use authenticate=true then it asks for a password file. In method 4 there is no password file. If I set authenticate=false then my custom JMXAuthenticator never gets invoked.

Any idea what I'm missing?

Thanks.

Posted by bbishopski on June 30, 2008 at 03:36 PM CEST #

bbishopski, you don't need to specify any system property to run method 4. You're using a custom RMI connector server and the only thing you must be sure of is that the custom authenticator has been supplied in the connector server map.

Maybe you're mixing both the out-of-the-box management agent and the custom
management agent and my blog only covers JMX Remote API 1.0 (JSR-160) connector servers.

If you want to use a database for authentication with the OOTB management
agent you should probably have to write a JAAS Login Module for it.

Have a look at
http://java.sun.com/javase/6/docs/technotes/guides/management/index.html
for more detailed info.

Regards,
Luis

Posted by Luis-Miguel Alventosa on June 30, 2008 at 11:54 PM CEST #

Hi Alexander,

If you have more than one client probably the easiest way for you would be to have two different connector clients each authenticating with its own security credentials. JMX Remote API 1.0 (JSR-160) also defines subject delegation that allows to multiplex different users in a single authenticated connection. Have a look at the JSR 160 specification to learn more about it.

Regards,
Luis

Posted by Luis-Miguel Alventosa on July 01, 2008 at 12:06 AM CEST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed

Calendar

RSS Feeds

Search

Links

Planet JMX

Navigation

Referers