Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail on empty password verification (without warning on any implementation) #35497

Merged
merged 1 commit into from Feb 3, 2020
Merged

Fail on empty password verification (without warning on any implementation) #35497

merged 1 commit into from Feb 3, 2020

Conversation

umulmrum
Copy link
Contributor

@umulmrum umulmrum commented Jan 28, 2020

Q A
Branch? 4.4
Bug fix? sort of
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

When using the sodium extension, an empty $raw string will issue a warning during validation, but the standard password_verify() does not. This PR aims to provide identical behavior independent of the underlying implementation. Two assumptions were made (please doublecheck if they are correct):

  • Empty password is never valid.
  • Empty password is not that severe that anybody needs to be informed using a warning or exception.

@nicolas-grekas nicolas-grekas added this to the 4.3 milestone Jan 28, 2020
@nicolas-grekas
Copy link
Member

Can you add the same test case on the SodiumPasswordEncoder?
From your description, I would have expected the patch on SodiumPasswordEncoder btw.
Note that this should target 4.3.
Thanks for the PR.

@umulmrum
Copy link
Contributor Author

My description could have been better :-) - without this PR, the call to sodium_crypto_pwhash_str_verify() in NativePasswordEncoder::isPasswordValid() issues the warning, so the change belongs here. Also added it in SodiumPasswordEncoder now - thanks for the pointer.

As for the target branch: The release info on https://symfony.com/releases/4.3 already marks 4.3 as security-fixes-only. As this is not a security fix, I targetted 4.4 - which one is correct?

@nicolas-grekas
Copy link
Member

There will be a last 4.3 in a few days.

@umulmrum umulmrum requested a review from sroze as a code owner January 28, 2020 14:54
@umulmrum umulmrum changed the base branch from 4.4 to 4.3 January 28, 2020 14:54
@javiereguiluz javiereguiluz changed the title Fail on empty password verification (without warning on any implement… Fail on empty password verification (without warning on any implementation) Jan 29, 2020
@nicolas-grekas nicolas-grekas modified the milestones: 4.3, 4.4 Feb 1, 2020
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for 4.4 now that 4.3 is closed)

@@ -73,6 +73,9 @@ public function encodePassword($raw, $salt)
*/
public function isPasswordValid($encoded, $raw, $salt)
{
if ('' === $raw) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a blank line after this one, same below

@fabpot fabpot changed the base branch from 4.3 to 4.4 February 3, 2020 16:30
@fabpot
Copy link
Member

fabpot commented Feb 3, 2020

Thank you @umulmrum.

fabpot added a commit that referenced this pull request Feb 3, 2020
…y implementation) (Stefan Kruppa)

This PR was submitted for the 4.3 branch but it was merged into the 4.4 branch instead (closes #35497).

Discussion
----------

Fail on empty password verification (without warning on any implementation)

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | sort of
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

When using the sodium extension, an empty $raw string will issue a warning during validation, but the standard `password_verify()` does not. This PR aims to provide identical behavior independent of the underlying implementation. Two assumptions were made (please doublecheck if they are correct):
- Empty password is never valid.
- Empty password is not that severe that anybody needs to be informed using a warning or exception.

Commits
-------

4d920f0 Fail on empty password verification (without warning on any implementation)
@fabpot fabpot merged commit 4d920f0 into symfony:4.4 Feb 3, 2020
This was referenced Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants