Skip to content

Commit

Permalink
Add back CHANGELOG entry for authenticate_by
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Dec 15, 2021
1 parent eb80dd3 commit 139183c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1 +1,28 @@
* Add `authenticate_by` when using `has_secure_password`.

`authenticate_by` is intended to replace code like the following, which
returns early when a user with a matching email is not found:

```ruby
User.find_by(email: "...")&.authenticate("...")
```

Such code is vulnerable to timing-based enumeration attacks, wherein an
attacker can determine if a user account with a given email exists. After
confirming that an account exists, the attacker can try passwords associated
with that email address from other leaked databases, in case the user
re-used a password across multiple sites (a common practice). Additionally,
knowing an account email address allows the attacker to attempt a targeted
phishing ("spear phishing") attack.

`authenticate_by` addresses the vulnerability by taking the same amount of
time regardless of whether a user with a matching email is found:

```ruby
User.authenticate_by(email: "...", password: "...")
```

*Jonathan Hefner*


Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activerecord/CHANGELOG.md) for previous changes.

0 comments on commit 139183c

Please sign in to comment.