Confirmed Add-on install/upgrade in the admin panel does not enforce requirement errors on POST

Sim

Well-known member
Licensed customer
Affected version
2.3.13
The add-on install and upgrade confirmation pages list requirement errors (for example "requires PHP 7.4.0+") and offer no submit button. But the controller never checks those errors when the form is submitted, so a POST to the same URL installs or upgrades the add-on anyway.

In XF\Admin\Controller\AddOnController, actionInstall() and actionUpgrade() both start with:

PHP:
[$warnings, $errors] = $this->getAddOnWarningsAndErrors($addOn);

if ($this->isPost())
{
    // ... runs the Setup steps; $errors is never read
}

$errors is used only by the GET branch, which passes it to the template, where addon_action_macros::action leaves out the button. actionRebuild() has the same shape.

Other routes check the same errors before acting:
  • actionToggle() returns $this->error($errors) before it enables an add-on.
  • The CLI's AddOnActionTrait::verifyAddOnAction() refuses on errors (xf:addon-install, xf:addon-upgrade).
  • XF\Job\AddOnInstallBatch refuses on errors (install/upgrade from archive).
So the confirm pages are the only route where the check works only through the UI.

Steps to reproduce
  1. Take any add-on and add an unmet requirement to its addon.json, for example "require": {"php": ["8.9.0", "PHP 8.9.0+"]}.
  2. Upload its files and open Admin > Add-ons. Click Upgrade (or Install). The page shows the error and no button.
  3. Submit the form anyway. The form element and its _xfToken are still on the page, so either:
    • run document.querySelector('form.block').submit() in the browser console; or
    • POST _xfToken to admin.php?add-ons/<addon_id>/upgrade, then follow the returned steps.
  4. The upgrade runs to completion. The add-on list shows the new version installed, though its requirement is unmet.

Expected: the POST is refused with the same errors the confirmation page shows, as actionToggle() and the CLI already do.

Observed on 2.3.0 Patch 2 (PHP 7.3.33, an add-on declaring PHP 7.4.0+): the hand-made POST upgraded the add-on to completion. The same code is unchanged in 2.3.13.

Impact is limited because an ordinary admin never sees a button. It matters when a requirement exists to keep a fatal error out. In our case the add-on's command class does not parse below 7.4, and once installed it was registered on every cmd.php run.

Suggested fix: in the POST branch of actionInstall(), actionUpgrade() and actionRebuild(), return $this->error($errors) if $errors is non-empty, as actionToggle() does. Only the first request needs the check (the one without _xfProcessing or finished), but checking every step does no harm.

Related, and possibly worth a separate report: when command registration hits a fatal error (here a ParseError while loading an add-on's command class), cmd.php still exits 0. XF\Cli\Runner::registerCommands() runs before any try block and before setupApp(), so nothing catches or logs the error, and a script running cmd.php reads the failure as success.
 
Back
Top Bottom