Skip to content

Commit 31478e4

Browse files
committed
Fix ClientHello parser for TLS 1.3, issue #84
reported by @GhostNaix
1 parent 66f2a4c commit 31478e4

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/protoautossl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://www.roe.ch/SSLsplit
44
*
55
* Copyright (c) 2009-2019, Daniel Roethlisberger <[email protected]>.
6-
* Copyright (c) 2017-2024, Soner Tari <[email protected]>.
6+
* Copyright (c) 2017-2025, Soner Tari <[email protected]>.
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -255,7 +255,7 @@ protoautossl_peek_and_upgrade(pxy_conn_ctx_t *ctx)
255255

256256
/* peek the buffer */
257257
inbuf = bufferevent_get_input(ctx->src.bev);
258-
if (evbuffer_peek(inbuf, 1024, 0, vec_out, 1)) {
258+
if (evbuffer_peek(inbuf, 2048, 0, vec_out, 1)) {
259259
if (ssl_tls_clienthello_parse(vec_out[0].iov_base, vec_out[0].iov_len, 0, &chello, &ctx->sslctx->sni) == 0) {
260260
if (OPTS_DEBUG(ctx->global)) {
261261
log_dbg_printf("Peek found ClientHello\n");

src/protossl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://www.roe.ch/SSLsplit
44
*
55
* Copyright (c) 2009-2019, Daniel Roethlisberger <[email protected]>.
6-
* Copyright (c) 2017-2024, Soner Tari <[email protected]>.
6+
* Copyright (c) 2017-2025, Soner Tari <[email protected]>.
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -1353,7 +1353,7 @@ protossl_fd_readcb(evutil_socket_t fd, UNUSED short what, void *arg)
13531353
// Child connections will use the sni info obtained by the parent conn
13541354
/* for SSL, peek ClientHello and parse SNI from it */
13551355

1356-
unsigned char buf[1024];
1356+
unsigned char buf[2048];
13571357
ssize_t n;
13581358
const unsigned char *chello;
13591359
int rv;

src/ssl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* https://www.roe.ch/SSLsplit
44
*
55
* Copyright (c) 2009-2019, Daniel Roethlisberger <[email protected]>.
6+
* Copyright (c) 2017-2025, Soner Tari <[email protected]>.
67
* All rights reserved.
78
*
89
* Redistribution and use in source and binary forms, with or without
@@ -2166,7 +2167,7 @@ ssl_tls_clienthello_parse(const unsigned char *buf, ssize_t sz, int search,
21662167
* updated for TLS 1.3 once that is standardized and still
21672168
* compatible with this parser; remember to also update the
21682169
* inner version check below */
2169-
if (p[0] != 0x03 || p[1] > 0x03)
2170+
if (p[0] != 0x03 || p[1] > 0x04)
21702171
continue;
21712172
p += 2; n -= 2;
21722173

@@ -2218,7 +2219,7 @@ ssl_tls_clienthello_parse(const unsigned char *buf, ssize_t sz, int search,
22182219
continue;
22192220
DBG_printf("clienthello version %02x %02x\n", p[0], p[1]);
22202221
/* inner version check, see outer one above */
2221-
if (p[0] != 0x03 || p[1] > 0x03)
2222+
if (p[0] != 0x03 || p[1] > 0x04)
22222223
continue;
22232224
p += 2; n -= 2;
22242225

0 commit comments

Comments
 (0)