Skip to content

Sylius has an Open Redirect via Referer Header

Moderate severity GitHub Reviewed Published Mar 9, 2026 in Sylius/Sylius • Updated Mar 11, 2026

Package

composer sylius/sylius (Composer)

Affected versions

<= 1.9.11
>= 1.10.0, <= 1.10.15
>= 1.11.0, <= 1.11.16
>= 1.12.0, <= 1.12.22
>= 1.13.0, <= 1.13.14
>= 1.14.0, <= 1.14.17
>= 2.0.0, <= 2.0.15
>= 2.1.0, <= 2.1.11
>= 2.2.0, <= 2.2.2

Patched versions

1.9.12
1.10.16
1.11.17
1.12.23
1.13.15
1.14.18
2.0.16
2.1.12
2.2.3

Description

Impact

CurrencySwitchController::switchAction(), ImpersonateUserController::impersonateAction() and StorageBasedLocaleSwitcher::handle() use the HTTP Referer header directly when redirecting.

The attack requires the victim to click a legitimate application link placed on an attacker-controlled page. The browser automatically sends the attacker's site as the Referer, and the application redirects back to it. This can be used for phishing or credential theft, as the redirect originates from a trusted domain.

The severity varies by endpoint; public endpoints require no authentication and are trivially exploitable, while admin-only endpoints require an authenticated session but remain vulnerable if an admin follows a link from an external source such as email or chat.

Affected classes:

  • CurrencySwitchController::switchAction() - public
  • StorageBasedLocaleSwitcher::handle() - public, used in locale switching without having locale in the url
  • ImpersonateUserController::impersonateAction() - admin-only

Patches

The issue is fixed in versions: 1.9.12, 1.10.16, 1.11.17, 1.12.23, 1.13.15, 1.14.18, 2.0.16, 2.1.12, 2.2.3 and above.

Workarounds

If you cannot update Sylius immediately, copy the affected classes from vendor to your project's src/ directory, apply the fix, and override the service definitions.

Step 1 - CurrencySwitchController

Copy from vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Controller/CurrencySwitchController.php to src/Controller/CurrencySwitchController.php and apply the following changes:

-namespace Sylius\Bundle\ShopBundle\Controller;
+namespace App\Controller;

 use Sylius\Component\Channel\Context\ChannelContextInterface;
 use Sylius\Component\Core\Currency\CurrencyStorageInterface;
 use Sylius\Component\Core\Model\ChannelInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\RouterInterface;

 final class CurrencySwitchController
 {
     public function __construct(
         private Environment $templatingEngine, // for 1.x version
         private CurrencyStorageInterface $currencyStorage,
         private ChannelContextInterface $channelContext,
+        private RouterInterface $router,
     ) {
     }

     public function switchAction(Request $request, string $code): Response
     {
         /** @var ChannelInterface $channel */
         $channel = $this->channelContext->getChannel();

         $this->currencyStorage->set($channel, $code);

-        return new RedirectResponse($request->headers->get('referer', $request->getSchemeAndHttpHost()));
+        return new RedirectResponse($this->router->generate('sylius_shop_homepage'));
     }
 }

Step 2 - ImpersonateUserController

Copy from vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Controller/ImpersonateUserController.php to src/Controller/Admin/ImpersonateUserController.php and apply the following changes:

