Fix CVE-2010-1157.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 21 Apr 2010 22:11:29 +0000 (22:11 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 21 Apr 2010 22:11:29 +0000 (22:11 +0000)
Prevent possible disclosure of host name or IP address via the HTTP WWW-Authenticate header when using BASIC or DIGEST authentication.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@936539 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/authenticator/AuthenticatorBase.java
java/org/apache/catalina/authenticator/BasicAuthenticator.java
java/org/apache/catalina/authenticator/DigestAuthenticator.java
webapps/docs/realm-howto.xml

index 5caed3f..e98dd8e 100644 (file)
@@ -107,6 +107,11 @@ public abstract class AuthenticatorBase extends ValveBase
     protected static final String AUTH_HEADER_NAME = "WWW-Authenticate";
 
     /**
+     * Default authentication realm name.
+     */
+    protected static final String REALM_NAME = "Authentication required";
+
+    /**
      * The message digest algorithm to be used when generating session
      * identifiers.  This must be an algorithm supported by the
      * <code>java.security.MessageDigest</code> class on your platform.
index 2e07d47..95a0a29 100644 (file)
@@ -165,9 +165,7 @@ public class BasicAuthenticator
         StringBuilder value = new StringBuilder(16);
         value.append("Basic realm=\"");
         if (config.getRealmName() == null) {
-            value.append(request.getServerName());
-            value.append(':');
-            value.append(Integer.toString(request.getServerPort()));
+            value.append(REALM_NAME);
         } else {
             value.append(config.getRealmName());
         }
index c246bb1..399eef0 100644 (file)
@@ -408,8 +408,7 @@ public class DigestAuthenticator
         // Get the realm name
         String realmName = config.getRealmName();
         if (realmName == null)
-            realmName = request.getServerName() + ":"
-                + request.getServerPort();
+            realmName = REALM_NAME;
 
         byte[] buffer = null;
         synchronized (md5Helper) {
index 5d2d31b..bb41703 100644 (file)
@@ -209,7 +209,11 @@ java org.apache.catalina.realm.RealmBase \
    <code>{cleartext-password}</code> must be replaced with 
    <code>{username}:{realm}:{cleartext-password}</code>. For example, in a
    development environment this might take the form
-   <code>testUser:localhost:8080:testPassword</code>.</p>
+   <code>testUser:Authentication required:testPassword</code>. The value for
+   <code>{realm}</code> is taken from the <code>&lt;realm-name&gt;</code>
+   element of the web application's <code>&lt;login-config&gt;</code>. If
+   not specified in web.xml, the default value of <code>Authentication
+   required</code> is used.</p>
 
 <p>To use either of the above techniques, the
 <code>$CATALINA_HOME/lib/catalina.jar</code> and