`verify()` raises `TypeError` instead of rejecting when `u1*G + u2*Q` is the point at infinity
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
- 90/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ệ
- cryptography, python
- Lĩnh vực
- cryptography, security
Hướng nghiên cứu
Bắt đầu với Public_key.verifies trong src/ecdsa/ecdsa.py, nơi xy được tính sau các nhánh mul_add và plain. Chạy bộ tái hiện được cung cấp với r = s = 1 và khóa công khai Q = -e*G để xác nhận TypeError, sau đó sửa luồng xác minh để từ chối điểm vô cùng thay vì tính tọa độ x của nó. Thêm hoặc cập nhật phạm vi kiểm thử hồi quy bằng các trường hợp Wycheproof được đề cập trong ecdsa_brainpool*_test.json và xác nhận rằng quá trình xác minh ném BadSignatureError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Versions: python-ecdsa 0.19.2 (latest release), CPython 3.13.15. The code path is unchanged on master as of
2026-11-28 (src/ecdsa/ecdsa.py, Public_key.verifies).
What happens
When the verification sum u1*G + u2*Q is the point at infinity, Public_key.verifies evaluates
v = xy.x() % n with xy.x() returning None, so VerifyingKey.verify() raises
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
instead of BadSignatureError. This happens for a valid public key and a signature with r and s in [1, n-1],
on every curve (reproduced on NIST P-256 and brainpoolP256r1). A caller that catches only BadSignatureError, as the
documentation suggests, gets an unhandled exception on attacker-chosen input.
No forgery: the signature is never accepted.
Reproducer (no test vectors needed)
Choose r = s = 1 and the public key Q = -e*G, so u1*G + u2*Q = e*G - e*G = O:
import hashlib, ecdsa
from ecdsa import VerifyingKey, BadSignatureError
from ecdsa.curves import NIST256p
from ecdsa.util import sigencode_der, sigdecode_der
msg = b"point at infinity during verify"
n, G = NIST256p.order, NIST256p.generator
e = int.from_bytes(hashlib.sha256(msg).digest(), "big")
vk = VerifyingKey.from_public_point(G * ((-e) % n), curve=NIST256p, hashfunc=hashlib.sha256)
try:
vk.verify(sigencode_der(1, 1, n), msg, sigdecode=sigdecode_der)
except BadSignatureError:
print("rejected (expected)")
# actual on 0.19.2: TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
pyca/cryptography rejects the same key, signature and message with InvalidSignature.
The same exception is raised on the Wycheproof testvectors_v1 cases flagged PointDuplication /
ArithmeticError ("duplication bug", "point at infinity during verify", "comparison with point at infinity"):
67 test cases across the five ecdsa_brainpool*_test.json files.
Suggested fix
In Public_key.verifies, after computing xy (both the mul_add and the plain branch):
if xy == ellipticcurve.INFINITY:
return False
Related, but a different path: #341 (TypeError instead of InvalidPointError from
VerifyingKey.from_public_point(INFINITY)).
- Ngôn ngữ chính
- Python
- Star
- 975
- Fork
- 346
- Merge trung bình
- 26 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tlsfuzzer/python-ecdsa
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
tlsfuzzer/python-ecdsa#387 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
tlsfuzzer/python-ecdsa#390 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
tlsfuzzer/python-ecdsa#381 · 1 bình luận · 5 reaction ·
-
ecdsa.keys.VerifyingKey.verify_digest should fail for CurveEdTwCó thể đã có người làm @apoorvdarshan đã nhận 143 ngày trước. Đang mởbug help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
tlsfuzzer/python-ecdsa#349 · 1 bình luận ·
-
feature help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
tlsfuzzer/python-ecdsa#348 · 1 bình luận ·
Tất cả issue của tlsfuzzer/python-ecdsa
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
comet-ml/opik#9877 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Resource]: FlavianĐang mởresource-submission validation-passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
hesreallyhim/awesome-claude-code#3736 · 1 bình luận ·
-
area: trackers bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Review: WordPress copy/snapshot download media with no size cap and a hostname-only origin checkĐang mởperformance product:quill
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Community-Access/quill#2634 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày