Skip to content

std.crypto.x509: an ECDSA r or s longer than 32 bytes is not a signature, and the dead inline parse is gone (#1057) - #2670

Merged
ehartford merged 1 commit into
mainfrom
fix-1057
Oct 25, 2026
Merged

ehartford merged 1 commit into
mainfrom
fix-1057

Conversation

@ehartford

@ehartford ehartford commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: ecdsa_verify_der_sig (lib/std/crypto/x509.w) copied r and s into
32-byte arrays at 32 - len with no bound on len, so an INTEGER over 32
bytes (after its sign byte) indexed below 0 and panicked: a peer-controlled
signature stopping the process. x509_verify_signature's own inline ECDSA
parse computed the same thing, discarded it ("Let me re-parse from
scratch") and called ecdsa_verify_der_sig; it is removed.

No regression test: x509_verify_signature has no caller yet (std.tls does
not verify signatures, #1061) and std's crypto is private to std, so no
program reaches it; the audit's probe (SEQ{INT(40 bytes), INT(1)}) is what
the bound answers.

Closes #1057

…ure, and the dead inline parse is gone (#1057)

Root cause: ecdsa_verify_der_sig (lib/std/crypto/x509.w) copied r and s into
32-byte arrays at `32 - len` with no bound on len, so an INTEGER over 32
bytes (after its sign byte) indexed below 0 and panicked: a peer-controlled
signature stopping the process. x509_verify_signature's own inline ECDSA
parse computed the same thing, discarded it ("Let me re-parse from
scratch") and called ecdsa_verify_der_sig; it is removed.

No regression test: x509_verify_signature has no caller yet (std.tls does
not verify signatures, #1061) and std's crypto is private to std, so no
program reaches it; the audit's probe (SEQ{INT(40 bytes), INT(1)}) is what
the bound answers.
@ehartford
ehartford added this pull request to stack #2678 October 25, 2026 22:52
@ehartford ehartford changed the title fix 1057 std.crypto.x509: an ECDSA r or s longer than 32 bytes is not a signature, and the dead inline parse is gone (#1057) Oct 25, 2026
@ehartford
ehartford marked this pull request as ready for review October 25, 2026 23:05
@ehartford
ehartford merged commit 592fb30 into main Oct 25, 2026
@ehartford
ehartford deleted the fix-1057 branch October 25, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[crypto] ecdsa_verify_der_sig panics (DoS) on over-long DER signature INTEGERs instead of rejecting

1 participant