Repository navigation
Build occurrence pagination links from page and items only - #99
Merged
fractaledmind merged 1 commit intoOct 13, 2026
Merged
Conversation
The links merged every request param into url_for. url_for reads keys like script_name, original_script_name, host and protocol as URL options, so a crafted link to an error page could make the pagination links point to another host or to a javascript: URL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The occurrence pagination links on the error page are built with
url_for(params.to_unsafe_hash.merge(page: ...)). That passes every request param tourl_for, andurl_forreads some keys as URL options, not as query params:script_name,original_script_name,host,protocol,port,anchor, etc.So a crafted link to an error page changes where the First / Previous / Next / Last links go:
A user who opens such a link and clicks a pagination link runs the script in the app's origin, or goes to another host. This is the same class of issue as Kaminari's CVE-2020-11082.
Fix
The page only reads
pageanditems, so the links are now built from those two values only:When there is no
itemsparam, the link has onlypage, the same as before.Tests
There were no request tests yet, so this mounts the engine in the dummy app and adds
test/controllers/solid_errors/errors_controller_test.rb:itemsparamitemsparamscript_name,original_script_name,host,protocol,portandanchorfrom the requestWithout the fix, the last test fails with
https://evil.example:6666javascript:alert(1)//javascript:alert(1)//1?items=1&page=2#x. The first two pass with and without the fix.bundle exec rake(tests + standard) passes.