Author: jfrederic.clere(a)jboss.com
Date: 2009-11-17 10:46:57 -0500 (Tue, 17 Nov 2009)
New Revision: 1270
Modified:
branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
branches/2.1.x/webapps/docs/changelog.xml
branches/2.1.x/webapps/docs/config/http.xml
Log:
Fix for cve-2009-3555.
Modified: branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
===================================================================
--- branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2009-11-17
14:18:11 UTC (rev 1269)
+++ branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2009-11-17
15:46:57 UTC (rev 1270)
@@ -42,6 +42,8 @@
import java.util.Vector;
import javax.net.ssl.CertPathTrustManagerParameters;
+import javax.net.ssl.HandshakeCompletedEvent;
+import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.ManagerFactoryParameters;
@@ -99,6 +101,7 @@
protected String clientAuth = "false";
protected SSLServerSocketFactory sslProxy = null;
protected String[] enabledCiphers;
+ protected boolean allowUnsafeLegacyRenegotiation = false;
/**
* Flag to state that we require client authentication.
@@ -149,13 +152,36 @@
SSLSocket asock = null;
try {
asock = (SSLSocket)socket.accept();
+ if (!allowUnsafeLegacyRenegotiation) {
+ asock.addHandshakeCompletedListener(
+ new DisableSslRenegotiation());
+ }
configureClientAuth(asock);
} catch (SSLException e){
throw new SocketException("SSL handshake error" + e.toString());
}
return asock;
}
+
+ private static class DisableSslRenegotiation
+ implements HandshakeCompletedListener {
+ private volatile boolean completed = false;
+ public void handshakeCompleted(HandshakeCompletedEvent event) {
+ if (completed) {
+ try {
+ log.warn("SSL renegotiation is disabled, closing
connection");
+ event.getSession().invalidate();
+ event.getSocket().close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ completed = true;
+ }
+ }
+
+
public void handshake(Socket sock) throws IOException {
((SSLSocket)sock).startHandshake();
}
@@ -447,6 +473,9 @@
enabledCiphers = getEnabledCiphers(requestedCiphers,
sslProxy.getSupportedCipherSuites());
+ allowUnsafeLegacyRenegotiation =
+
"true".equals(attributes.get("allowUnsafeLegacyRenegotiation"));
+
// Check the SSL config is OK
checkConfig();
Modified: branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
===================================================================
--- branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2009-11-17
14:18:11 UTC (rev 1269)
+++ branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2009-11-17
15:46:57 UTC (rev 1270)
@@ -170,7 +170,10 @@
break;
}
}
- ssl.setSoTimeout(oldTimeout);
+ // If legacy re-negotiation is disabled, socked could be closed here
+ if (!ssl.isClosed()) {
+ ssl.setSoTimeout(oldTimeout);
+ }
if (listener.completed == false) {
throw new SocketException("SSL Cert handshake timeout");
}
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2009-11-17 14:18:11 UTC (rev 1269)
+++ branches/2.1.x/webapps/docs/changelog.xml 2009-11-17 15:46:57 UTC (rev 1270)
@@ -20,6 +20,16 @@
<subsection name="Coyote">
<changelog>
<fix>
+ Fix CVE-2009-3555, man-in-the-middle attack in TLS protocol. (markt)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
+<section name="JBoss Web 2.1.5.GA (remm)">
+ <subsection name="Coyote">
+ <changelog>
+ <fix>
<bug>46950</bug>: Allow renegotiation to work for client
certificates. (markt)
</fix>
<fix>
Modified: branches/2.1.x/webapps/docs/config/http.xml
===================================================================
--- branches/2.1.x/webapps/docs/config/http.xml 2009-11-17 14:18:11 UTC (rev 1269)
+++ branches/2.1.x/webapps/docs/config/http.xml 2009-11-17 15:46:57 UTC (rev 1270)
@@ -501,6 +501,13 @@
TrustStore then you are using for the KeyStore.</p>
</attribute>
+ <attribute name="allowUnsafeLegacyRenegotiation"
required="false">
+ <p>Is unsafe legacy TLS renegotiation allowed which is likely to expose
+ users to CVE-2009-3555, a man-in-the-middle vulnerability in the TLS
+ protocol that allows an attacker to inject arbitrary data into the user's
+ request. If not specified, a default of <code>false</code> is
used.</p>
+ </attribute>
+
</attributes>
<p>For more information, see the
Show replies by date