Problem/Motivation
In Drupal 9.5.11, the Media Library AJAX pagination used the POST method. In Drupal 10.1.x, it switched to using the GET method.
With multiple pages in the Media Library, the URLs for these pages become longer and longer. Consequently, these lengthy URLs are being blocked by AWS WAF when following the core ruleset https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-g...
---
SizeRestrictions_QUERYSTRING
Inspects for URI query strings that are over 2,048 bytes.
Rule action: Block
Label: awswaf:managed:aws:core-rule-set:SizeRestrictions_QueryString
--
The specific rule causing the block is the "SizeRestrictions_QUERYSTRING" rule, which checks for URI query strings over 2,048 bytes and blocks them accordingly.
This issue is related to
- #3348789: Compress ajax_page_state
- #3380486: Extremely long Views AJAX query string triggers 403 in AWS
Despite applying a patch to compress libraries from #3348789: Compress ajax_page_state, the URL length remains too large. The URL length was reduced from approximately 2600 to 2200 characters, and it still triggers blocks by AWS WAF.
This issue may also be connected to the discussion on allowing AJAX to use GET requests
- #956186: Allow AJAX to use GET requests
Proposed resolution
Wouldn't it be better to handle view ajax pagination with the POST method to avoid such URL length issues altogether?
| Comment | File | Size | Author |
|---|
Issue fork drupal-3421255
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:
- 3421255-pager-with-ajax
changes, plain diff MR !14116
Comments
Comment #2
vesnag commentedComment #3
cilefen commentedCan you verify on 10.2 please?
Comment #4
vesnag commentedWith the clean install of 10.2.3, the Media Library URL may extend beyond 2000 characters when navigating through pages.
Comment #5
longwaveThis isn't a bug in Drupal, just a false positive in the WAF. I've also run into this as I have sites behind AWS WAF and have had to add exceptions for this rule and the media library URLs (as an aside, editing content in Drupal often triggers false positives in other WAF rules such as XSS, this is not a bug either).
There are lots of different resources to refer to here, but the most up to date standard from https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of... says
so Drupal is not technically doing anything wrong here. WAFs are never one-size-fits-all and always need tuning for complex applications.
Comment #6
vesnag commentedAs already reported here https://www.drupal.org/project/drupal/issues/3403077, GET requests also break Varnish.
Comment #7
longwaveWell yes, but that's a separate issue; the AWS WAF does not use Varnish.
Comment #9
johnvBetter title for non-techies, better links tot issues, adding related links
Comment #12
adebruin commentedIt is possible to reproduce this problem by using the media library, especially the pager, in a node edit form when using at least 70+ libraries.
We made an attempt at further reducing the length of the ajax_page_state libraries. For our attempt to work, the theme has to be loaded so we had to move the priority of the ajax_page_state middleware to run only after the pre_handle middleware has already ran.
We made changes to the UrlHelper::compressQueryParameters and UrlHelper::uncompressQueryParameters methods. These methods were not specifically created for only handling ajax_page_state (un)compression but right now they only seem to be used for this. A better solution might be to move the compression to a separate service.
The change we made reduced the size of the libraries token from 900 to about 360 characters which is quite a lot less.
Comment #13
adebruin commentedThis is a patch file of the latest state of the MR for save usage with composer patches.
Comment #14
cilefen commentedWe should consider closing this as a duplicate of #3403077: media_library_opener leads to massive GET requests that break varnish etc..
Comment #15
adebruin commentedThese tickets do seem to want to fix the same issue but with a different approach.
Comment #17
drale01 commentedSame issue
Comment #18
quietone commentedThis was changed to a support request by @longwave who has experienced the same problem. He also pointed out that this issue is about "AWS WAF" which does not use Varnish. Whereas the possible duplicate issue is specifically about Varnish. He also explained what he did to workaround the problem.
Based on the that, this issue can be closed.
I also asked in #bugsmash about this being a duplicate. acbramley replied that this does appear to be a duplicate. Since there are several people that think so I will close this as a duplicate and comment on the other issue that there is an MR here they may wish to review.