Skip to content

Login form and logout not protected against CSRF #93

Open

Description

@njoubert-cleverage

Description

The login form of the UI is not protected against CSRF: the form_login configuration prepended by the bundle does not set enable_csrf (default false), and LoginController does not pass csrf_token_intention to the login template (no _csrf_token field in the page). A third-party site can submit the login form of the UI on behalf of a visitor (login CSRF: the visitor ends up authenticated with the attacker's account).

The logout has the same issue (audit point C5, merged into this issue): logout.enable_csrf is not set, so GET /process/logout logs out any visitor (forced logout from a third-party site, e.g. an <img> tag).

Reproduction

  1. Open /process/login: the form has no _csrf_token field
  2. POST /process/login with only _username / _password (no token, e.g. from another origin): the user is authenticated

Expected: the login form carries a CSRF token, a login request without a valid token is rejected (Invalid CSRF token.).

Tested on main (9471168), cleverage/process-bundle 5.1, PHP 8.5, Symfony 8.1 (test application of the bundle) and in process-bundle-demo (PHP 8.5, Symfony 7.4, EasyAdmin 5).

Cause

Proposed fix

  • prepend enable_csrf: true (token id authenticate, parameter _csrf_token: the form_login defaults, also used by the EasyAdmin template)
  • pass csrf_token_intention: authenticate to the login template
  • prepend logout.enable_csrf: true (token id logout): the EasyAdmin logout link (LogoutUrlGenerator) carries the token
  • declare symfony/security-csrf (currently only installed as a transitive dependency)
  • document it (reference, upgrade note)

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

Applications that override the login template without the _csrf_token field, or that submit the login form without it, must add it (or set enable_csrf: false on their main firewall). The Symfony CSRF protection must be enabled (framework.csrf_protection, enabled by default when the session is).

Activity

  1. added
    bugSomething isn't working
    enhancementNew feature or request
    and removed
    bugSomething isn't working
    on Oct 5, 2026
  2. added this to the v4.0 milestone on Oct 5, 2026
  3. added 2 commits that reference this issue on Oct 5, 2026
  4. changed the title [-]Login form not protected against CSRF[/-] [+]Login form and logout not protected against CSRF[/+] on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions