Skip to content

[Security] bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider #11058

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

Closed

Conversation

glutamatt
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #10242
License MIT

[Security] fixed missing call to UserChecker::checkPreAuth

edit : after the discution with @hellomedia , i replaced postcheck with precheck
glutamatt@e0730e0#commitcomment-6580764

@glutamatt glutamatt changed the title bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider [Security] bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider Jun 4, 2014
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
$userChecker->expects($this->once())
->method('checkPreAuth')
->will($this->throwException(new DisabledException()))
Copy link
Member

Choose a reason for hiding this comment

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

Why does your mock throws an exception, if, then, you do not assert anything?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jeremy-derusse expectation is defined with the @expectedException annotation.

However, I wouldn't use $userChecker->expects($this->once()), but $userChecker->expects($this->any()).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakzal checkPreAuth must be called once in this test, as muche as checkPostAuth in the next test case
I just see that the exeption thrown in the postcheck test is mocked : i will do the same here to be consistent

Copy link
Member

Choose a reason for hiding this comment

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

right, I missed the annotation. sorry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test case is edited to be consistent with postcheck test

Copy link
Contributor

Choose a reason for hiding this comment

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

Acutally, mocking exceptions is not consistent with rest of Symfony. I'd avoid this. See #10621

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix that ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (real exceptions instances are thrown)

@odolbeau
Copy link
Contributor

odolbeau commented Jun 5, 2014

👍

@MattKetmo
Copy link
Contributor

+1 to merge this fix asap (which could be seen as a security issue)

@cvasseur
Copy link

cvasseur commented Jul 1, 2014

+1

@cmodijk
Copy link

cmodijk commented Jul 8, 2014

Any updates on this?

@glutamatt
Copy link
Contributor Author

Nothing :'(

@gredin
Copy link

gredin commented Jul 30, 2014

👍 Fix an issue I had.
Hope it'll be merged soon enough.

@odolbeau
Copy link
Contributor

odolbeau commented Sep 2, 2014

Any update?

@c7nj7n
Copy link

c7nj7n commented Sep 2, 2014

+1

@MattKetmo
Copy link
Contributor

Ping @stof for the review (I don't know who's the best member from the core team in charge of the security component)

I don't think this could be seen as a security issue (well… sort of), but it's could be quite critical in some case and the PR stands for a few month now.

Thanks.

@dschenk
Copy link

dschenk commented Sep 19, 2014

+1

I think its a pretty severe security issue. If a user gets disabled he can still login with the remember-me cookie. If such a user is an admin (and there were certain reasons to disable the account), he can wreak havoc on the system...

@glutamatt glutamatt force-pushed the ticket_10242-rememberme-checkpreauth branch from 30a34b0 to db99801 Compare September 23, 2014 09:17
@glutamatt glutamatt force-pushed the ticket_10242-rememberme-checkpreauth branch from db99801 to 510218f Compare September 23, 2014 09:21
@fabpot
Copy link
Member

fabpot commented Sep 24, 2014

Looks good to me.

@fabpot
Copy link
Member

fabpot commented Sep 24, 2014

Thank you @glutamatt.

fabpot added a commit that referenced this pull request Sep 24, 2014
…AuthenticationProvider (glutamatt)

This PR was submitted for the 2.4 branch but it was merged into the 2.3 branch instead (closes #11058).

Discussion
----------

[Security] bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #10242
| License       | MIT

[Security] fixed missing call to UserChecker::checkPreAuth

edit : after the discution with @hellomedia , i replaced postcheck with precheck
glutamatt@e0730e0#commitcomment-6580764

Commits
-------

a38d1cd bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider
@fabpot fabpot closed this Sep 24, 2014
@@ -50,7 +50,7 @@ public function authenticate(TokenInterface $token)
}

$user = $token->getUser();
$this->userChecker->checkPostAuth($user);
$this->userChecker->checkPreAuth($user);
Copy link
Member

Choose a reason for hiding this comment

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

IMO, adding the preAuth check is good, but postAuth should not be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's something i was thinking about, but i followed this pr : #9902
and prefered to stay consistent with.

postauth check if credentials are fresh enough (if i'm not wrong), i focused on triger critical checks performed by preAuth checks

it's a matter of remeberme feature ... I can't decide this alone

Anyway, thanks for your remark

Copy link
Contributor

Choose a reason for hiding this comment

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

I am the one who suggested @glutamatt to remove it.

As discussed here : glutamatt@e0730e0

PostCheck only checks for credentials expiration. I would think that could - but does not have to - prevent the user from logging in. It could just be a suggestion to change a password after X months.

Maybe I am wrong, but if it should always prevent from loging in, why is there 2 separate checks, pre-check and post-check ? Why not everything in the same global check ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.