Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Security] Fix infinite loop when token storage has no token #37314

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

Conversation

l-vo
Copy link
Contributor

@l-vo l-vo commented Jun 16, 2020

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

When token storage is empty (anonymous not enabled in the config of the fullstack framework) and when we try to access to a page covered by an access control rule, an infinite loop is triggered:

  • AccessListener throws an AuthenticationException because TokenStorage has no token
  • ExceptionListener intercept the exception and redirects to the login page
  • AccessListener catches the request and throws an AuthenticationException because TokenStorage has no token etc...

This PR aims to fix that behavior.

@derrabus
Copy link
Member

(anonymous not enabled in the config of the fullstack framework)

ExceptionListener intercept the exception and redirects to the login page

How do you render a login page without allowing anonymous access?

@l-vo
Copy link
Contributor Author

l-vo commented Jun 18, 2020

Any problem to render a login page occurs only if the login page is covered by a security rule (voter, access_control...) isn't it ?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jun 18, 2020

I fear this change will break the behavior of apps that expect the session to be started when an access listener is enabled.

@wouterj
Copy link
Member

wouterj commented Jun 18, 2020

I'm not totally sure what the changes of this PR result in (I can't test it atm), so please ignore me if I'm understanding it completely wrong😅. If this PR means that the only routes that are secured are the ones behind an access_control, I'm not in favor of the changes. Security is such a sensitive thing that I consider implicitly protecting all paths is better than implicitly making all paths public. Also, changing it can be considered a BC break as there probably are apps relying on implicitly protecting all paths.

@l-vo
Copy link
Contributor Author

l-vo commented Jun 20, 2020

@nicolas-grekas I'm not sure to get the use-case. This change should only affect configurations where anonymous mode is disabled (but maybe I miss something). Is there other cases where AccessListener may be executed with token to null in token storage ?

@wouterj I'm agree with your thoughts and indeed if this PR breaks the current behavior, it should be closed. But (as far as I understand) the authentication mechanism (triggered by AuthenticationCredentialsNotFoundException) only occurs when there is no token in token storage. And if my tests are right, it currently doesn't work (infinite loop). In regular configurations (with anonymous mode enabled), token storage should have an AnonymousToken.

But maybe I miss an important part of how the component work. In that case your knowledge on this is very welcome :)))

@nicolas-grekas
Copy link
Member

I don't think this PR is correct. I did a similar change in #37314, and it was reverted in #34358 to fix #34357. See #34358 (comment)

Closing therefor. Dunno about the infinite loop (it's a configuration issue in the first place, isn't it?)

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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.