Affected versions

Symfony Security Core versions >=5.4, <5.4.57, >=6, <6.4.51, >=7, <7.4.24, >=8, <8.1.12 are affected by this security issue.

The issue has been fixed in Symfony Security Core 5.4.57, 6.4.51, 7.4.24, 8.1.12.

Description

With the unanimous access decision strategy, an access_control rule that lists several roles requires all of them. That's the behavior restored by the fix for CVE-2020-5275. Since Symfony 5.4, the access decision manager asked each voter once about all the attributes of a rule. RoleVoter grants access as soon as the user has one of the roles. So a user who had only one of these roles was granted access:

1
2
3
4
5
security:
    access_decision_manager:
        strategy: unanimous
    access_control:
        - { path: ^/admin, roles: [ROLE_ADMIN, ROLE_AUDITOR] }

Only attributes decided by the same voter were affected. For example, a role combined with allow_if still required both.

Resolution

With the unanimous strategy, voters are asked about each attribute separately again, as before Symfony 5.4. Access is denied as soon as one of the attributes is denied.

The patches for this issue are available here for branch 5.4 (and forward-ported to 6.4, 7.4, 8.1 and 8.2).

Credits

We would like to thank Jack Worman for reporting the issue and providing the fix.