The vulnerability is an Insecure Direct Object Reference (IDOR) in the shopping cart functionality of Craft Commerce. The root cause is that the application uses a user-provided cart number to retrieve and manage shopping carts without properly verifying that the user making the request is the owner of the cart.
Two functions in src/controllers/CartController.php were identified as vulnerable:
-
craftcms\commerce\controllers\CartController::actionLoadCart(): This public controller action is directly exposed to user input via the number GET parameter. The patch file for commit ceab5e47e9a5cb77dd274cba0e62cbace5c827fc shows that before the fix, this function would load any cart based on its number. The patch adds a token-based validation mechanism and checks for cart ownership if the user is logged in, thus mitigating the IDOR.
-
craftcms\commerce\controllers\CartController::_getCart(): Although not directly modified in the provided patch, the vulnerability description explicitly points to this private method as being vulnerable. It retrieves a cart using the number from the request body, also without ownership checks. It's likely that other public methods in the controller call this private method, and the vulnerability was fixed by adding checks in the calling methods or by refactoring the code to not use this insecure method.
The exploitation of this vulnerability would involve an attacker obtaining a victim's cart number and then using it in a request to actionLoadCart or another endpoint that uses _getCart. This would load the victim's cart into the attacker's session, allowing them to view and modify it, potentially leading to the exposure of Personally Identifiable Information (PII) and session hijacking. The patch in commit 03f55010f323d10205d5f6ff696ac832c89d737b also strengthens the cart number generation to make it less predictable, which is a hardening measure against brute-force attacks.