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

CommentFileSizeAuthor
#16 3489155-without-tests.patch615 bytessleitner
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

sleitner created an issue. See original summary.

sleitner’s picture

Status: Active » Needs review
scott_euser’s picture

Status: Needs review » Needs work

Thanks 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']);
```

sleitner’s picture

Status: Needs work » Needs review

The value of $json is null

scott_euser’s picture

And 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

sleitner’s picture

Issue summary: View changes
sleitner’s picture

Issue summary: View changes
sleitner’s picture

Issue summary: View changes
sleitner’s picture

Issue summary: View changes
sleitner’s picture

Someone 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 null or int is not specified in the interface of ViewsReferenceCompressionInterface as a valid return value
public function uncompress(array $viewsreference, ViewExecutable $view): array;
Therefor a TypeError error is thrown and causes a php error in the drupal log /admin/reports/dblog and an error in the apache error logs

scott_euser’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the details and patience helping me understand. Added test coverage that fails without the code change + passes with the code change. Thank you!

scott_euser’s picture

Status: Reviewed & tested by the community » Fixed

  • scott_euser committed 1b512665 on 8.x-2.x authored by sleitner
    Issue #3489155 by sleitner, scott_euser: uncompress(): Return value must...
weseze’s picture

Can 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.

sleitner’s picture

StatusFileSize
new615 bytes
scott_euser’s picture

Status: Reviewed & tested by the community » Fixed

Oddly this was stuck in rtbc, moving to fixed since was committed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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