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

  1. Leave "Allow domain-scoped destination redirects" off.
  2. 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.
  3. 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

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

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review
mably’s picture

Issue summary: View changes
Priority: Normal » Minor

  • mably committed 7c4870f9 on 4.x
    fix: #3642276 Process destination_domain only when domain-scoped...

  • mably committed 8abee63f on 3.x
    fix: #3642276 Process destination_domain only when domain-scoped...

  • mably committed 4d61dda3 on 3.0.x
    fix: #3642276 Process destination_domain only when domain-scoped...
mably’s picture

Status: Needs review » Fixed

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.