Skip to content

Commit

Permalink
Make timing attacks against the Realm implementations harder. (schultz)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.5.x/trunk@1758500 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Aug 30, 2016
1 parent f97769f commit d79c63d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions java/org/apache/catalina/realm/DataSourceRealm.java
Expand Up @@ -303,6 +303,8 @@ protected Principal authenticate(Connection dbConnection,

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

if (containerLog.isTraceEnabled())
containerLog.trace(sm.getString("dataSourceRealm.authenticateFailure",
Expand Down
2 changes: 2 additions & 0 deletions java/org/apache/catalina/realm/JDBCRealm.java
Expand Up @@ -384,6 +384,8 @@ public synchronized Principal authenticate(Connection dbConnection,

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

if (containerLog.isTraceEnabled())
containerLog.trace(sm.getString("jdbcRealm.authenticateFailure",
Expand Down
4 changes: 3 additions & 1 deletion java/org/apache/catalina/realm/MemoryRealm.java
Expand Up @@ -125,7 +125,9 @@ public Principal authenticate(String username, String credentials) {
GenericPrincipal principal = principals.get(username);

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

if (log.isDebugEnabled())
log.debug(sm.getString("memoryRealm.authenticateFailure", username));
Expand Down
2 changes: 2 additions & 0 deletions java/org/apache/catalina/realm/RealmBase.java
Expand Up @@ -344,6 +344,8 @@ public Principal authenticate(String username, String credentials) {

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

if (containerLog.isTraceEnabled()) {
containerLog.trace(sm.getString("realmBase.authenticateFailure",
Expand Down
3 changes: 3 additions & 0 deletions webapps/docs/changelog.xml
Expand Up @@ -183,6 +183,9 @@
of the web.xml file where specified or UTF-8 where no explicit encoding
is specified. (markt)
</fix>
<fix>
Make timing attacks against the Realm implementations harder. (schultz)
</fix>
</changelog>
</subsection>
<subsection name="Coyote">
Expand Down

0 comments on commit d79c63d

Please sign in to comment.