-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The GET handler treats existence as the authorization decision\n\nPrestaShop 1.7 through 8.2.2 ships an admin password-reset flow that starts with an email link. The link is generated by `processForgot()` and points back at the same controller with two parameters: `id_employee` (an auto-increment integer naming which administrator the link belongs to) and `reset_token` (a 40-character SHA-1 stamped onto the employee row at link-generation time, with a 1440-minute default validity window).\n\nWhen an administrator clicks that link, the browser hits `index.php?controller=AdminLogin&id_employee=N&reset_token=T`. The front controller routes the GET to `AdminLoginController::initContent()`, which is responsible for rendering the form the administrator will type their new password into. The form needs the employee's email so it can round-trip the value back on submission, and so the user can see whose account they are about to change.\n\nThe pre-patch `initContent()` walks five operations:\n\n```php\n// controllers/admin/AdminLoginController.php (PrestaShop 8.2.2, lines 160-170)\n// For reset password feature\nif ($reset_token = Tools::getValue('reset_token')) {\n $this->context->smarty->assign('reset_token', $reset_token);\n}\nif ($id_employee = Tools::getValue('id_employee')) {\n $this->context->smarty->assign('id_employee', $id_employee);\n $employee = new Employee($id_employee);\n if (Validate::isLoadedObject($employee)) {\n $this->context->smarty->assign('reset_email', $employee->email);\n }\n}\n```\n\nRead the operations in order. The handler reads `reset_token` from the request and binds it to the Smarty template. The token is never compared to anything. Its single role in this method is to be a hidden input on the form that submits the new password, so the next request carries it back. The handler then reads `id_employee` from the request, instantiates an `Employee` object against it, and asks `Validate::isLoadedObject` whether the constructor succeeded in loading a row. If the row loaded, the employee's email goes into the template.\n\nThe check at the end of that sequence is asking \"does an employee with this ID exist in the database?\" The decision it gates is whether to disclose that employee's email. Those are two different questions. The PoC iterates `id_employee` from 1 to 30 (PrestaShop installs typically have between one and ten administrators, and `id_employee` is a sequential primary key), runs the URL once per integer with arbitrary garbage in `reset_token`, and scrapes the rendered HTML for ``. Each iteration that finds a row prints a real administrator's email. The `reset_token` can be any non-falsy string.\n\n## The validator was already on the model\n\nThe fixed version of `initContent()` calls a real validator. The validator's name is `Employee::getValidResetPasswordToken()`, defined in `classes/Employee.php`:\n\n```php\n// classes/Employee.php (lines 711-725, identical in 8.2.2 and 8.2.3)\n/**\n * Returns the valid reset password token if it validity date is > now().\n */\npublic function getValidResetPasswordToken()\n{\n if (!$this->reset_password_token) {\n return false;\n }\n\n if (!$this->reset_password_validity || strtotime($this->reset_password_validity) < time()) {\n return false;\n }\n\n return $this->reset_password_token;\n}\n```\n\nThis method existed in PrestaShop 8.2.2. A byte-level diff of `classes/Employee.php` between 8.2.2 and 8.2.3 is empty; the patch did not add the validator. The pre-patch `initContent()` loaded the `Employee` object and then did not call `$employee->getValidResetPasswordToken()`. It called `Validate::isLoadedObject($employee)` instead.\n\nIn the same controller, two hundred lines further down, `processReset()` already knew how to use the method. That handler answers the POST the form submits, and its job is to actually change the password:\n\n```php\n// controllers/admin/AdminLoginController.php, processReset(), line 438 (pre-patch)\n} elseif ($employee->getValidResetPasswordToken() !== $reset_token_value) {\n // To update password, we must have the temporary reset token that matches.\n $this->errors[] = $this->trans(\n 'Your password reset request expired. Please start again.',\n [], 'Admin.Login.Notification'\n );\n}\n```\n\n`processReset()` reads the supplied token, calls `getValidResetPasswordToken()` on the loaded Employee, compares the two with `!==`, and refuses to change the password if they disagree. The author of `processReset()` knew the token had to be checked, because the password-change action would otherwise let anyone reset any administrator's password. They wrote the check.\n\nThe author of `initContent()` is rendering the form that supplies that very token to `processReset()`. They have the same `Employee` object, the same `reset_token` value out of the request, and the same `getValidResetPasswordToken()` method available on the model. They wrote a different check.\n\n## The patch copies the comparison from one method into the other\n\nThe diff is 11 lines, all in `AdminLoginController.php`:\n\n```diff\n // For reset password feature\n- if ($reset_token = Tools::getValue('reset_token')) {\n+ $reset_token = Tools::getValue('reset_token');\n+ $id_employee = Tools::getValue('id_employee');\n+ if ($reset_token !== false && $id_employee !== false) {\n $this->context->smarty->assign('reset_token', $reset_token);\n- }\n- if ($id_employee = Tools::getValue('id_employee')) {\n $this->context->smarty->assign('id_employee', $id_employee);\n+\n $employee = new Employee($id_employee);\n- if (Validate::isLoadedObject($employee)) {\n+ $valid_reset_token = $employee->getValidResetPasswordToken();\n+\n+ if ($valid_reset_token !== false && $valid_reset_token === $reset_token) {\n $this->context->smarty->assign('reset_email', $employee->email);\n }\n }\n```\n\nThe body of the conditional is now gated by `$valid_reset_token === $reset_token` instead of `Validate::isLoadedObject($employee)`. No method was added to `Employee`. No call was reorganised at the front-controller level. The four lines of comparison that already lived in `processReset()` were copied, with one variable rename, into `initContent()`.\n\nThe commit message that ships those four lines, signed by morgan at PrestaShop on 2025-08-28, is three words: \"Email enumeration fix.\"\n\n## The exploit is the URL the legitimate link would have been\n\n`processForgot()`, the handler that generates the legitimate reset email, builds the URL like this:\n\n```php\n// controllers/admin/AdminLoginController.php, processForgot(), line 349\n'{url}' => $admin_url . '&id_employee=' . (int) $employee->id\n . '&reset_token=' . $employee->reset_password_token,\n```\n\nA real reset email contains a URL whose `id_employee` is the integer primary key of the recipient and whose `reset_token` is the SHA-1 stamped on their row sixty seconds earlier. The attacker's request is the same URL with the second value replaced by a value the attacker chose:\n\n```bash\ncurl -s \"https://shop.example/admin123/index.php?controller=AdminLogin&id_employee=1&reset_token=$(head -c32 /dev/urandom | xxd -p)\" \\\n | grep -Eo 'name=\"reset_email\"[^>]*value=\"[^\"]+\"'\n# name=\"reset_email\" value=\"admin@shop.example\"\n```\n\nThe PoC, a nuclei template authored by mastercho, iterates `id_employee` from 1 to 30 across forty common admin-panel paths (`admin`, `backoffice`, `back-office`, `administrator`, `panel`, ..., `admin123`, `ps-admin`, `BackofficeNEW`). It registers a hit whenever the response is `200 OK` and the body contains ``. The token in the URL is a random 32-character string the template regenerates per run. The token's value does not matter. Its presence matters only because the pre-patch conditional was the assign-and-test `if ($reset_token = Tools::getValue('reset_token'))`, and `Tools::getValue` returns the string `false` when the parameter is missing.\n\nThe output of one successful scan against a vulnerable host is a list of administrator email addresses, one per back-office account, indexed by the integer that is their primary key.\n\n## Existence is authorization, at the model layer\n\nPrestaShop wrote a model with a `reset_password_token` column, a `reset_password_validity` column, and a `getValidResetPasswordToken()` method that consults both. The model carries the per-call credential. The model's validator is one call away from any handler that loads the object. The bug is not the absence of a check. The bug is a handler that loaded the object, had the credential value in the request, and decided to ask whether the row existed.\n\nThis is [existence-is-authorization](/patterns/existence-is-authorization) where the per-call credential is already in the request and the validator is already on the loaded object. The [n8n exhibit](/posts/n8n-chat-existence-was-the-gate) had to switch from `checkIfExecutionExists` to `findExecution` because the original lookup did not return a row rich enough to validate against. The [ksmbd exhibit](/posts/ksmbd-durable-handle-was-the-credential) had to add a `durable_owner` struct that did not exist on the file row at all. PrestaShop did not need to add a column, a method, or a lookup. The credential travels in the URL. The validator is on the object. The sibling method on the same file does the comparison.\n\n`Validate::isLoadedObject` is the question \"did the ORM find a row with this primary key?\" The handler asked that question and then disclosed an email. The question that would have gated the disclosure is \"did the caller send a string that equals the token stamped on this row?\" Both questions are one method call away from a loaded `Employee` object. The pre-patch handler answered the first one and named it the second.\n\n## What the 8.2.3 release actually contains\n\n`controllers/admin/AdminLoginController.php` gained seven lines. `classes/Employee.php` did not change. The validator was not added; the call to the validator was. The structural reason for the bug is that one method on a controller knew how to use the model's validator and another method on the same controller did not. The 8.2.3 patch closes the GET-side disclosure by copying four lines from the POST-side method.\n\nThe 1.7-through-8.2.2 range is the entire 7.x and 8.x line of PrestaShop, and the validator is the one whose method body has been on `Employee` long enough that the patch shipped without touching it. Maxime Morel reported the disclosure to PrestaShop on 2025-05-17. The fix landed on 2025-08-28. The advisory shipped on 2025-09-04. CVE-2025-51586 was published the same week.\n\nPoC: [projectdiscovery/nuclei-templates](https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2025/CVE-2025-51586.yaml)","closing_line":"The fix did not add a method. The validator was already on the object, and the sibling handler in the same file already called it.","hook_md":"PrestaShop's `AdminLoginController` has two methods that touch reset tokens. `processReset()`, the POST handler that actually changes a password, validates the supplied token by calling `$employee->getValidResetPasswordToken() !== $reset_token_value` on line 438. `initContent()`, the GET handler that renders the password-reset form, loads the employee, checks `Validate::isLoadedObject($employee)`, and assigns the employee's email to the template if the load succeeded.\n\nCVE-2025-51586 is the gap between those checks. The validator method was on the Employee object. The sibling handler in the same file called it. The renderer asked a different question.","post_id":584,"slug":"prestashop-cve-2025-51586-validator-was-on-the-object","title":"CVE-2025-51586: PrestaShop's AdminLogin Renderer Asked If The Employee Existed. The Validator Was Already On The Object.","type":"initial","unreadable_sentence":"The patch closes this CVE by calling, in initContent, the method processReset was already calling two hundred lines below."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCarvv5wAKCRDeZjl4jgkQ JmCLAQC26rPlgAVu2zpSWxLNNOoNhLp5pqE0e8eR8aAgRb+F/gEAskQKR8Go3MSL lSEFJprGP+TzPEKmuty1gnwyHj/C+ww= =WqAC -----END PGP SIGNATURE-----