[jboss-cvs] JBossAS SVN: r114519 - projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 2 22:52:25 EDT 2013
Author: jiwils
Date: 2013-10-02 22:52:25 -0400 (Wed, 02 Oct 2013)
New Revision: 114519
Added:
projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java
Modified:
projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/Main.java
Log:
Add CVE-2011-4605 changes for JBPAPP-10871.
Modified: projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/Main.java
===================================================================
--- projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/Main.java 2013-10-01 14:21:22 UTC (rev 114518)
+++ projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/Main.java 2013-10-03 02:52:25 UTC (rev 114519)
@@ -105,6 +105,8 @@
private Executor lookupExector;
/** The exception seen when creating the lookup listening port */
private Exception lookupListenerException;
+ /** Naming server guard to receive RMIs and decide what will come through to NamingServer */
+ private NamingServerGuard namingServerGuard;
// Static --------------------------------------------------------
public static void main(String[] args)
@@ -440,8 +442,14 @@
serverSocket = null;
s.close();
}
- if( isStubExported == true )
- UnicastRemoteObject.unexportObject(theServer.getNamingInstance(), false);
+ if( isStubExported == true )
+ {
+ if (namingServerGuard != null)
+ UnicastRemoteObject.unexportObject(namingServerGuard, false);
+ else
+ UnicastRemoteObject.unexportObject(theServer.getNamingInstance(), false);
+ }
+
}
catch (Exception e)
{
@@ -458,9 +466,18 @@
+",rmiPort="+rmiPort
+",clientSocketFactory="+clientSocketFactory
+",serverSocketFactory="+serverSocketFactory);
+
Naming instance = getNamingInstance();
- Remote stub = UnicastRemoteObject.exportObject(instance,
- rmiPort, clientSocketFactory, serverSocketFactory);
+ Remote stub;
+ if (getUseGlobalService()) {
+ namingServerGuard = new NamingServerGuard(instance);
+ stub = UnicastRemoteObject.exportObject(namingServerGuard,
+ rmiPort, clientSocketFactory, serverSocketFactory);
+ }
+ else {
+ stub = UnicastRemoteObject.exportObject(instance,
+ rmiPort, clientSocketFactory, serverSocketFactory);
+ }
log.debug("NamingServer stub: "+stub);
serverStub = new MarshalledObject(stub);
isStubExported = true;
Copied: projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java (from rev 113109, projects/naming/branches/5.0.3.GA_CP/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java)
===================================================================
--- projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java (rev 0)
+++ projects/naming/branches/5.0.3.GA_JBPAPP-10871/jnpserver/src/main/java/org/jnp/server/NamingServerGuard.java 2013-10-03 02:52:25 UTC (rev 114519)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jnp.server;
+
+import java.rmi.RemoteException;
+import java.util.Collection;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.NoPermissionException;
+
+import org.jnp.interfaces.Naming;
+
+/**
+ * NamingServerGuard will be registered instead of NamingServer to receive all RMIs and decide what
+ * will come through to NamingServer.
+ *
+ * @author Peter Skopek <pskopek at redhat.com>
+ *
+ */
+public class NamingServerGuard
+ implements Naming, java.io.Serializable
+{
+
+ private static final long serialVersionUID = 1875763972368932742L;
+
+ private final Naming securedNaming;
+
+ public static final String GUARDED_JNDI_METHOD_NAMES = "bind,rebind,unbind,createSubcontext";
+
+
+
+ public NamingServerGuard(Naming securedNaming) {
+
+ this.securedNaming = securedNaming;
+ }
+
+ public void bind(Name name, Object obj, String className)
+ throws NamingException, RemoteException {
+
+ throw new NoPermissionException("bind JNDI operation not allowed when calling from outside NamingServer's VM.");
+ }
+
+ public void rebind(Name name, Object obj, String className)
+ throws NamingException, RemoteException {
+
+ throw new NoPermissionException("rebind JNDI operation not allowed when calling from outside NamingServer's VM.");
+ }
+
+ public void unbind(Name name) throws NamingException, RemoteException {
+
+ throw new NoPermissionException("unbind JNDI operation not allowed when calling from outside NamingServer's VM.");
+ }
+
+ public Object lookup(Name name) throws NamingException, RemoteException {
+ return securedNaming.lookup(name);
+ }
+
+ public Collection list(Name name) throws NamingException, RemoteException {
+ return securedNaming.list(name);
+ }
+
+ public Collection listBindings(Name name) throws NamingException,
+ RemoteException {
+
+ return securedNaming.listBindings(name);
+ }
+
+ public Context createSubcontext(Name name) throws NamingException,
+ RemoteException {
+
+ throw new NoPermissionException("createSubcontext JNDI operation not allowed when calling from outside NamingServer's VM.");
+ }
+
+}
More information about the jboss-cvs-commits
mailing list