Commit b48eb17
committed
fix(security): vuln-scan false positive from checking declared semver range instead of resolved version
_parse_bun_lock() collected packages from TWO sources: workspaces.dependencies
(declared semver ranges from package.json, e.g. '^9.0.0') AND packages
(resolved concrete versions from the lockfile, e.g. '9.0.2'). Both were fed
into the same vulnerability-matching loop as if they were equally valid
'installed versions'.
_compare_versions()'s _parse_ver() extracts leading digits per dot-separated
segment via regex ^(\d+) — for '^9.0.0', the first segment '^9' has no
leading digit (the caret isn't stripped), so it silently parses to 0. This
makes '^9.0.0' compare as if it were '0.0.0', matching ANY '<X.Y.Z'
vulnerable_range regardless of the real installed version.
Found via real-codebase validation (Coretax-Auto-Downloader KDS backend):
jsonwebtoken reported 'installed_version': '^9.0.0' against
'vulnerable_range': '<9.0.0' — 9.0.0 is not less than 9.0.0, so this was a
false positive purely from checking the declared range string. Fix: only
collect from the 'packages' (resolved) section — remove the
workspaces.dependencies collection entirely, since it duplicates data
already present (correctly, as concrete versions) in 'packages'.
Verified: total vuln findings 22 -> 13, jsonwebtoken false positives (4)
eliminated entirely.1 parent 6f5ee05 commit b48eb17
1 file changed
Lines changed: 12 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3471 | 3471 | | |
3472 | 3472 | | |
3473 | 3473 | | |
3474 | | - | |
3475 | | - | |
3476 | | - | |
3477 | | - | |
3478 | | - | |
3479 | | - | |
3480 | | - | |
3481 | | - | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
3482 | 3486 | | |
3483 | 3487 | | |
3484 | 3488 | | |
| |||
0 commit comments