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

[Security] Fix UserNotFoundException is not thrown #45452

Merged
merged 1 commit into from Mar 27, 2022
Merged

Conversation

damienfa
Copy link
Contributor

@damienfa damienfa commented Feb 17, 2022

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #45070
License MIT
Doc PR N/A

@damienfa damienfa requested review from wouterj and chalasr as code owners Feb 17, 2022
@carsonbot carsonbot added this to the 6.1 milestone Feb 17, 2022
@carsonbot carsonbot changed the title Fix #45070 : UserNotFoundException is not thrown [Security] Fix #45070 : UserNotFoundException is not thrown Feb 17, 2022
@nicolas-grekas nicolas-grekas changed the title [Security] Fix #45070 : UserNotFoundException is not thrown [Security] Fix UserNotFoundException is not thrown Feb 17, 2022
@carsonbot
Copy link

@carsonbot carsonbot commented Feb 17, 2022

Hey!

I think @IonBazan has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Can you please rebase to target 5.4, and add a test case?

@@ -66,6 +67,13 @@ public function getUser(): UserInterface
}

$user = ($this->userLoader)($this->userIdentifier);

// No user has been found via the $this->userLoader callback.
if (is_null($user)) {
Copy link
Member

@nicolas-grekas nicolas-grekas Feb 18, 2022

Choose a reason for hiding this comment

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

if (null === $user) {

@nicolas-grekas nicolas-grekas removed this from the 6.1 milestone Feb 18, 2022
@nicolas-grekas nicolas-grekas added this to the 5.4 milestone Feb 18, 2022
@nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Feb 21, 2022

Can you please add a test case, and rebase + target 5.4 also?

@kaznovac
Copy link
Contributor

@kaznovac kaznovac commented Feb 23, 2022

don't have time to thoroughly check the pr and how does the UserNotFoundException propagate, pay attention not to reintroduce the user enumeration
also take in consideration the hideUserNotFoundExceptions parameter

@fabpot
Copy link
Member

@fabpot fabpot commented Mar 26, 2022

@wouterj Can you have a look at this PR?

Copy link
Member

@wouterj wouterj left a comment

With the suggested CS changes, this change looks good to me (for 5.4+).

This code is within the user enumeration control of the authenticator manager - so nothing to worry about concerning that.

if (is_null($user)) {
($exception = new UserNotFoundException())->setUserIdentifier($this->userIdentifier);
throw $exception;
Copy link
Member

@wouterj wouterj Mar 26, 2022

Choose a reason for hiding this comment

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

Suggested change
if (is_null($user)) {
($exception = new UserNotFoundException())->setUserIdentifier($this->userIdentifier);
throw $exception;
if (null === $user) {
$exception = new UserNotFoundException();
$exception->setUserIdentifier($this->userIdentifier);
throw $exception;

Copy link
Member

@chalasr chalasr left a comment

Once CS issues have been adressed

fabpot
fabpot approved these changes Mar 27, 2022
@fabpot
Copy link
Member

@fabpot fabpot commented Mar 27, 2022

Thank you @damienfa.

@fabpot fabpot merged commit e6e7efd into symfony:6.1 Mar 27, 2022
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants