Forge doesn't validate version field when parsing RSA PRIVATE KEY PEM

Aperta
#1,143 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
javascript

Direzione di ricerca

Start with the parse_key.js reproduction and the forge.pki.privateKeyFromPem entry point, using invalid.key to observe the current behavior. The change is complete when an RSA PRIVATE KEY with a version other than 0 or 1 is rejected, and the reproduction no longer prints a parsed private key.

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

Descrizione

fc8017 shows: "An RSA private key should be represented with the ASN.1 type RSAPrivateKey: RSAPrivateKey ::= SEQUENCE {
version Version,
modulus INTEGER, -- n
publicExponent INTEGER, --e
privateExponent INTEGER, -- d
prime1 INTEGER, --p
prime2 INTEGER, -- q
exponent1 INTEGER, -- d mod (p-1)
exponent2 INTEGER, -- d mod (q-1)
coefficient INTEGER, -- (inverse of q) mod p
otherPrimeInfos OtherPrimeInfos OPTIONAL
},
and, for version, version is the version number, for compatibility with future revisions of this document. It SHALL be 0 for this version of the document, unless multi-prime is used; in which case, it SHALL be 1." However, here forge accepts a key with version number 17.

To Reproduce:
Steps to reproduce the behavior:

const forge = require('node-forge');
const fs = require('fs');
const filePath = process.argv[2];
const keyPem = fs.readFileSync(filePath, 'utf8');
const privateKey = forge.pki.privateKeyFromPem(keyPem);
console.dir(privateKey, { depth: null, colors: true });

node parse_key.js invalid.key

Expected behavior
Since the version number is not 0 or 1, it should be rejected.

invalid.zip

Lingua principale
JavaScript
Stelle
5.4k
Fork
874
Merge medio
3m
PR unite (30g)
6

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 digitalbazaar/forge

Tutte le issue di digitalbazaar/forge

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.