Skip to content

fix: scope the reported fix version to the installed version's range - #1085

Merged
sonukapoor merged 1 commit into
mainfrom
bugfix/fixed-version-range-scoping
Sep 5, 2026
Merged

fix: scope the reported fix version to the installed version's range#1085
sonukapoor merged 1 commit into
mainfrom
bugfix/fixed-version-range-scoping

Conversation

@sonukapoor

Copy link
Copy Markdown
Collaborator

findFirstFixedVersion collected every fixed event for a package and returned the global minimum, without checking which range the installed version actually falls in. When an advisory patches two release branches, the other branch's fix won.

minimist@1.2.5 against GHSA-xvch-5gv4-984h is the concrete case. OSV declares [1.0.0, 1.2.6) fixed in 1.2.6 and [0, 0.2.4) fixed in 0.2.4. The install is on the first branch so the fix is 1.2.6, but 0.2.4 sorted lower and was reported instead: a downgrade across a major boundary that would break any consumer.

The remediation resolver already got this right, so a single scan contradicted itself. Compact output and the HTML report's Fixed column said 0.2.4 while the fix command directly beneath said 1.2.6.

The function now takes the installed version and walks each range's events in order, pairing introduced with fixed so a range that reintroduces a vulnerability is handled. Fixes whose window contains the installed version win. When no window contains it, the previous lowest-fix behaviour is kept so a finding's remediation stays visible rather than disappearing.

Known limitation, recorded on the issue: this is incomplete for pre-release installed versions, because the window check depends on compareVersions, which #1077 shows is wrong for pre-releases. That case resolves automatically once #1077 lands, with no further change here. Every release install is correct now and pre-release installs are no worse than before.

Found by dogfooding while building the Open Source Friday demo, where a critical finding was about to recommend a downgrade on air.

Closes #1083

…'s range

findFirstFixedVersion collected every fixed event for a package and
returned the global minimum, without checking which range the installed
version actually falls in. When an advisory patches two release
branches, the other branch's fix won.

minimist@1.2.5 against GHSA-xvch-5gv4-984h is the concrete case. OSV
declares [1.0.0, 1.2.6) fixed in 1.2.6 and [0, 0.2.4) fixed in 0.2.4.
The installed version is on the first branch, so the fix is 1.2.6, but
0.2.4 sorted lower and was reported instead: a downgrade across a major
boundary that would break any consumer.

The remediation resolver already got this right, so a single scan
contradicted itself. Compact output and the HTML report's Fixed column
said 0.2.4 while the fix command directly beneath said 1.2.6.

findFirstFixedVersion now takes the installed version and walks each
range's events in order, pairing introduced with fixed so a range that
reintroduces a vulnerability is handled. Fixes whose window contains the
installed version win; when no window contains it the previous
lowest-fix behaviour is kept so a finding's remediation stays visible.

This is distinct from the pre-release ordering bug in compareVersions:
even with a correct comparator the global minimum is still the wrong
branch. It is also distinct from the cross-package leak, which was the
right range on the wrong package.
@sonukapoor
sonukapoor force-pushed the bugfix/fixed-version-range-scoping branch from 3f69cc9 to b016ec1 Compare September 5, 2026 19:59
@sonukapoor
sonukapoor merged commit 9622d94 into main Sep 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scanner): findFirstFixedVersion picks the lowest fix across all ranges, ignoring which range the installed version is in

1 participant