GHSA-77W3-2367-7XVQ
Administrator password-reset link is built from the request Host header, allowing reset-token theft
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-77W3-2367-7XVQ divulgada · CVSS 8.8 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Impact
Anyone able to trigger a password-reset e-mail for an administrator which needs nothing but that administrator's e-mail address and a single unauthenticated request could make the reset link in that e-mail point at a domain of their choosing. When the administrator clicked the link, the valid reset token was delivered to the attacker's server, and the attacker could then set a new password on the real shop and take the account over.
Sylius built the absolute reset URL with Twig's `url()` helper, which derives scheme and host from the incoming request. Symfony resolves those from the `Host` header, or `X-Forwarded-Host` behind a trusted proxy, unless `framework.trusted_hosts` is configured and Sylius ships no default for it. The e-mail was otherwise entirely genuine: real sender, real branding, real token; only the link's domain was attacker-controlled.
Both entry points behave the same way: the `/admin/forgotten-password` form and the `POST /api/v2/admin/administrators/reset-password` endpoint. The shop-side password reset was never affected, because it builds its link from the channel's configured hostname.
### Patches
The issue is fixed in versions: 1.12.25, 1.13.17, 1.14.20, 2.1.16, 2.2.9 and above.
Two things to plan for when upgrading:
- If your application overrides `SyliusCoreBundle/Email/adminPasswordReset.html.twig`, update it, otherwise it keeps generating the link with `url()` and remains vulnerable. The shipped template now renders `resetUrl` and falls back to displaying the token; mirror that in your override.
Note that pinning `framework.trusted_hosts` remains worthwhile after upgrading: it closes Host-header injection for the whole application, not only for this one e-mail.
### Workarounds
If you cannot update Sylius immediately, either of the following is sufficient on its own. Doing both is recommended.
Option A. Pin the trusted hosts
# config/packages/framework.yaml
framework:
trusted_hosts: ['^(www\.)?your-shop\.example$', '^admin\.your-shop\.example$']Configuring the front-end web server to reject requests whose `Host` does not match a known virtual host has the same effect. This option is worth applying on every installation, patched or not.
Option B. Decorate the mailer
Step 1. Create `src/Mailer/ChannelHostAdminResetPasswordEmailManager.php`
<?php
declare(strict_types=1);
namespace App\Mailer;
use Sylius\Bundle\CoreBundle\Mailer\Emails;
use Sylius\Bundle\CoreBundle\Mailer\ResetPasswordEmailManagerInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Channel\Context\ChannelNotFoundException;
use Sylius\Component\Channel\Model\ChannelInterface;
use Sylius\Component\Mailer\Sender\SenderInterface;
use Sylius\Component\User\Model\UserInterface;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\RouterInterface;
final class ChannelHostAdminResetPasswordEmailManager implements ResetPasswordEmailManagerInterface
{
public function __construct(
private ResetPasswordEmailManagerInterface $decoratedResetPasswordEmailManager,
private SenderInterface $emailSender,
private RouterInterface $router,
private ChannelContextInterface $channelContext,
private bool $unsecuredUrls = false,
) {
}
public function sendAdminResetPasswordEmail(UserInterface $user, string $localCode): void
{
$this->emailSender->send(
code: Emails::ADMIN_PASSWORD_RESET,
recipients: [$user->getEmail()],
data: [
'adminUser' => $user,
'localeCode' => $localCode,
'resetUrl' => $this->generateAdminResetPasswordUrl($user),
],
);
}
public function sendResetPasswordEmail(UserInterface $user, ChannelInterface $channel, string $localCode): void
{
$this->decoratedResetPasswordEmailManager->sendResetPasswordEmail($user, $channel, $localCode);
}
private function generateAdminResetPasswordUrl(UserInterface $user): ?string
{
try {
$hostname = $this->channelContext->getChannel()->getHostname();
} catch (ChannelNotFoundException) {
return null;
}
if (null === $hostname) {
return null;
}
try {
$path = $this->router->generate(
'sylius_admin_render_password_reset',
['token' => (string) $user->getPasswordResetToken()],
);
} catch (RouteNotFoundException) {
return null;
}
return ($this->unsecuredUrls ? 'http://' : 'https://') . $hostname . $path;
}
}On 1.12 the administrator e-mail is sent by `Sylius\Bundle\CoreBundle\MessageHandler\Admin\Account\SendResetPasswordEmailHandler` rather than by the mailer, so decorate that handler instead, keeping the `generateAdminResetPasswordUrl()` body identical. On 1.13, 1.14, 2.1 and 2.2 the handler delegates to the mailer, so decorating the mailer covers both the form and the API endpoint.
Step 2. Override `templates/bundles/SyliusCoreBundle/Email/adminPasswordReset.html.twig`
Copy the core template and replace both `sylius_bundle_loaded_checker('SyliusAdminBundle')` conditions with `resetUrl is not null`, and the `url(...)` link with `resetUrl`:
{% block content %}
<div style="text-align: center; margin-bottom: 30px;">
<div style="font-size: 24px;">
{{ 'sylius.email.admin_password_reset.hello'|trans({}, null, localeCode) }} <strong>{{ adminUser.firstName }} {{ adminUser.lastName }}</strong><br>
</div>
{% if resetUrl is not null %}
{{ 'sylius.email.password_reset.to_reset_your_password'|trans({}, null, localeCode) }}:
{% else %}
{{ 'sylius.email.admin_password_reset.to_reset_your_password_token'|trans({}, null, localeCode) }}:
{% endif %}
</div>
<div style="text-align: center;">
{% if resetUrl is not null %}
<a href="{{ resetUrl }}" style="display: inline-block; text-align: center; background: #1abb9c; padding: 18px 28px; color: #fff; text-decoration: none; border-radius: 3px;">
{{ 'sylius.email.admin_password_reset.reset_your_password'|trans({}, null, localeCode) }}
</a>
{% else %}
{{ 'sylius.email.admin_password_reset.token'|trans({}, null, localeCode) }}: {{ adminUser.passwordResetToken }}
{% endif %}
</div>
{% endblock %}Step 3. Register the decorator in `config/services.yaml`
services:
+
+ App\Mailer\ChannelHostAdminResetPasswordEmailManager:
+ decorates: sylius.mailer.reset_password_email_manager
+ arguments:
+ $decoratedResetPasswordEmailManager: '@.inner'
+ $emailSender: '@sylius.email_sender'
+ $router: '@router'
+ $channelContext: '@sylius.context.channel'
+ $unsecuredUrls: '%sylius.unsecured_urls%'Step 4. Clear the cache
bin/console cache:clearReporters
We would like to extend our gratitude to the following individuals for their detailed reporting and responsible disclosure of this vulnerability:
- Winfunc Research (https://winfunc.com/)
For more information
If you have any questions or comments about this advisory:
- Open an issue in Sylius issues
https://github.com/Sylius/Sylius/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen - Email us at [security@sylius.com](mailto:security@sylius.com)
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistsylius/sylius |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/Sylius/Sylius/security/advisories/GHSA-77w3-2367-7xvqLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
