{"id":"CVE-2026-31888","aliases":["GHSA-gqc5-xv7m-gcjq"],"url":"https://o3.security/vulnerability/CVE-2026-31888","summary":"Shopware has user enumeration via distinct error codes on Store API login endpoint","details":"## Summary\n\nThe Store API login endpoint (`POST /store-api/account/login`) returns different error codes depending on whether the submitted email address belongs to a registered customer (`CHECKOUT__CUSTOMER_AUTH_BAD_CREDENTIALS`) or is unknown (`CHECKOUT__CUSTOMER_NOT_FOUND`). The \"not found\" response also echoes the probed email address. This allows an unauthenticated attacker to enumerate valid customer accounts. The storefront login controller correctly unifies both error paths, but the Store API does not — indicating an inconsistent defense.\n\n## CWE\n\n- **CWE-204**: Observable Response Discrepancy\n\n## Description\n\n### Distinct error codes leak account existence\n\nThe login flow in `AccountService::getCustomerByLogin()` calls `getCustomerByEmail()` first, which throws `CustomerNotFoundException` if the email is not found. If the email IS found but the password is wrong, a separate `BadCredentialsException` is thrown:\n\n```php\n// src/Core/Checkout/Customer/SalesChannel/AccountService.php:116-145\npublic function getCustomerByLogin(string $email, string $password, SalesChannelContext $context): CustomerEntity\n{\n    if ($this->isPasswordTooLong($password)) {\n        throw CustomerException::badCredentials();\n    }\n\n    $customer = $this->getCustomerByEmail($email, $context);\n    // ↑ Throws CustomerNotFoundException with CHECKOUT__CUSTOMER_NOT_FOUND if email unknown\n\n    if ($customer->hasLegacyPassword()) {\n        if (!$this->legacyPasswordVerifier->verify($password, $customer)) {\n            throw CustomerException::badCredentials();\n            // ↑ Throws BadCredentialsException with CHECKOUT__CUSTOMER_AUTH_BAD_CREDENTIALS\n        }\n        // ...\n    }\n\n    if ($customer->getPassword() === null\n        || !password_verify($password, $customer->getPassword())) {\n        throw CustomerException::badCredentials();\n        // ↑ Same: CHECKOUT__CUSTOMER_AUTH_BAD_CREDENTIALS\n    }\n    // ...\n}\n```\n\nThe two exception types produce clearly distinguishable API responses:\n\n**Email not registered:**\n```json\n{\n  \"errors\": [{\n    \"status\": \"401\",\n    \"code\": \"CHECKOUT__CUSTOMER_NOT_FOUND\",\n    \"detail\": \"No matching customer for the email \\\"probe@example.com\\\" was found.\",\n    \"meta\": { \"parameters\": { \"email\": \"probe@example.com\" } }\n  }]\n}\n```\n\n**Email registered, wrong password:**\n```json\n{\n  \"errors\": [{\n    \"status\": \"401\",\n    \"code\": \"CHECKOUT__CUSTOMER_AUTH_BAD_CREDENTIALS\",\n    \"detail\": \"Invalid username and/or password.\"\n  }]\n}\n```\n\n### Storefront is protected — Store API is not\n\nThe storefront login controller demonstrates that Shopware's developers are aware of this risk class. `AuthController::login()` catches both exceptions together and returns a generic error:\n\n```php\n// src/Storefront/Controller/AuthController.php:203\n} catch (BadCredentialsException|CustomerNotFoundException) {\n    // Unified handling — no distinction exposed to the user\n}\n```\n\nThe Store API `LoginRoute::login()` does NOT catch these exceptions. They propagate to the global `ErrorResponseFactory`, which serializes the distinct error codes into the JSON response:\n\n```php\n// src/Core/Checkout/Customer/SalesChannel/LoginRoute.php:54-58\n$token = $this->accountService->loginByCredentials(\n    $email,\n    (string) $data->get('password'),\n    $context\n);\n// No try/catch — exceptions propagate with distinct codes\n```\n\nThis inconsistency confirms the Store API exposure is an oversight, not a design decision.\n\n### Rate limiting is present but insufficient for enumeration\n\nThe login route has rate limiting (LoginRoute.php:47-51) keyed on `strtolower($email) . '-' . $clientIp`. This slows bulk enumeration but does not prevent it because:\n\n1. The attacker only needs **one request per email** to determine existence\n2. The rate limit key includes the IP, so rotating IPs resets the counter\n3. The rate limiter is designed to prevent brute-force password guessing, not single-probe enumeration\n\n## Impact\n\n- **Customer email enumeration**: An attacker can confirm whether specific email addresses are registered as customers, enabling targeted attacks\n- **Phishing enablement**: Confirmed customer emails can be targeted with store-specific phishing campaigns (e.g., fake order confirmations, password reset lures)\n- **Credential stuffing optimization**: Attackers with breached credential databases can first filter for valid emails before attempting password guesses, improving efficiency against rate limits\n- **Privacy violation**: Confirms an individual's association with a specific store, which may be sensitive depending on the store's nature (e.g., medical supplies, adult products)\n- **Email reflection**: The `CHECKOUT__CUSTOMER_NOT_FOUND` response echoes the probed email in the `detail` and `meta.parameters.email` fields, which could be leveraged in reflected content attacks\n\n## Recommended Remediation\n\n### Option 1: Catch both exceptions in LoginRoute and throw a unified error (Preferred)\n\nApply the same pattern already used in the storefront controller:\n\n```php\n// src/Core/Checkout/Customer/SalesChannel/LoginRoute.php\npublic function login(#[\\SensitiveParameter] RequestDataBag $data, SalesChannelContext $context): ContextTokenResponse\n{\n    EmailIdnConverter::encodeDataBag($data);\n    $email = (string) $data->get('email', $data->get('username'));\n\n    if ($this->requestStack->getMainRequest() !== null) {\n        $cacheKey = strtolower($email) . '-' . $this->requestStack->getMainRequest()->getClientIp();\n\n        try {\n            $this->rateLimiter->ensureAccepted(RateLimiter::LOGIN_ROUTE, $cacheKey);\n        } catch (RateLimitExceededException $exception) {\n            throw CustomerException::customerAuthThrottledException($exception->getWaitTime(), $exception);\n        }\n    }\n\n    try {\n        $token = $this->accountService->loginByCredentials(\n            $email,\n            (string) $data->get('password'),\n            $context\n        );\n    } catch (CustomerNotFoundException) {\n        // Normalize to the same exception as bad credentials\n        throw CustomerException::badCredentials();\n    }\n\n    if (isset($cacheKey)) {\n        $this->rateLimiter->reset(RateLimiter::LOGIN_ROUTE, $cacheKey);\n    }\n\n    return new ContextTokenResponse($token);\n}\n```\n\nThis ensures both \"not found\" and \"bad credentials\" return the same `CHECKOUT__CUSTOMER_AUTH_BAD_CREDENTIALS` code and generic message.\n\n### Option 2: Unify at the AccountService layer\n\nFor defense in depth, change `AccountService::getCustomerByLogin()` to throw `BadCredentialsException` instead of letting `CustomerNotFoundException` propagate:\n\n```php\n// src/Core/Checkout/Customer/SalesChannel/AccountService.php\npublic function getCustomerByLogin(string $email, string $password, SalesChannelContext $context): CustomerEntity\n{\n    if ($this->isPasswordTooLong($password)) {\n        throw CustomerException::badCredentials();\n    }\n\n    try {\n        $customer = $this->getCustomerByEmail($email, $context);\n    } catch (CustomerNotFoundException) {\n        throw CustomerException::badCredentials();\n    }\n\n    // ... rest of password verification\n}\n```\n\nThis protects all callers of `getCustomerByLogin()` regardless of how they handle exceptions. Note: `getCustomerByEmail()` is also called independently (e.g., password recovery), so that method should continue to throw `CustomerNotFoundException` for internal use — the normalization should happen at the login boundary.\n\n### Additional: Fix registration endpoint\n\nThe registration endpoint (`POST /store-api/account/register`) also leaks email existence via `CUSTOMER_EMAIL_NOT_UNIQUE`. For complete remediation, consider returning a generic success response and sending a notification email to the existing address instead.\n\n## Credit\n\nThis vulnerability was discovered and reported by [bugbunny.ai](https://bugbunny.ai).","published":"2026-03-11T18:53:03.018Z","modified":"2026-08-12T03:51:23.111978550Z","cvss":{"score":5.3,"severity":"MEDIUM","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"},"epss":{"score":0.00218,"percentile":0.12437,"asOf":"2026-09-17"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Packagist","name":"shopware/platform","fixedVersion":"6.7.8.1"},{"ecosystem":"Packagist","name":"shopware/platform","fixedVersion":"6.6.10.14"},{"ecosystem":"Packagist","name":"shopware/core","fixedVersion":"6.7.8.1"},{"ecosystem":"Packagist","name":"shopware/core","fixedVersion":"6.6.10.15"}],"fix":null,"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/31xxx/CVE-2026-31888.json"},{"type":"ADVISORY","url":"https://github.com/shopware/shopware/security/advisories/GHSA-gqc5-xv7m-gcjq"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31888"},{"type":"PACKAGE","url":"https://github.com/shopware/shopware"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:23.111978550Z"}}