Skip to content

scancode-next: NuGet name casing bypasses vulnerability lookups #2539

Todo

Description

@keshav-space

Description

Case-only changes to NuGet package IDs can hide known advisories from VulnerableCode and make ScanCode.io's configured vulnerability gate pass. NuGet treats package IDs as case-insensitive, but the vulnerability API compares complete PURL strings exactly. ScanCode.io also associates returned assessments with inventory records by exact PURL spelling.

For example, the real advisory GHSA-j378-6mmw-hqfr identifies System.IO.Pipelines 4.5.0 as affected by CVE-2018-8409. After importing that advisory, querying the lowercase or uppercase spelling returns HTTP 200 with no matching package; the advisory spelling returns the advisory. PackageURL 0.17.6 preserves these valid NuGet spellings. The API's lookup performs no ecosystem-aware comparison:

    def filter_purls(self, purls=[]):
        return PackageV2.objects.filter(package_url__in=purls)

Figure X.1: NuGet identity is compared as an exact string (vulnerablecode/vulnerabilities/models.py#L3722-L3723).

Native .NET SDK 6.0.428 accepted case-only edits to generated lockfiles under locked restore without rewriting them; all restored identical public package bytes. Full Toolkit scans preserved their spelling. Native advisory import/publication, API, consumer, and gate bodies failed the advisory-spelled inventory and passed lower/uppercase variants, with reduced SQLite wiring and bounded versions.

Changing the API lookup alone returns the advisory under its stored spelling, which ScanCode.io’s independent exact-key join still misses. Correcting both comparisons restored detection; fixed-version/unrelated controls stayed clear. The proposed repair spans both repositories; an API explicitly correlating requested spellings is another option. The partial-fix control does not establish an independently exploitable client flaw against today’s unchanged provider.

To reproduce, import/publish GHSA-j378-6mmw-hqfr and POST {"purls":["pkg:nuget/system.io.pipelines@4.5.0"],"details":true} to /api/v3/packages/; compare advisory/lower/uppercase spellings. Only the advisory-spelled request returns the affecting advisory. Fresh inventories pass/fail accordingly; an equivalent spelling already imported or retained old findings can change results. The proof uses reduced SQLite wiring and bounded versions, not full deployments. Its whole-PURL iexact repair is causal evidence, not a name-only production patch.

Recommendations

Short term, compare NuGet package names case-insensitively in vulnerability lookup and in ScanCode.io's response-to-inventory association. Preserve the correct version, qualifiers, and component association, and handle existing differently cased database identities. Rerun affected assessments after correction.

Long term, add a native locked-restore-to-scan regression using one unchanged package under multiple valid ID spellings. Require identical advisory and gate results, and retain fixed-version and unrelated-package controls. Keep normalization specific to each ecosystem; lowercasing every PURL can change case-sensitive identities.

References

Client PermaLink:

def filter_purls(self, purls=[]):
return PackageV2.objects.filter(package_url__in=purls)

Originally reported by @Xenomega

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions