Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

RSAKeyFormatHelper does not reject nonsense RSAPrivateKey versions

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

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

Inizia con la convalida in RSAKeyFormatHelper.Pkcs1.cs alle righe 23-25 ed esamina la definizione firmata di Version in PrivateKeyInfoAsn.xml.cs. Traccia il percorso esistente di decodifica delle chiavi private RSA, aggiungi la copertura per le versioni negative e verifica che un RSAPrivateKey con qualsiasi versione negativa venga rifiutato anziché essere trattato come versione 0.

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

Descrizione

area-System.Security untriaged
Description

If an RSAPrivateKey has a version of -1 it decodes successfully and is treated as 0.

https://github.com/dotnet/runtime/blob/0598ca0a45c1f29be94f889a1fc6e9b30c40ea64/src/libraries/Common/src/System/Security/Cryptography/RSAKeyFormatHelper.Pkcs1.cs#L23-L25

Version is a signed integer, so it can contain negative values:

https://github.com/dotnet/runtime/blob/0598ca0a45c1f29be94f889a1fc6e9b30c40ea64/src/libraries/Common/src/System/Security/Cryptography/Asn1/PrivateKeyInfoAsn.xml.cs#L15

Reproduction Steps

Construct an RSAPrivateKey with a version of -1, or any other negative number.

Expected behavior

The RSAPrivateKey should be rejected.

Actual behavior

The RSAPrivateKey version is treated as 0.

Regression?

No

Known Workarounds

No response

Configuration

No response

Other information

RFC 8017 and RFC 3447 define version as

Version ::= INTEGER { two-prime(0), multi(1) }
               (CONSTRAINED BY
               {-- version must be multi if otherPrimeInfos present --}

Since .NET does not support multi-prime values for key imports, the version check should probably just be != 0.

Lingua principale
C#
Stelle
18.3k
Fork
5.6k
Merge medio
2g 17h
PR unite (30g)
615

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 dotnet/runtime

Tutte le issue di dotnet/runtime

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.