This issue was reported privately, but has been approved for public discussion by the Drupal Security Team.

Problem/Motivation

The update module does not sufficiently check if core_version_requirement is a valid version constraint.

Steps to reproduce

  1. Install a module.
  2. Issue an updated version of the module with an invalid version number in core_version_requirement in the .info.yml file.
  3. Update this module to the new version. Not needed - the existence of the broken release in the updates.d.o release history feed triggers the bug

Proposed resolution

The following was proposed by @MegaphoneJon.

The update module should be checking its inputs rather than accepting them as-is from d.o. And arguably the release process on d.o should be checking for invalid version constraints.

Remaining tasks

  1. Add tests
  2. Reviews / refinements

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

TBD

Issue fork drupal-3451701

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Mingsong created an issue. See original summary.

dww made their first commit to this issue’s fork.

dww credited MegaphoneJon.

dww’s picture

dww’s picture

Title: The update module should check the validation of a module version » The update module should not crash with releases that contain invalid values for core_version_requirement
Priority: Normal » Critical
Issue summary: View changes
Status: Active » Needs review
Issue tags: +Bug Smash Initiative, +Needs tests

Here's a quick start. Needs tests, but wanted to get an MR open ASAP.

Elevating to critical since this is potentially very bad. 😬 While there are guardrails for the version strings themselves when creating releases on d.o, there's nothing to prevent people from having typos in the core_version_requirement they put into tagged releases. Update manager needs to be resilient to those sorts of mistakes, not hard crash with uncaught exceptions. Especially since we generally prevent anyone from fixing a broken release, so once there's a problem, we've got it "forever".

Fixing the summary, both formatting, and some technical details.

dww’s picture

Issue tags: -Needs tests

Added Unit test coverage that shows the bug and proves the fix.

We probably want to extend some Functional coverage for this, too, since there might be other spots that blow up in this case, and it'd be nice to have an end-to-end test to verify it.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @dww for super clear ticket

Test-only was already ran https://git.drupalcode.org/issue/drupal-3451701/-/jobs/1748750 and shows the coverage.

Code review of using a try/catch seems fine and good idea for an immediate fix.

  • catch committed 71b3b5c6 on 10.2.x
    Issue #3451701 by dww, Mingsong, MegaphoneJon: The update module should...

  • catch committed 48d52ff3 on 10.3.x
    Issue #3451701 by dww, Mingsong, MegaphoneJon: The update module should...

  • catch committed 33f668e0 on 10.4.x
    Issue #3451701 by dww, Mingsong, MegaphoneJon: The update module should...

  • catch committed d2f79916 on 11.0.x
    Issue #3451701 by dww, Mingsong, MegaphoneJon: The update module should...
catch’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked back through to 10.2.x, thanks!

  • catch committed d3b2a6a5 on 11.x
    Issue #3451701 by dww, Mingsong, MegaphoneJon: The update module should...
drumm’s picture

(Saving to resolve issue indexing issue, please disregard.)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.