Skip to content
This repository was archived by the owner on Dec 4, 2018. It is now read-only.

Commit dc4c331

Browse files
committed
Make timing attacks against the Realm implementations harder. (schultz)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.0.x/trunk@1758501 13f79535-47bb-0310-9956-ffa450edef68
1 parent d98fa92 commit dc4c331

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
@@ -488,6 +488,8 @@ public Principal authenticate(String username, String credentials) {
488488

489489
if (serverCredentials == null) {
490490
// User was not found
491+
// Waste a bit of time as not to reveal that the user does not exist.
492+
getCredentialHandler().mutate(credentials);
491493

492494
if (containerLog.isTraceEnabled()) {
493495
containerLog.trace(sm.getString("realmBase.authenticateFailure",

webapps/docs/changelog.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@
200200
of the web.xml file where specified or UTF-8 where no explicit encoding
201201
is specified. (markt)
202202
</fix>
203+
<fix>
204+
Make timing attacks against the Realm implementations harder. (schultz)
205+
</fix>
203206
</changelog>
204207
</subsection>
205208
<subsection name="Coyote">

0 commit comments

Comments
 (0)