Problem/Motivation
the error TypeError: Drupal\viewsreference\ViewsReferenceCompression::uncompress(): Return value must be of type array, int returned in Drupal\viewsreference\ViewsReferenceCompression->uncompress() (line 39 in /wwwdoc/web/modules/contrib/viewsreference/src/ViewsReferenceCompression.php). is thrown when someone provides a non compressed query string
Steps to reproduce
GET parameter e.g. https://www.website.com/node-with-viewsreference?page=1&viewsreference%5Bcompressed%5D=-1/%2A%2A/OR/%2A%2A/1%3D1%29/%2A%2A/AND/%2A%2A/COALESCE%28ASCII%28SUBSTR%28CAST%28%28VERSION%28%29%29AS/%2A%2A/VARCHAR%288000%29%29%2C1%2C1%29%29%2C0%29%3E255
Proposed resolution
return an empty array instead of null or int or raise an error
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3489155-without-tests.patch | 615 bytes | sleitner |
Issue fork viewsreference-3489155
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
Comment #3
sleitner commentedComment #4
scott_euser commentedThanks for raising! I think I might need more steps to reproduce that; it seems like the proposed MR is masking a problem uncompressing the stored data?
What is the value from this $json here? (ie, just before the code you are adding).
```
$json = UrlHelper::uncompressQueryParameter($viewsreference['compressed']);
```
Comment #5
sleitner commentedThe value of
$jsonisnullComment #6
scott_euser commentedAnd steps to reproduce please. Need to understand why compress/uncompress isn't working for you. Is it compressing null in the first place or is it failing to uncompress. Your link in steps to reproduce isn't sufficient to actually reproduce
Comment #7
sleitner commentedComment #8
sleitner commentedComment #9
sleitner commentedComment #10
sleitner commentedComment #11
sleitner commentedSomeone who tries many SQL injections on my website causes hundreds of errors in the logs.
The viewsreference[compressed] URL parameter is not compressed and not JSON.
PHP Version is 8.2.25
Since
nullorintis not specified in the interface ofViewsReferenceCompressionInterfaceas a valid return valuepublic function uncompress(array $viewsreference, ViewExecutable $view): array;Therefor a TypeError error is thrown and causes a php error in the drupal log
/admin/reports/dblogand an error in the apache error logsComment #12
scott_euser commentedThanks for the details and patience helping me understand. Added test coverage that fails without the code change + passes with the code change. Thank you!
Comment #13
scott_euser commentedComment #15
weseze commentedCan we get a new release for this?
Also experienced this issue where dozens of errors are being logged from malicious requests. These causes unnecessary load on our infrastructure.
Comment #16
sleitner commentedComment #17
scott_euser commentedOddly this was stuck in rtbc, moving to fixed since was committed