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
Users: API token replaced by a simple GET request (no CSRF token) #115
The "generateToken" action of the users (edit page) replaces the API token of a user on a simple GET request (/process/user/{id}/generate-token, route methods GET|POST), without CSRF token nor confirmation. An admin following a forged link (image, link in an email…) unknowingly replaces the token of a user: the previous token stops working (HTTP integrations broken). The new token is only displayed to the admin (flash message), so there is no token leak: the impact is a denial of service of the integrations.
The token is also generated with md5(uniqid(date('YmdHis'))), which is predictable (based on the time).
Reproduction
Logged in as an admin, GET /process/user/<id>/generate-token
The token of the user is replaced (302 to the edit page, new token in the flash message)
Expected: the token is only replaced by a POST request with a valid CSRF token, after confirmation.
Tested on main (e298007) in process-bundle-demo: PHP 8.5, Symfony 7.4, EasyAdmin 5.
Cause
UserCrudController: linkToCrudAction('generateToken') (link), #[AdminRoute] without methods, no CSRF check.
Proposed fix
action rendered as a POST form (renderAsForm()) with a confirmation, URL with a CSRF token per user
route restricted to POST, CSRF token checked (403 otherwise)
token generated with random_bytes()
Requirements
Documentation updates
Reference
Changelog
Unit tests
Breaking changes
The direct GET /process/user/{id}/generate-token URL no longer works (405): the token is generated from the button of the user edit page. Upgrade note in UPGRADE.md v4.0.
Activity