Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

RSAKeyFormatHelper does not reject nonsense RSAPrivateKey versions

Đang mở Phù hợp với người mới
#134,659 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
cryptography, security

Hướng nghiên cứu

Bắt đầu với phần xác thực tại RSAKeyFormatHelper.Pkcs1.cs, dòng 23-25, và kiểm tra định nghĩa Version đã ký trong PrivateKeyInfoAsn.xml.cs. Truy vết đường dẫn giải mã khóa riêng RSA hiện có, bổ sung độ bao phủ cho các phiên bản âm và xác minh rằng RSAPrivateKey với bất kỳ phiên bản âm nào đều bị từ chối thay vì được coi là phiên bản 0.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
18.3k
Fork
5.6k
Merge trung bình
2 ngày 18 giờ
Pull request đã merge (30 ngày)
617

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/runtime

Tất cả issue của dotnet/runtime

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.