[Bug] SPDX SBOM can emit duplicate SPDXID values when a colliding package shares a suffixed ID

Aperta Adatta ai principianti
#1,859 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, security

Direzione di ricerca

Inizia da makeSpdxId in src/output/spdx.ts e segui come vengono tracciati gli ID generati nella mappa used. Riproduci la collisione con i tre nomi e le versioni dei pacchetti elencati nell’issue, poi controlla i valori SPDXID nell’output di buildSpdxDocument. Il lavoro è concluso quando ogni pacchetto ottiene uno SPDXID univoco in quel caso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Summary

makeSpdxId in src/output/spdx.ts disambiguates sanitized SPDXID collisions by appending -${seen + 1} to base, but it never records the newly generated suffixed ID (${base}-${seen + 1}) in the used map. If another package later sanitizes directly to that suffixed string (for example, a prerelease version like [email protected]), used.get(base) returns undefined and emits the exact same SPDXID twice.

Per the SPDX 2.3 specification, every SPDXID within an SPDX document must be unique. Duplicate SPDXID values break document validation and make relationships ambiguous.

Environment

  • OS: macOS
  • Node.js version: v22.x
  • Package manager: npm
  • Lockfile type: package-lock.json
  • CVE Lite CLI version: main (v1.44.0)

Expected behavior

makeSpdxId should guarantee that every returned SPDXID is globally unique within the document (for example, checking and registering the final candidate ID in a Set / Map loop until an unused ID is found).

Actual behavior

When the following three packages appear in the same SBOM:

  1. @scope/[email protected] -> SPDXRef-scope-pkg-1.0.0 (registered in used)
  2. [email protected] -> SPDXRef-scope-pkg-1.0.0-2 (NOT registered in used)
  3. [email protected] -> SPDXRef-scope-pkg-1.0.0-2 (duplicate SPDXID)

Two distinct packages end up with the identical SPDXID "SPDXRef-scope-pkg-1.0.0-2".

Reproduction

Call buildSpdxDocument with packages:

  • @scope/pkg at 1.0.0
  • scope-pkg at 1.0.0
  • scope-pkg at 1.0.0-2

Inspect the SPDXID fields in doc.packages: two packages have SPDXID: "SPDXRef-scope-pkg-1.0.0-2".

Relevant files or output

  • src/output/spdx.ts (lines 135-144, makeSpdxId)
Lingua principale
TypeScript
Stelle
806
Fork
209
Merge medio
3g 16h
PR unite (30g)
133

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OWASP/cve-lite-cli

Tutte le issue di OWASP/cve-lite-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.