Opened 16 hours ago
Last modified 55 minutes ago
#66662 assigned defect (bug)
Random content redirect should not combine with search (?s=…&random)
| Reported by: | ReneHermi | Owned by: | jorbin |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Rewrite Rules | Version: | trunk |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
The random content redirect added in 7.2 (/random/ and ?random) also works together with a search query. /?s=WORD&random redirects to a random post that matches WORD, and returns a 404 when nothing matches.
This mixes two features in a way that is hard to predict. It also turns search into a yes/no answer for each search term, even where search results themselves would not be shown, for example on sites behind a login plugin (see #66661).
Steps to reproduce (7.2-beta4-65283, logged out):
- Publish a post with the word "Zebrafinqx" in its title.
- Request
/?s=Zebrafinqx&random: you get a 302 to that post. - Request
/?s=qqqzzznothere&random: you get a 404.
Expected: random and a search query do not act at the same time. Suggested fix, as discussed with the security team: ignore random when the request is a search (or skip the search when random is set), so that ?s=…&random behaves like a normal search.
Related: #66625 (caching headers for the random redirect).
This was first sent to security@…. The team decided it does not need a private fix and asked for a public ticket.
Change History (5)
#3
in reply to: ↑ description
;
follow-up:
↓ 4
@
5 hours ago
#4
in reply to: ↑ 3
@
4 hours ago
Replying to manfcarlo:
I have been of the view for some time that the random redirects should use nonce verification, which would address this and many of the other issues reported.
Every logged out visitor gets the same nonce for the same action, so this won't provide any protection. Additionally, /random/ is a URL that folks link to, bookmark and type. A nonce turns it into a link that only works when Core generated it in the 24 hours which would break the feature.
This ticket was mentioned in PR #15916 on WordPress/wordpress-develop by @jorbin.
55 minutes ago
#5
- Keywords has-patch has-unit-tests added
A search request that includes the random query variable redirected to a matching post or returned a 404, which revealed whether any post matched the search terms. Search requests are no longer random content requests. Instead they are redirected to the same search without the random query variable or the random base, before the main query is run.
The redirect retains the requested path and the other query string parameters, URL-encodes parameter names as well as values, and is skipped when the location would be the requested URL.
Requests for robots.txt, the favicon, sitemaps, feeds and trackbacks now ignore the random query variable, they are neither random content requests nor redirected.
Use of AI Tools
Example disclosure:
AI assistance: Yes
Tool(s): Claude
Model(s): Fabel 5.2
Used for: Code Generation, Code Review, Risk Analysis
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Replying to ReneHermi:
This seems like an important point. Themes have the ability to omit the query loop or synthesise its results in some way, while this feature overrules the theme by "revealing" one of the posts that would have been shown. Example:
I have been of the view for some time that the random redirects should use nonce verification, which would address this and many of the other issues reported. Better yet, scrap the feature owing to its near-zero level of community support.