Problem/Motivation

This is a spin-off issue of #2973356: Cacheability information from route access checker access results are ignored by dynamic_page_cache where as part of the review, @kristiaanvde's spidey senses identified an incorrect cacheability information definition in the access result returned by the UserAccessControlHandler that could lead to unexpected scenarios (like access loss) when access results returned by route access checkers finally get considered by Dynamic Page Cache module.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3452426

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mxr576 created an issue. See original summary.

mxr576’s picture

Title: Insufficient cacheability information in UserAccessControlHandler » Insufficient cacheability information bubbled up by UserAccessControlHandler
Assigned: Unassigned » mxr576
Related issues: +#2973356: Cacheability information from route access checker access results are ignored by dynamic_page_cache

I'll submit a patch for this later today.

kristiaanvandeneynde’s picture

If the intent was to manually optimize 'user.permissions' into 'user', don't. VariationCache needs all of the cache contexts, even if they will eventually be optimized away because, during said optimization (cache context folding), extra cache tags might surface that need to be added to the cache entry.

So in this case, the first if-statement can vary by user.permissions, the second by ['user', 'user.permissions'] and the third one too. Again, do not manually optimize this, you're introducing bugs and potential security issues.

mxr576’s picture

Status: Active » Needs review

mxr576 changed the visibility of the branch 3452426-insufficient-cacheability-information-with-accessresult-orif to hidden.

kristiaanvandeneynde’s picture

Changes look great, would RTBC but I think we should explain why the seemingly unrelated tests were changed. If you could add a few notes with your findings there, then all good to me.

mxr576’s picture

why the seemingly unrelated tests were changed. If you could add a few notes with your findings there, then all good to me.

I double checked it and I haven't found any unrelated tests, those are test base classes that used by the user related REST/JSONAPI endpoint tests.

kristiaanvandeneynde’s picture

Sorry I should have been more specific: Test code that shouldn't at first sight have been affected.

if ($sparse_fieldset === NULL || !empty(array_intersect(['mail', 'display_name'], $sparse_fieldset))) {

Could you briefly explain why this is needed now?

Could you also elaborate on the mitigating lines? Why weren't they needed before and are they now?

What about the fix you copied from REST?

mxr576’s picture

What about the fix you copied from REST

I assume you were referring to this one, which was copied from JSONAPI: https://git.drupalcode.org/project/drupal/-/merge_requests/8285#note_321681

It seems there are no tests in REST - which concerns me - that would have hit the simple "let's normalize user.permission user to user" requirement so far.

kristiaanvandeneynde’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good to me.

  • catch committed 90baffa4 on 10.3.x
    Issue #3452426 by mxr576, kristiaanvandeneynde: Insufficient...

  • catch committed 2844276e on 10.4.x
    Issue #3452426 by mxr576, kristiaanvandeneynde: Insufficient...

  • catch committed a3647bff on 11.0.x
    Issue #3452426 by mxr576, kristiaanvandeneynde: Insufficient...

  • catch committed 9fc1bc9a on 11.x
    Issue #3452426 by mxr576, kristiaanvandeneynde: Insufficient...
catch’s picture

Version: 11.0.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Looks good to me too, both the actual fixes and trying to keep the scope appropriate vs. the other pre-existing and newly opened issues. Also thanks for the annotations on the MR for the test changes, I probably would have asked about at least one so saved a round trip of issue statuses.

Committed/pushed to 11.x, cherry-picked to 11.0.x, 10.4.x, 10.3.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.