CVE-2024-23648 (published 2024-01-24T18:15Z)

Pimcore\'s Admin Classic Bundle provides a backend user interface for Pimcore. The password reset functionality sends to the the user requesting a password change an email containing an URL to reset its password. The URL sent contains a unique token, valid during 24 hours, allowing the user to reset its password. This token is highly sensitive ; as an attacker able to retrieve it would be able to resets the user\'s password. Prior to version 1.2.3, the reset-password URL is crafted using the "Host" HTTP header of the request sent to request a password reset. This way, an external attacker could send password requests for users, but specify a "Host" header of a website that they control. If the user receiving the mail clicks on the link, the attacker would retrieve the reset token of the victim and perform account takeover. Version 1.2.3 fixes this issue.

CVSS v3 base score: 8.8, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-74
cwe_name: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
description: The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
extended_description: Software or other automated logic has certain assumptions about what constitutes data and control respectively. It is the lack of verification of these assumptions for user-controlled input that leads to injection problems. Injection problems encompass a wide variety of issues -- all mitigated in very different ways and usually attempted in order to alter the control flow of the process. For this reason, the most effective way to discuss these weaknesses is to note the distinct features that classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common -- i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed.
         

Fix information:
repo_url: https://github.com/pimcore/admin-ui-classic-bundle
commit_details: repo_url: https://github.com/pimcore/admin-ui-classic-bundle
author: Bernhard Rusch
author_date: 2023-12-06 12:35:56+01:00
msg: Password reset - fix for possible host header injection (#362)

* Password reset - fix for possible host header injection

* Update src/Controller/Admin/LoginController.php

Co-authored-by: Sebastian Blank <blank@data-factory.net>

---------

Co-authored-by: Sebastian Blank <blank@data-factory.net>
repository: repo_url: https://github.com/pimcore/admin-ui-classic-bundle
repo_name: pimcore/admin-ui-classic-bundle
repo_language: JavaScript
owner: pimcore
file_changes: filename: LoginController.php
change_type: ModificationType.MODIFY
diff: @@ -32,6 +32,7 @@ use Pimcore\Http\ResponseHelper;
 use Pimcore\Logger;
 use Pimcore\Model\User;
 use Pimcore\Security\SecurityHelper;
+use Pimcore\SystemSettingsConfig;
 use Pimcore\Tool;
 use Pimcore\Tool\Authentication;
 use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
@@ -44,6 +45,7 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent;
 use Symfony\Component\RateLimiter\RateLimiterFactory;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Routing\RouterInterface;
 use Symfony\Component\Security\Core\Exception\AuthenticationException;
 use Symfony\Component\Security\Core\Security;
 use Symfony\Component\Security\Core\User\UserInterface;
@@ -194,7 +196,13 @@ class LoginController extends AdminAbstractController implements KernelControlle
     /**
      * @Route("/login/lostpassword", name="pimcore_admin_login_lostpassword")
      */
-    public function lostpasswordAction(Request $request, CsrfProtectionHandler $csrfProtection, Config $config, RateLimiterFactory $resetPasswordLimiter): Response
+    public function lostpasswordAction(
+        Request $request,
+        CsrfProtectionHandler $csrfProtection,
+        Config $config,
+        RateLimiterFactory $resetPasswordLimiter,
+        RouterInterface $router
+    ): Response
     {
         $params = $this->buildLoginPageViewParams($config);
         $error = null;
@@ -226,12 +234,20 @@ class LoginController extends AdminAbstractController implements KernelControlle
             if (!$error) {
                 $token = Authentication::generateTokenByUser($user);
 
-                $loginUrl = $this->generateUrl('pimcore_admin_login_check', [
-                    'token' => $token,
-                    'reset' => 'true',
-                ], UrlGeneratorInterface::ABSOLUTE_URL);
-
                 try {
+                    $domain = SystemSettingsConfig::get()['general']['domain'];
+                    if (!$domain) {
+                        throw new \Exception('No main domain set in system settings, unable to generate reset password link');
+                    }
+
+                    $context = $router->getContext();
+                    $context->setHost($domain);
+
+                    $loginUrl = $this->generateUrl('pimcore_admin_login_check', [
+                        'token' => $token,
+                        'reset' => 'true',
+                    ], UrlGeneratorInterface::ABSOLUTE_URL);
+
                     $event = new LostPasswordEvent($user, $loginUrl);
                     $this->eventDispatcher->dispatch($event, AdminEvents::LOGIN_LOSTPASSWORD);
 

programming_language: PHP