Support signature verification against a custom COREPACK_NPM_REGISTRY
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- nodejs, typescript
Direzione di ricerca
Inizia in sources/npmRegistryUtils.ts, all'interno di verifySignature, quindi segui in che modo COREPACK_NPM_REGISTRY, l'autenticazione e COREPACK_INTEGRITY_KEYS influenzano la risoluzione delle chiavi attendibili. Il lavoro è completato quando i registry personalizzati possono fornire chiavi da /-/npm/v1/keys senza sostituire le chiavi incluse, le chiavi di integrità esplicite mantengono la precedenza e le risposte alle chiavi non riuscite o malformate usano un fallback sicuro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When COREPACK_NPM_REGISTRY points at a private registry that re-signs packages with its own key, corepack prepare / corepack install fail with:
Usage Error: The package was not signed by any trusted keys
Corepack fetches package metadata and tarballs from the configured registry, but it only ever verifies signatures against the npm public keys bundled in config.json (or a manually supplied COREPACK_INTEGRITY_KEYS). It never consults the configured registry's own published keys, so a package signed by that registry can never be trusted.
Where it happens
sources/npmRegistryUtils.ts, verifySignature:
const {npm: trustedKeys} = process.env.COREPACK_INTEGRITY_KEYS
? JSON.parse(process.env.COREPACK_INTEGRITY_KEYS)
: defaultConfig.keys; // <-- always npmjs keys, even when COREPACK_NPM_REGISTRY is a private registry
The registry URL and auth are already known here (COREPACK_NPM_REGISTRY, COREPACK_NPM_TOKEN, etc.), but the registry's /-/npm/v1/keys endpoint is never fetched.
Why this can't reasonably be worked around by users
- There's no way for many consumers (e.g. Dependabot jobs) to inject
COREPACK_INTEGRITY_KEYSinto the environment. .corepack.envis not loaded by theprepare/installsubcommands (#741), so committing config doesn't help.- The result is broken installs for anyone behind a re-signing private registry (Cloudsmith, and similar), across every corepack-driven tool (npm/pnpm/yarn activation, and downstream tools like Dependabot and mise).
Proposed change
When a non-default COREPACK_NPM_REGISTRY is configured and COREPACK_INTEGRITY_KEYS is not explicitly set, corepack should fetch that registry's signing keys from <registry>/-/npm/v1/keys (the standard npm registry keys endpoint) and trust them in addition to the bundled npm keys.
Trusted-key resolution would become:
| Config | Trusted keys |
|---|---|
COREPACK_INTEGRITY_KEYS set |
that value (unchanged, explicit override wins) |
| default npmjs registry | bundled npm keys (unchanged) |
custom COREPACK_NPM_REGISTRY |
registry's /-/npm/v1/keys + bundled npm keys |
Merging (rather than replacing) keeps working for registries that proxy packages while preserving npm's original signatures, and adds trust for packages the registry re-signs with its own key.
Rationale / trust model
Corepack already downloads and executes the package manager binary from COREPACK_NPM_REGISTRY. Trusting that same registry's published signing keys is strictly less privilege than that, and mirrors what the npm CLI already does (it verifies against the configured registry's keys). It also aligns with npm's registry signature spec, which defines /-/npm/v1/keys as the registry's key endpoint.
Safety
- If the keys fetch fails or returns an empty/malformed body, fall back to the bundled npm keys rather than failing or disabling verification.
Prior art
dependabot/dependabot-core#15568implements this externally by fetching the registry keys and injectingCOREPACK_INTEGRITY_KEYSa workaround that would be unnecessary if corepack did this natively.
- Lingua principale
- TypeScript
- Stelle
- 3.8k
- Fork
- 279
- Merge medio
- 1h 47m
- PR unite (30g)
- 2
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nodejs/corepack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Tutte le issue di nodejs/corepack
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mksglu/context-mode#1200 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/claude-code#96687 ·
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
AOSSIE-Org/DebateAI#582 · 2 commenti ·