Skip to content

Commit

Permalink
fix: prevent user enumeration using local login timings
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Sep 17, 2022
1 parent 665284b commit 4b30050
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/modules/authentication/local/authentication.js
@@ -1,3 +1,5 @@
const bcrypt = require('bcryptjs-then')

/* global WIKI */

// ------------------------------------
Expand Down Expand Up @@ -28,6 +30,9 @@ module.exports = {
done(null, user)
}
} else {
// Fake verify password to mask timing differences
await bcrypt.compare((Math.random() + 1).toString(36), '$2a$12$irXbAcQSY59pcQQfNQpY8uyhfSw48nzDikAmr60drI501nR.PuBx2')

done(new WIKI.Error.AuthLoginFailed(), null)
}
} catch (err) {
Expand Down

0 comments on commit 4b30050

Please sign in to comment.