{"id":"CVE-2026-31822","aliases":["GHSA-vgh8-c6fp-7gcg"],"url":"https://o3.security/vulnerability/CVE-2026-31822","summary":"Sylius has a XSS vulnerability in checkout login form","details":"### Impact\n\nA cross-site scripting (XSS) vulnerability exists in the shop checkout login form handled by the ApiLoginController Stimulus controller.                                                                                                               \n\nWhen a login attempt fails, AuthenticationFailureHandler returns a JSON response whose message field is rendered into the DOM using innerHTML, allowing any HTML or JavaScript in that value to be parsed and executed by the browser.\n\nThe message value originates from `AuthenticationException::getMessageKey()` passed through Symfony's translator (security domain, using the request locale). In the default Sylius installation, this returns a hardcoded translation key (e.g. \"Invalid credentials.\"), which is not directly user-controlled. However, using innerHTML with server-derived data violates defense-in-depth principles, and the risk escalates significantly under realistic scenarios:\n  - Customized authentication handlers — if a project overrides AuthenticationFailureHandler to include user-supplied data in the message (e.g. \"No account found for <username>\"), an attacker can inject arbitrary JavaScript directly via the login\n  form without any privileged access.\n  - Translation injection — if translation files are sourced from an untrusted database or CMS and contain HTML, the message could carry a malicious payload.\n  - Man-in-the-Middle — if the response is intercepted (e.g. on HTTP or via a compromised proxy), an attacker can inject arbitrary HTML/JS into the message field.\n  - Server-side injection — if any middleware, reverse proxy, or error handler modifies the JSON response body, malicious content could be injected into the message field.\n\nExploitation could lead to session hijacking, credential theft, cart/order manipulation, or phishing within the trusted shop domain.\n\nThe vulnerability affects all Sylius installations that use the default shop checkout login form with the bundled ApiLoginController.js.\n\n### Patches\nThe issue is fixed in versions: 2.0.16, 2.1.12, 2.2.3 and above.\n\n### Workarounds\nOverride the vulnerable JavaScript controller at the project level.\n> Note: Step 2 differs between Sylius 2.0 and up\n\n#### Step 1. Override JavaScript controller handling login\n### Patch ApiLoginController.js\n\nCopy the original from `vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/assets/controllers/ApiLoginController.js` to `assets/shop/controllers/ApiLoginController.js` and apply:\n```diff\n...\n  .then(response => {\n    if (response.success) {\n      window.location.reload();\n    } else {\n      const errorElement = this.errorPrototypeTarget.cloneNode(true);\n-     errorElement.innerHtml = response.message;\n+     errorElement.textContent = response.message;\n      this.errorTarget.innerHTML = errorElement.outerHTML;\n    }\n  })\n...\n```\n\n#### Step 2. Register the patched controller\n> Sylius 2.1+ (Stimulus Bridge with `controllers.json`)\n\nDisable the vendor controller in `assets/shop/controllers.json`:\n```diff\n...\n  \"api-login\": {\n-    \"enabled\": true,\n+    \"enabled\": false,\n    \"fetch\": \"lazy\"\n  }\n...\n```\nRegister the overwritten controller in `assets/shop/bootstrap.js`\n```js\nimport ApiLoginController from './controllers/ApiLoginController'\n\napp.register('sylius--shop-bundle--api-login', ApiLoginController);\n```\n---\n> Sylius 2.0 (explicit imports in vendor `app.js`)\n\nUse Webpack's `NormalModuleReplacementPlugin` to swap the controller at build time. In `webpack.config.js`, after `shopConfig` is created:\n\n```diff\n+ const webpack = require('webpack');\n...\n  // Shop config\n  const shopConfig = SyliusShop.getWebpackConfig(path.resolve(__dirname));\n+ shopConfig.plugins.push(\n+   new webpack.NormalModuleReplacementPlugin(\n+     /\\/controllers\\/ApiLoginController\\.js$/,\n+     path.resolve(__dirname, 'assets/shop/controllers/ApiLoginController.js')\n+   )\n+ );\n...\n```\n\n#### Step 3. Rebuild assets\n\n```bash\nyarn encore dev  # or: yarn encore production\n```\n\n### Reporters\n\nWe would like to extend our gratitude to the following individuals for their detailed reporting and responsible disclosure of this vulnerability:\n- Bartłomiej Nowiński (@bnBart)\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n- Open an issue in [Sylius issues](https://github.com/Sylius/Sylius/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen)\n- Email us at [security@sylius.com](mailto:security@sylius.com)","published":"2026-03-10T21:27:38.691Z","modified":"2026-08-12T03:51:32.247859395Z","cvss":null,"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Packagist","name":"sylius/sylius","fixedVersion":"2.0.16"},{"ecosystem":"Packagist","name":"sylius/sylius","fixedVersion":"2.1.12"},{"ecosystem":"Packagist","name":"sylius/sylius","fixedVersion":"2.2.3"}],"fix":null,"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/31xxx/CVE-2026-31822.json"},{"type":"ADVISORY","url":"https://github.com/Sylius/Sylius/security/advisories/GHSA-vgh8-c6fp-7gcg"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31822"},{"type":"PACKAGE","url":"https://github.com/Sylius/Sylius"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:32.247859395Z"}}