Problem/Motivation
The experimental "Allow domain-scoped destination redirects" setting (#3570210) sends users back to the domain they came from after an action on another domain. It has two sides:
- Outbound, DomainPathProcessor adds a destination_domain query parameter to cross-domain links that carry a destination. This side checks the setting.
- Inbound, DomainSubscriber turns destination_domain and destination into an absolute destination on that host, when the host passes the trusted host patterns. This side does not check the setting.
So on a site where the setting is off, which is the default, a request with both parameters, like /user/login?destination=/node/1&destination_domain=https://two.example.com, still sends the user to that domain after the action. DomainRedirectResponse only lets the redirect reach a registered domain of the site, so the target is always one of the site's own domains; but with the setting off, the parameter should have no effect at all.
Steps to reproduce
- Leave "Allow domain-scoped destination redirects" off.
- Open /user/login?destination=/node/1&destination_domain=https://two.example.com on one.example.com, two.example.com being another domain of the site.
- Log in: the redirect goes to https://two.example.com/node/1.
Proposed resolution
Process destination_domain in DomainSubscriber only when the setting is on, from the same check as DomainPathProcessor. With the setting off, leave the request as it is: destination keeps its usual same-site meaning.
Remaining tasks
- Merge request with a kernel test that fails before the fix: with the setting off, the destination is not rewritten; with it on, it still is.
- Backport to 3.x and 3.0.x, which have the same code.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
destination_domain is only processed when "Allow domain-scoped destination redirects" is on. Sites that build destination_domain links themselves need that setting.
AI-Generated: Yes (Claude Code drafted this issue from the code of DomainSubscriber, DomainPathProcessor and DomainRedirectResponse. I reviewed it.)
Issue fork domain-3642276
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 #5
mably commentedComment #6
mably commentedComment #10
mably commented