Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Ready for review

96580[TASK] Add check whether a user may read a record

Oli Bartsch CR 0 V 0 Expert +1773 −28 updated 11/18/26, 20:43

Commit message

The core decides at several places whether a backend user may see a
record, and each place checks something else: the clipboard, the
element information, the record history and the live search. An API
that resolves a record by its uid for a backend user needs one check,
and lists and searches need the same rules as a query restriction.

The decision is taken by security voters, so it is the same for every
caller and extensions can restrict it: the internal RecordVoter decides
on isGranted(Scope::READ, new RecordRow($schema, $row)) for the
principal of the request, with the workspace and the webmounts stored
on the token. The table permission is asked from the TableVoter, the
page permission from the PagePermissionEvaluator, as for the PageVoter.
RecordRow is internal, as the subject for reading and writing records
is decided together with the DataHandler rewrite.

The internal RecordReadAccessCheck takes a table and a uid and fetches
the record and its version in the workspace of the token itself. Missing
and deleted records and versions of another workspace are not readable.
A record deleted in the current workspace stays readable, its workspace
state is up to the caller. Otherwise it checks the table permission,
admin only tables and the page of the record the way
BackendUtility::readPageAccess() does: the page must be shown to the
user and lie within a webmount. A record moved in the workspace is
checked on its new page, records on root level require the table to
ignore the root level restriction. A caller that loaded the record
already checks it with checkRecord().

The internal RecordReadAccessRestriction applies the same table and
page rules to a query: tables the user may not select, admin only
tables and tables without TCA yield no records, and records are limited
to pages the user may see within a webmount. A live record moved in the
current workspace is limited by the page of its move pointer. Deleted
records and the workspace selection stay with the existing
restrictions.

The restriction only builds the expression. The internal
RecordReadAccessRestrictionFactory creates it for the principal of the
request and resolves the readable tables, those the voters grant
Scope::READ on, and the readable pages beforehand. Without a backend
principal nothing is readable. The internal
ReadablePageResolver resolves the readable pages from the webmounts
down through pages with show permission, with pages moved in the
current workspace below their new parent, in one recursive query, and
keeps them in the runtime cache.

None of them takes a BackendUserAuthentication object.

The element information and the suggest wizard of FormEngine are the
first users. The element information loads the record once and checks
it. It no longer shows versions of another workspace and records of
admin only tables to users who are no administrators. The suggest
wizard no longer suggests records of tables the user may not select and
records of admin only tables to users who are no administrators, and
records the user may not read no longer take up the result limit of its
query.

Restrictions that apply to editing or display only, such as allowed
languages, authMode or editlock, are not part of the read check. The
other existing checks are not changed by this patch.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 4
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/80/96580/4 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/80/96580/4 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Relation chain 10

  1. main 96664[TASK] Resolve page and record references Based on this change Work in progress Merge conflict Oli Bartsch CR 0 V 0 Expert +1652 −12
  2. main 96661[TASK] Add capability invoker and registry Based on this change Work in progress Merge conflict Oli Bartsch CR 0 V 0 Expert +2379 −0
  3. main 96660[TASK] Derive argument schemas from signatures Based on this change Work in progress Merge conflict Oli Bartsch CR 0 V 0 Expert +1995 −1
  4. main 96582[TASK] Use the record read access check in backend Based on this change Abandoned Oli Bartsch CR 0 V 0 Normal +170 −26
  5. main 96581[TASK] Add query restriction for records a user may read Based on this change Abandoned Oli Bartsch CR 0 V 0 Hard +708 −0
  6. main 96852[TASK] Add check whether a user may read a field Based on this change Merge conflict Oli Bartsch CR 0 V 0 Hard +320 −3
  7. 96580 [TASK] Add check whether a user may read a record This change

  8. main 97323[TASK] Check page access along the cached page ancestry This change is based on it Merge conflict Benni Mack CR 0 V 0 Normal +166 −1
  9. main 97322[FEATURE] Decide page permissions with a security voter This change is based on it Benni Mack CR 0 V 0 Expert +1489 −151
  10. main 95784[FEATURE] Decide table, field and language access with voters This change is based on it Thomas Maroschik CR +1 V +1 unified-identity-security-kernel Expert +1215 −11

Issues 4

Files 17

Review log 711

  1. Oli Bartsch uploaded patch set 1 10/09/26, 20:34

  2. core-ci voted on patch set 1 V +1 10/09/26, 20:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110713

  3. Oli Bartsch uploaded patch set 2 V +1 10/14/26, 06:42

  4. core-ci voted on patch set 2 V +1 10/14/26, 07:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111042

  5. Benni Mack commented on patch set 2 CR -1 10/18/26, 17:09

    ElementInformationController.php:97

    check() already loads the record, its workspace version and the page. One line further down is BackendUtility::getRecordWSOL() for the same record, which loads it again and overlays it with different logic than check(). The !== 'pages' special case at line 100 is unexplained, and the reason from AccessCheckResult is discarded.

    RecordReadAccessRestriction.php:42

    Restrictions in core so far only build expressions. This one walks the page tree, loads move pointers and writes to the runtime cache whenever the SQL is built (RecordReadAccessRestriction.php:76 → getReadablePageIds()). How about: resolve everything before the query is built, and keep the restriction a plain value object: ``` final readonly class RecordReadAccessRestrictionFactory { public function __construct( private ReadablePageResolver $readablePageResolver, private TcaSchemaFactory $tcaSchemaFactory, ) {} public function create(BackendUserAuthentication $backendUser): QueryRestrictionInterface { // admin → no-op restriction; otherwise readable page ids + denied tables } } ``` This way we do not need to have all these makeInstance = hidden dependencies.

    RecordReadAccessRestriction.php:95

    I assume we cannot handle moved records yet?

    RecordReadAccessRestriction.php:209

    this is like a SQL query in a Expression. How about we use a CTE to get subpages with the permissions in mind from a user in a separate service? We could then cache this once and pump into this restriction, this would benefit the whole core.
  6. Oli Bartsch uploaded patch set 3 CR -1 V +1 10/19/26, 07:27

  7. Oli Bartsch commented on patch set 3 10/19/26, 07:36

    ElementInformationController.php:97 Reply

    Loads the record once now (getRecordWSOL()) and checks that row with the new checkRecord(). The pages case keeps the live uid as before. Not showing the reason is intentional: missing and unreadable records should look the same.

    RecordReadAccessRestriction.php:42 Reply

    RecordReadAccessRestrictionFactory resolves everything up front, and the restriction is now a value object.

    RecordReadAccessRestriction.php:95 Reply

    Good catch, that was a bug. Moved records are now restricted by their move pointer, like the check.

    RecordReadAccessRestriction.php:209 Reply

    ReadablePageResolver uses one recursive CTE and caches the result. The IDs still end up as IN(...). If you'd rather have the CTE as a subquery in the restriction, I can switch.
  8. core-ci voted on patch set 3 V +1 10/19/26, 07:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111587

  9. Oli Bartsch commented on patch set 3 10/22/26, 19:59

    RecordReadAccessRestriction.php:209 Reply Unresolved

    @benni@typo3.org how to proceed?
  10. Benni Mack uploaded patch set 4 V +1 11/18/26, 20:33

  11. core-ci voted on patch set 4 V +1 11/18/26, 20:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114922