You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Login form and logout not protected against CSRF #93
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
Open /process/login: the form has no _csrf_token field
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).
LoginController: no csrf_token_intention, so the EasyAdmin login template does not render the _csrf_token field
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
#93 Protect the login form against CSRF
#93 Protect the logout against CSRF
[-]Login form not protected against CSRF[/-][+]Login form and logout not protected against CSRF[/+]