8000 security #23507 [Security] validate empty passwords again (xabbuh) · symfony/symfony@559ccb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 559ccb2

Browse files
committed
security #23507 [Security] validate empty passwords again (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [Security] validate empty passwords again | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23341 (comment) | License | MIT | Doc PR | It looks like this part of #23341 causes serious security issues for some users who rely on the validator to also compare the empty string with their user's password (see for example #23341 (comment)). Thus I suggest to revert this part of #23341. Commits ------- 878198c [Security] validate empty passwords again
2 parents 01cb493 + 878198c commit 559ccb2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,29 @@ public function testPasswordIsNotValid()
9090
->assertRaised();
9191
}
9292

93+
/**
94+
* @dataProvider emptyPasswordData
95+
*/
96+
public function testEmptyPasswordsAreNotValid($password)
97+
{
98+
$constraint = new UserPassword(array(
99+
'message' => 'myMessage',
100+
));
101+
102+
$this->validator->validate($password, $constraint);
103+
104+
$this->buildViolation('myMessage')
105+
->assertRaised();
106+
}
107+
108+
public function emptyPasswordData()
109+
{
110+
return array(
111+
array(null),
112+
array(''),
113+
);
114+
}
115+
93116
/**
94117
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
95118
*/

src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function validate($password, Constraint $constraint)
4040
}
4141

4242
if (null === $password || '' === $password) {
43+
$this->context->addViolation($constraint->message);
44+
4345
return;
4446
}
4547

0 commit comments

Comments
 (0)
0