Skip to content

Session lost due to concurrent requests with "Remember Me" #28314

@darnel

Description

@darnel

Symfony version(s) affected: 4.1.3

Description

When using "Remember me" functionality, session is regenerated with every request. Due to concurrent requests done by browser session is effectively lost which leads to e.g. CSRF token mismatch.

Authentication is kept, user is still logged in (because of Remember me), but the session is lost.

In \Symfony\Component\Security\Http\Firewall\RememberMeListener::handle:87 following method is called \Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy::onAuthentication. With default session strategy migrate it leads to calling session_regenerate_id($destroy = true) in every request. Session ID is changed A->B with main request. For other requests done by browser session ID is B, but changed B->C, B->D etc.

How to reproduce

  • use "Remember me" functionality
  • login e.g using form
  • make HTTP request, which makes browser request other resources responded by controller (not assets)
  • you can check session ID changes every request and Cookie/Set-Cookie HTTP headers is set sent accordingly.

fragment from config/packages/security.yaml

            remember_me:
                secret: '%kernel.secret%'
                lifetime: 34128000
                #                secure: true
                always_remember_me: true
                user_provider: entity.user_account.email

Possible Solution

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy