Install

Works with Drupal: ^10.3 || ^11 || ^12

Using Composer to manage Drupal site dependencies

Alternative installation files

Download tar.gz 144.89 KB
MD5: d5ffb74c83af8f278f61e6130ae15eba
SHA-1: bd59955497f9bb08b159b70d1eb47013643d1858
SHA-256: 27d94e454249fb295ff4562e2b70ee39bc90fa7c1f29f71dc1e4cf2de0aa96e3
Download zip 273.53 KB
MD5: 0d3ed6213e08553e49de0fe35f424e13
SHA-1: 645879255947173e271bbf31ff2060347605ece7
SHA-256: b31d28bd49badd827b1ba7ea8ecdc9d667600bccc28035d5e6c019c5746e9d14

Release notes

Flag action routes now require view access to the flagged entity

What was wrong

The route access checks for Flag's action routes (_flag_access / _unflag_access) only called FlagInterface::actionAccess(). That method checks Flag's own permissions — flag <id> / unflag <id>, the "own / other users' items" configuration and hook_flag_action_access() — but never checked whether the user may view the entity being flagged.

As a result, any user with permission to use a flag could flag or unflag any entity of the flag's entity type by guessing or enumerating IDs: unpublished nodes, other users' private content, and content hidden by node access grants or modules such as Group. Differing responses for existing and missing IDs additionally allowed entity ID enumeration.

What changed

FlagAccessCheck and UnFlagAccessCheck now combine the flag's own action access with the flaggable entity's view access: a user may only flag or unflag an entity they are allowed to view. The check applies to all action routes at once — action links (AJAX/POST and no-JS/GET), the confirm forms and the field entry forms. Requests for non-existent entities still return 404, exactly as before.

Flag's programmatic API (FlagService::flag() / FlagService::unflag()) is unchanged; only route access is affected.

Impact on existing sites

For the vast majority of sites nothing changes: flag links are only rendered where the entity is already viewable, and standard entity types (nodes, users, taxonomy terms, comments, media) return a definitive view access result.

Be aware of the following behavior changes:

  • Entity types with "neutral" view access: if you flag a custom entity type that has no access control handler, no admin permission and no hook_entity_access() implementations, its view access is neutral by default — and neutral combined with an allowed flag permission is no longer sufficient. Such entity types can no longer be flagged through the routes. If this affects you, implement an access handler or a hook_ENTITY_TYPE_access() that returns "allowed" for users who should see the entity. (Allowing neutral results would have kept the vulnerability open for those entity types, so the strict behavior is intentional.)
  • Flags on user accounts now additionally require the access user profiles permission.
  • Unflagging content that became unviewable: users can no longer unflag an entity they are no longer allowed to view (for example, a bookmarked node that was later unpublished). Such flaggings remain in place until the entity becomes viewable again or an administrator resets the flag.
  • hook_flag_action_access() implementations can no longer grant flag access to entities the user cannot view — the view access check always applies.

Contributors (5)

Anybody, anybody, csakiistvan, grevil, ivnish

Changelog

Issues: 3 issues resolved.

Changes since 5.2.1 (compare):

Bug

  • fix: #3638488 Make CSRF Token handling specific to Flag routes
  • fix: #3638525 Prevent unexpected flagging
  • fix: #3638524 Anonymous users personal flaggings are shown to other anonymous users through Views caching
Created by: ivnish
Created on: 16 Nov 2026 at 16:44 UTC
Last updated: 16 Nov 2026 at 16:44 UTC
Bug fixes

Other releases