Fix odd-length CertificateRequest signature_algorithms acceptance#10630
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request hardens the TLS 1.2 CertificateRequest parser by rejecting malformed supported_signature_algorithms vectors whose length is not an even multiple of the 2‑byte SignatureAndHashAlgorithm element size, aligning behavior with existing TLS 1.3 parsing.
Changes:
- Reject odd-length TLS 1.2
supported_signature_algorithmsinDoCertificateRequest()withBUFFER_ERRORbefore algorithm selection. - Add a regression test that performs a real TLS 1.2 memio handshake, corrupts the
CertificateRequestsig-algs vector length parity while keeping length fields self-consistent, and asserts the client fails withBUFFER_ERROR. - Register the new test in the TLS API test list.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/internal.c | Adds an explicit modulo check to reject malformed TLS 1.2 sig-algs vectors before calling PickHashSigAlgo(). |
| tests/api/test_tls.c | Adds a memio-based regression test that mutates a server CertificateRequest to have an odd sig-algs vector length and expects BUFFER_ERROR. |
| tests/api/test_tls.h | Declares and registers the new regression test in the TLS test group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10630
Scan targets checked: none
Failed targets: wolfcrypt-rs-bugs, wolfssl-bugs, wolfssl-src
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10630
Scan targets checked: none
Failed targets: wolfcrypt-rs-bugs, wolfssl-bugs, wolfssl-src
Description
The TLS 1.2 CertificateRequest parser bounds-checked the supported_signature_algorithms vector but never verified that its length is an even multiple of the 2-byte SignatureAndHashAlgorithm element size. PickHashSigAlgo iterates while (i+1) < hashSigAlgoSz, so an odd trailing byte was silently ignored — a malformed vector (e.g. length 3: one valid pair + 1 junk byte) could select an algorithm and return success instead of being rejected.
This adds the missing parity check, matching what the TLS 1.3 signature_algorithms extension parser already does (TLSX_SignatureAlgorithms_Parse in src/tls.c).
Addressed by f_4890.
Changes
Testing