rustls: precaution for possible malicious certs_num from peer#19397
Closed
x2018 wants to merge 9 commits into
Closed
rustls: precaution for possible malicious certs_num from peer#19397x2018 wants to merge 9 commits into
x2018 wants to merge 9 commits into
Conversation
bagder
reviewed
Nov 7, 2025
Contributor
Author
|
The backend |
vszakats
reviewed
Nov 7, 2025
vszakats
reviewed
Nov 7, 2025
0b315a1 to
0f7fe69
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
Author
I made an attempt. If anything is improper, I will reset the changes for them. wolfSSL_CTX_load_verify_buffer() have a buffer size limitation already. By the way, I add a precaution check for preventing invalid socket for wolfssl. For mbedtls, it sets the verification callback via mbedtls_ssl_conf_verify(). Our local function is |
bagder
approved these changes
Nov 8, 2025
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does a precaution for possible malicious certs_num from peer. By doing so, we do not need to worry about the possible issues of the cast for
num_certs, or malicious servers which send abnomal number of certs.Note that
MAX_ALLOWED_CERT_AMOUNTis based on the code of https://github.com/curl/curl/blob/master/lib/vtls/openssl.c#L352.The handling is also a copy of code from openssl.c:
Other:
The type of the second parameter of rustls_connection_get_peer_certificate is
size_t, so we do not need to cast thenum_certstointthere, just like the calling at line 1232(cert = rustls_connection_get_peer_certificate(rconn, i);).