fix(v3): fix strict mode TLS 1.3 detection bug#5
Open
36huo wants to merge 1 commit into
Open
Conversation
- v3_server.go: isServerHelloSupportTLS13 treated extensionListLength as number of extensions instead of total byte length, causing out-of-bounds reads - v3_client.go: isServerHelloSupportTLS13 was called with buffer[5:] (already stripped TLS record header), but the function expected the full frame including header, causing parsing offset error Fixes: strict mode always fails with TLS 1.3 servers
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.
Summary
isServerHelloSupportTLS13treatedextensionListLengthas number of extensions instead of total byte length, causing out-of-bounds readsisServerHelloSupportTLS13was called withbuffer[5:](already stripped TLS record header), but the function expected the full frameBug Details
Bug 1: Extension parsing loop (v3_server.go)
extensionListLengthis the total byte length of all extensions, NOT the number of extensions. The original code used it as a loop counter, causing the parser to read far past the actual data.Fix: Track bytes consumed with
extensionsReadand add4 + extensionLengthper iteration.Bug 2: Buffer offset (v3_client.go)
Client called
isServerHelloSupportTLS13(buffer[5:])after stripping the 5-byte TLS record header, but the function internally usessessionIDLengthIndex=43which assumes the full frame is passed.Fix: Pass the full buffer instead of
buffer[5:].Testing
Tested with
cloud.tencent.com:443(confirmed TLS 1.3) + strict mode enabled.5/5 random string echo tests pass.