GitHub Advisoryadvisory · Packagist

GHSA-mf3v-f2qq-pf9g Insufficient Session Expiration in Sylius

HIGH Published 2022-03-14 Modified 2022-03-15 Official page ↗
Aliases
CVE-2022-24743
Ecosystem
Packagist
Packages
sylius/sylius
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:N
Weaknesses
CWE-613
Reviewed
2022-03-14

Affected packages

• Packagist sylius/sylius: >= 1.10.0, < 1.10.11 → fixed in 1.10.11 • Packagist sylius/sylius: >= 1.11.0, < 1.11.2 → fixed in 1.11.2

Description

Impact The reset password token was not set to null after the password was changed. This is causing behaviour in which the same token can be used several times, so it can result in a leak of the existing token and an unauthorised password change. Patches The issue is fixed in versions: 1.10.11, 1.11.2 and above Workarounds You have to overwrite your `Sylius\Bundle\ApiBundle\CommandHandler\ResetPasswordHandler` class using this code: ```php userRepository = $userRepository; $this->metadata = $metadata; $this->passwordUpdater = $passwordUpdater; } public function __invoke(ResetPassword $command): void { /** @var ShopUserInterface|null $user */ $user = $this->userRepository->findOneBy(['passwordResetToken' => $command->resetPasswordToken]); Assert::notNull($user, 'No user found with reset token: ' . $command->resetPasswordToken); $resetting = $this->metadata->getParameter('resetting'); $lifetime = new \DateInterval($resetting['token']['ttl']); if (!$user->isPasswordRequestNonExpired($lifetime)) { throw new \InvalidArgumentException('Password reset token has expired'); } if ($command->resetPasswordToken !== $user->getPasswordResetToken()) { throw new \InvalidArgumentException('Password reset token does not match.'); } $user->setPlainPassword($command->newPassword); $this->passwordUpdater->updatePassword($user); $user->setPasswordResetToken(null); } } ``` And register it in container: ```yaml App\CommandHandler\Account\ResetPasswordHandler: arguments: • '@sylius.repository.shop_user' • !service class: Sylius\Component\Resource\Metadata\MetadataInterface factory: [ '@sylius.resource_registry', 'get' ] arguments: • 'sylius.shop_user' • '@sylius.security.password_updater' tags: • { name: messenger.message_handler, bus: sylius.command_bus } • { name: messenger.message_handler, bus: sylius_default.bus } ``` For more information If you have any questions or comments about this advisory: • Open an issue in Sylius issues • Email us at [email protected]

Related

Weakness · not in database (1)

Alias · CVE (1)

  • CVE-2022-24743 Sylius is an open source eCommerce platform. vulnerability

References