Skip to content

Commit 8e4b29f

Browse files
committed
prefer query_parameters to params for search endpoint
Using params will pull values from the request body (if not present in the query parameters). We shouldn't ever see these in normal use, but somebody could pass them in to poison a cache that only keys on query parameters, not bodies (like Cloudflare). More details in #1551. I'm still unconvinced this would be a problem in practice, since real users would be sending a search parameter in the query string, and that would skip the poisoned entry. But it's easy enough to workaround anyway, so let's do it. It would be nice if there were a more systematic solution here, so we don't end up with a similar problem later. But this site really does very little parameter processing in the first place (this seems to be the only case in the whole code base).
1 parent faf5da5 commit 8e4b29f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/controllers/site_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def index
1111

1212
# called when you start typing into search form
1313
def search
14-
@term = sname = params["search"].to_s.downcase
14+
@term = sname = request.query_parameters["search"].to_s.downcase
1515
@data = search_term(sname)
1616
render partial: "shared/search"
1717
end
1818

1919
# called when you submit your search
2020
def search_results
21-
@term = sname = params["search"].to_s.downcase
21+
@term = sname = request.query_parameters["search"].to_s.downcase
2222
data = search_term(sname, true)
2323
@top = []
2424
@rest = []

0 commit comments

Comments
 (0)