Skip to content

Commit 86b2e43

Browse files
committed
Make timing attacks against the Realm implementations harder. (schultz)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1758499 13f79535-47bb-0310-9956-ffa450edef68
1 parent f603f2f commit 86b2e43

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

java/org/apache/catalina/realm/DataSourceRealm.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ protected Principal authenticate(Connection dbConnection,
303303

304304
if(dbCredentials == null) {
305305
// User was not found in the database.
306+
// Waste a bit of time as not to reveal that the user does not exist.
307+
getCredentialHandler().mutate(credentials);
306308

307309
if (containerLog.isTraceEnabled())
308310
containerLog.trace(sm.getString("dataSourceRealm.authenticateFailure",

java/org/apache/catalina/realm/JDBCRealm.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ public synchronized Principal authenticate(Connection dbConnection,
384384

385385
if (dbCredentials == null) {
386386
// User was not found in the database.
387+
// Waste a bit of time as not to reveal that the user does not exist.
388+
getCredentialHandler().mutate(credentials);
387389

388390
if (containerLog.isTraceEnabled())
389391
containerLog.trace(sm.getString("jdbcRealm.authenticateFailure",

java/org/apache/catalina/realm/MemoryRealm.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ public Principal authenticate(String username, String credentials) {
125125
GenericPrincipal principal = principals.get(username);
126126

127127
if(principal == null || principal.getPassword() == null) {
128-
// User was not found in the database of the password was null
128+
// User was not found in the database or the password was null
129+
// Waste a bit of time as not to reveal that the user does not exist.
130+
getCredentialHandler().mutate(credentials);
129131

130132
if (log.isDebugEnabled())
131133
log.debug(sm.getString("memoryRealm.authenticateFailure", username));

java/org/apache/catalina/realm/RealmBase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ public Principal authenticate(String username, String credentials) {
344344

345345
if (serverCredentials == null) {
346346
// User was not found
347+
// Waste a bit of time as not to reveal that the user does not exist.
348+
getCredentialHandler().mutate(credentials);
347349

348350
if (containerLog.isTraceEnabled()) {
349351
containerLog.trace(sm.getString("realmBase.authenticateFailure",

webapps/docs/changelog.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@
183183
of the web.xml file where specified or UTF-8 where no explicit encoding
184184
is specified. (markt)
185185
</fix>
186+
<fix>
187+
Make timing attacks against the Realm implementations harder. (schultz)
188+
</fix>
186189
</changelog>
187190
</subsection>
188191
<subsection name="Coyote">

0 commit comments

Comments
 (0)