Skip to content

Support fragmented TLS handshake records#431

Merged
9seconds merged 1 commit into9seconds:masterfrom
appolimp:tls-record-reassembly-pr
Apr 1, 2026
Merged

Support fragmented TLS handshake records#431
9seconds merged 1 commit into9seconds:masterfrom
appolimp:tls-record-reassembly-pr

Conversation

@appolimp
Copy link
Copy Markdown
Contributor

@appolimp appolimp commented Apr 1, 2026

DPI bypass tools like ByeDPI fragment a single TLS record into multiple records to evade censorship. This broke ReadClientHello because it assumed the entire ClientHello arrives in one TLS record.

Add reassembleTLSHandshake that reads continuation records and reconstructs a single TLS record before parsing and HMAC verification. Per RFC 5246 Section 6.2.1, handshake messages may be fragmented across multiple records — this is valid TLS behavior.

@appolimp appolimp force-pushed the tls-record-reassembly-pr branch 4 times, most recently from d3ae098 to 8bb9716 Compare April 1, 2026 05:39
DPI bypass tools like ByeDPI fragment a single TLS record into multiple
records to evade censorship. This broke ReadClientHello because it
assumed the entire ClientHello arrives in one TLS record.

Add reassembleTLSHandshake that reads continuation records and
reconstructs a single TLS record before parsing and HMAC verification.
Per RFC 5246 Section 6.2.1, handshake messages may be fragmented
across multiple records — this is valid TLS behavior.
@appolimp appolimp force-pushed the tls-record-reassembly-pr branch from 8bb9716 to 38abee7 Compare April 1, 2026 06:05

RUN set -x \
&& version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always)" \
&& version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always 2>/dev/null || echo dev)" \
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

из-за этого сборка в докере из исходников не работала

@appolimp appolimp marked this pull request as ready for review April 1, 2026 06:09
@9seconds
Copy link
Copy Markdown
Owner

9seconds commented Apr 1, 2026

Спасибо! Немного стыдно, но я совсем не знал о такой фрагментации, поэтому мне нужно немножко времени, чтобы во всем разобраться.

@appolimp appolimp closed this Apr 1, 2026
@appolimp appolimp reopened this Apr 1, 2026
@appolimp
Copy link
Copy Markdown
Contributor Author

appolimp commented Apr 1, 2026

я случайно)

Да, я тоже удивился. Из-за этого у меня не работает прокси через wifi (так как на роутере есть bydpi)

@9seconds
Copy link
Copy Markdown
Owner

9seconds commented Apr 1, 2026

Почитал, разобрался, наконец-то встало на место, зачем там 2 раза длина повторяется. PR тоже хороший, я не вижу каких-то явных проблем или недостатков. Я его вмержу, но попробую сам для себя повторить поддержку такой фрагментации, отрефакторить. Не потому, что код не нравится - код нравится; мне просто критически важно, чтобы мозг сам такое повторил, и я очень хорошо осознавал, чего каждая строчка делает. В этом смысле отдельное спасибо за тесты! :)

@9seconds 9seconds merged commit e8368f7 into 9seconds:master Apr 1, 2026
17 checks passed
@appolimp appolimp deleted the tls-record-reassembly-pr branch April 1, 2026 07:35
@appolimp
Copy link
Copy Markdown
Contributor Author

appolimp commented Apr 1, 2026

Спасибо за прокси!

@9seconds 9seconds mentioned this pull request Apr 1, 2026
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.

2 participants