Skip to content

CSRF exception for LogoutListener Firewall isn't handled #36814

@davispuh

Description

@davispuh

Symfony version(s) affected: v5.0.8 (and git master)

Description
Currently when you use CSRF validation for logout then when invalid CSRF is submitted HTTP 500 will be returned and exception logged.
But this isn't correct because maybe user has wrong state (in which case we should inform them to refresh token) or even if it's attacker then we don't care about it (it's not server error, so HTTP 500 is wrong) as it's expected behavior.

How to reproduce

In security.yaml

security:
    firewalls:
        main:
            logout:
                path: logout
                csrf_token_generator: security.csrf.token_manager

Then make request to logout with wrong CSRF token.

Possible Solution
In Firewall ExceptionListener there is handleLogoutException it could check if it's CSRF exception and set response to redirect.

Additional context

Log

May 13 23:41:32 |INFO | PHP    A LogoutException was thrown. 
May 13 23:41:32 |ERROR| PHP    Uncaught PHP Exception Symfony\Component\Security\Core\Exception\LogoutException: "Invalid CSRF token." at /mnt/code/proj/vendor/symfony/security-http/Firewall/LogoutListener.php line 89 

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