Skip to content

fix(v3): fix strict mode TLS 1.3 detection bug#5

Open
36huo wants to merge 1 commit into
SagerNet:mainfrom
36huo:fix-tls13-strict-mode
Open

fix(v3): fix strict mode TLS 1.3 detection bug#5
36huo wants to merge 1 commit into
SagerNet:mainfrom
36huo:fix-tls13-strict-mode

Conversation

@36huo
Copy link
Copy Markdown

@36huo 36huo commented May 11, 2026

Summary

  • 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

Bug Details

Bug 1: Extension parsing loop (v3_server.go)

extensionListLength is 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 extensionsRead and add 4 + extensionLength per 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 uses sessionIDLengthIndex=43 which 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.

- 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
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.

1 participant