Issue Bug Under Review

#111699Backend user aspect points to another user after fetchGroupData()

Matthias Vogel 12/02/26, 06:24 updated 12/02/26, 06:26

Description

Symptom

When BackendUserAuthentication::fetchGroupData() runs for a user who is not the backend user of the current request, the Context aspect backend.user points to that other user afterwards. $GLOBALS['BE_USER'] still is the logged-in backend user.

All code that reads the aspect later in the same request uses the wrong user, for example page TSconfig conditions like [backend.user.isAdmin] or [backend.user.userGroupIds ...], PageRenderer and ExtbaseHistoryTracker.

Steps to reproduce

Backend Users module:

  1. Log in as a backend user.
  2. Open the “Backend Users” module.
  3. Open the detail view of another user (or compare two users, or open the detail view of a group).
  4. After the module loaded the other user, GeneralUtility::makeInstance(Context::class)->getAspect('backend.user')->get('id') returns the uid of the other user (or PHP_INT_MAX for the dummy user of the group view), not the uid of the logged-in user.

EXT:reactions:

  1. Create a “create record” reaction that impersonates a user.
  2. Run the dry run of the reaction in the backend.
  3. After the dry run, the backend.user aspect points to the impersonated user. $GLOBALS['BE_USER'] is restored correctly.

Cause

The fix for #92516 (also released in 14.3.8) sets the backend.user aspect to the parsed user in fetchGroupData(), right before prepareUserTsConfig(). This is necessary, because user TSconfig conditions are evaluated against this aspect. But the aspect is not restored after the parsing.

For the real login this has no effect, because the authentication middlewares and initializeBackendLogin() set the aspect for the same user afterwards. For callers that load another user (UserInformationService::getUserInformation(), UserInformationService::getGroupInformation(), CreateRecordDryRun), the aspect stays on that other user.

Proposed fix

Keep the aspect of the parsed user only while the user TSconfig is parsed, and restore the previous aspect after that (try / finally around prepareUserTsConfig()). User TSconfig conditions still match the parsed user. CommandLineUserAuthentication::authenticate() then sets the aspect for the _cli_ user itself, so the command line keeps its current behaviour.

Reviews 1

History 12

  1. Matthias Vogel changed Related to #92516 12/02/26, 06:24

  2. Gerrit Code Review pushed patch set 1 for main to change 98272 status New Under Review 12/02/26, 06:26