Skip to content

fix(remediation): stop parent-update targets merging into install targets - #1113

Open
osfv wants to merge 1 commit into
OWASP:mainfrom
osfv:fix/issue-1007-parent-update-target-merge
Open

fix(remediation): stop parent-update targets merging into install targets#1113
osfv wants to merge 1 commit into
OWASP:mainfrom
osfv:fix/issue-1007-parent-update-target-merge

Conversation

@osfv

@osfv osfv commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What changed and why

suggestedFixCommands could emit a version that does not exist for the package it names, e.g. npm install axios@4.0.6 where 4.0.6 is form-data's version.

The reported diagnosis (index-aligned lookup) pointed at the right area but the mechanism is slightly different. In buildSuggestedFixCommandPlan the accumulator is keyed by package name only. A transitive finding whose remediation is a within-range refresh produces a parent-update target with package = the parent (axios) and targetVersion = the child's version (4.0.6), because that target means "refresh form-data within axios's range", not "install axios@4.0.6". When a direct finding for axios also exists, the two land on the same key, and upsertTarget's "higher version wins" merge compares versions of two different packages, so form-data's 4.0.6 replaces axios's 1.19.0 and the merged target is emitted as a direct install.

Fix: key parent-update targets in their own keyspace, per parent and per child, so they only merge with a refresh of the same child through the same parent. Install targets (direct / parent-upgrade) keep merging per package exactly as before. Each finding keeps resolving to its own target through findFixTargetForFinding, and coverage counts are unchanged.

For the repro in the issue the plan now emits npm update axios && npm install axios@1.19.0 js-yaml@4.3.1. The refresh is kept rather than dropped because npm install axios@1.19.0 alone does not guarantee npm re-resolves an already-locked form-data@4.0.5 that still satisfies the range.

Tests: tests/remediation/fix-commands-parent-update-merge.test.ts covers the issue repro, two refreshes of different children through the same parent, and the unchanged merge of repeated install targets.

Verified against current main (#1084 / #1085 moved findFirstFixedVersion but do not touch this path).

Note: #1007 is assigned to @alamb-hex. The maintainer's check-in on Sept 6 had no reply, so I went ahead; happy to close this in favour of theirs if they are still working on it.

Closes #1007

…gets

A within-range refresh (parent-update) target carries the vulnerable
child's version under the parent's package name. Keyed by package name
alone it merged with the direct install target for the same parent, and
the child's higher version won the merge, so the plan pinned the parent
to a version that does not exist (npm install axios@4.0.6, where 4.0.6
is form-data's version).

Key parent-update targets separately, per parent and child, so they only
merge with a refresh of the same child through the same parent. Install
targets keep merging per package as before.

Closes OWASP#1007
@osfv
osfv requested a review from sonukapoor as a code owner September 9, 2026 16:50
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.

suggestedFixCommands emits a version that does not exist (cross-wired from another finding)

1 participant