Repository navigation
set_tls_verify_peer: use peer_info callback for relay cert verification - #591
Merged
Merged
Conversation
The relay SSL_CTX was given verify_peer_identity(), which reads a struct connection_closure from SSL ex_data slot 1. Relay connections store a struct peer_info there instead (tls_ctx_client_setup() sets it to &relay_closure->relay_name), so verify_peer() read ->name and ->ipaddr past the end of the relay_closure and passed the result to validate_hostname(). Use tls_client.c's peer_info-based callback, now exported as tls_verify_peer(), for the relay context.
millert
approved these changes
Nov 4, 2026
millert
left a comment
Collaborator
There was a problem hiding this comment.
It would be nice to be able to use the same verify function in both cases, but embedding struct peer_info into struct connection_closure makes the code a bit ugly. This seems like the best solution for now.
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.
Heap overread in relay TLS certificate verification
set_tls_verify_peer()installsverify_peer_identity()on the relaySSL_CTX, but that callback reads astruct connection_closurefrom SSL ex_data slot 1. Relay connections store astruct peer_infothere instead (tls_ctx_client_setup()sets it to&relay_closure->relay_name), so during the handshakeverify_peer()reads->nameand->ipaddrfrom past the end of the 248-byterelay_closureand hands the result tovalidate_hostname()insudo_logsrvd. Withtls_checkpeerset on the relay, any client connection that opens a relay connection reaches this path. Beyond the out-of-bounds read, the relay certificate's host check is then computed from adjacent heap rather than the configured relay name, so it fails closed on a zeroed heap and could misvalidate with groomed heap.The relay wants the same peer_info-based check the sendlog client already does, so this exports that callback from tls_client.c as
tls_verify_peer()and uses it for the relay context. The server accept path keepsverify_peer_identity(), which is where theconnection_closurereally lives.Confirmed with AddressSanitizer: before the change a relayed log triggers a heap-buffer-overflow READ in
verify_peer, 32 bytes past a 248-byterelay_closure; after it the handshake validates against the relay name and the log forwards.