-namespace Sylius\Bundle\AdminBundle\Controller;
+namespace App\Controller\Admin;

 // ... (keep all existing use statements)

     public function impersonateAction(Request $request, string $username): Response
     {
         // ... (keep authorization check and impersonation logic)

         $this->addFlash($request, $username);

-        $redirectUrl = $request->headers->get(
-            'referer',
+        return new RedirectResponse(
             $this->router->generate('sylius_admin_customer_show', ['id' => $user->getId()])
         );
-
-        return new RedirectResponse($redirectUrl);
     }

Step 3 - StorageBasedLocaleSwitcher (only if you use locale_switcher: storage)

Note: Skip this step if you use the default locale_switcher: url mode.

Copy from vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Locale/StorageBasedLocaleSwitcher.php to src/Locale/StorageBasedLocaleSwitcher.php and apply the following changes:

For Sylius 1.9 – 2.1.2:

-namespace Sylius\Bundle\ShopBundle\Locale;
+namespace App\Locale;

 use Sylius\Bundle\ShopBundle\Locale\LocaleSwitcherInterface;
 use Sylius\Component\Channel\Context\ChannelContextInterface;
 use Sylius\Component\Core\Locale\LocaleStorageInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\RouterInterface;

 final class StorageBasedLocaleSwitcher implements LocaleSwitcherInterface
 {
     public function __construct(
         private LocaleStorageInterface $localeStorage,
         private ChannelContextInterface $channelContext,
+        private RouterInterface $router,
     ) {
     }

     public function handle(Request $request, string $localeCode): RedirectResponse
     {
         $this->localeStorage->set($this->channelContext->getChannel(), $localeCode);

-        return new RedirectResponse($request->headers->get('referer', $request->getSchemeAndHttpHost()));
+        return new RedirectResponse($this->router->generate('sylius_shop_homepage'));
     }
 }

For Sylius 2.1.3 and later:

In Sylius 2.1.3 the class was refactored to use UrlMatcherInterface. While this adds partial validation, it still passes the full referer URL to RedirectResponse, so the open redirect remains exploitable.

-namespace Sylius\Bundle\ShopBundle\Locale;
+namespace App\Locale;

 use Sylius\Bundle\ShopBundle\Locale\LocaleSwitcherInterface;
 use Sylius\Component\Channel\Context\ChannelContextInterface;
 use Sylius\Component\Core\Locale\LocaleStorageInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Routing\Exception\ResourceNotFoundException;
-use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
+use Symfony\Component\Routing\RouterInterface;

 final class StorageBasedLocaleSwitcher implements LocaleSwitcherInterface
 {
     public function __construct(
         private LocaleStorageInterface $localeStorage,
         private ChannelContextInterface $channelContext,
-        private ?UrlMatcherInterface $urlMatcher = null,
+        private RouterInterface $router,
     ) {
-        if (null === $this->urlMatcher) {
-            trigger_deprecation(
-                'sylius/shop-bundle',
-                '2.1',
-                'Not passing a "%s" to "%s" is deprecated and will be required in Sylius 3.0.',
-                UrlMatcherInterface::class,
-                self::class,
-            );
-        }
     }

     public function handle(Request $request, string $localeCode): RedirectResponse
     {
         $this->localeStorage->set($this->channelContext->getChannel(), $localeCode);
-        $url = $request->headers->get('referer', $request->getSchemeAndHttpHost());
-
-        if ($this->urlMatcher) {
-            try {
-                $this->urlMatcher->match($url);
-            } catch (ResourceNotFoundException) {
-                return new RedirectResponse($request->getSchemeAndHttpHost());
-            }
-        }
-
-        return new RedirectResponse($url);
+        return new RedirectResponse($this->router->generate('sylius_shop_homepage'));
     }
 }

Step 4 - Override the services

Add to config/services.yaml.

Sylius 1.x (1.9 – 1.14):

services:
    # ... your existing services ...

    sylius.controller.shop.currency_switch:
        class: App\Controller\CurrencySwitchController
        public: true
        arguments:
            $templatingEngine: '@twig'
            $currencyStorage: '@sylius.storage.currency'
            $channelContext: '@sylius.context.channel'
            $router: '@router'

    sylius.controller.shop.impersonate_user:
        class: App\Controller\Admin\ImpersonateUserController
        public: true
        arguments:
            $impersonator: '@sylius.admin.security.user_impersonator'
            $authorizationChecker: '@security.authorization_checker'
            $userProvider: '@sylius.admin_user_provider.email_or_name_based'
            $router: '@router'
            $authorizationRole: 'ROLE_ADMINISTRATION_ACCESS'

    # Only if you use locale_switcher: storage
    sylius.shop.locale_switcher:
        class: App\Locale\StorageBasedLocaleSwitcher
        public: false
        arguments:
            $localeStorage: '@sylius.storage.locale'
            $channelContext: '@sylius.context.channel'
            $router: '@router'

Sylius 2.x (2.0 – 2.1):

services:
    # ... your existing services ...

    sylius_shop.controller.currency_switch:
        class: App\Controller\CurrencySwitchController
        public: true
        arguments:
            $currencyStorage: '@sylius.storage.currency'
            $channelContext: '@sylius.context.channel'
            $router: '@router'

    sylius_admin.controller.impersonate_user:
        class: App\Controller\Admin\ImpersonateUserController
        public: true
        arguments:
            $impersonator: '@sylius_admin.security.shop_user_impersonator'
            $authorizationChecker: '@security.authorization_checker'
            $userProvider: '@sylius.shop_user_provider.email_or_name_based'
            $router: '@router'
            $authorizationRole: 'ROLE_ADMINISTRATION_ACCESS'

    # Only if you use locale_switcher: storage
    sylius_shop.locale_switcher:
        class: App\Locale\StorageBasedLocaleSwitcher
        public: false
        arguments:
            $localeStorage: '@sylius.storage.locale'
            $channelContext: '@sylius.context.channel'
            $router: '@router'

Step 5 - Clear cache

bin/console cache:clear

Customizing the redirect target

If you need a different redirect target, override the route definition with the _sylius.redirect attribute:

# config/routes/sylius_shop.yaml (AFTER the sylius_shop resource import)
sylius_shop_switch_currency:
    path: /{_locale}/switch-currency/{code}
    methods: [GET]
    defaults:
        _controller: sylius.controller.shop.currency_switch:switchAction
        _sylius:
            redirect: sylius_shop_product_index  # or any route name

Reporters

We would like to extend our gratitude to the following individuals for their detailed reporting and responsible disclosure of this vulnerability:

For more information

If you have any questions or comments about this advisory:

References

@NoResponseMate NoResponseMate published to Sylius/Sylius Mar 9, 2026
Published by the National Vulnerability Database Mar 10, 2026
Published to the GitHub Advisory Database Mar 11, 2026
Reviewed Mar 11, 2026
Last updated Mar 11, 2026

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality None
Integrity None
Availability None
Subsequent System Impact Metrics
Confidentiality Low
Integrity Low
Availability Low

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:L

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(13th percentile)

Weaknesses

URL Redirection to Untrusted Site ('Open Redirect')

The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. Learn more on MITRE.

CVE ID

CVE-2026-31819

GHSA ID

GHSA-9ffx-f77r-756w

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.