Skip to content

Commit d9d6801

Browse files
author
David Cooper
committed
Avoid ClientHello size bug
As described in testssl#1113, some servers will fail if the length of the ClientHello message is 522, 778, 1034, ... bytes (i.e., if length mod 256 = 10) or 526, 782, 1038, ... bytes (i.e., if length mod 256 = 14). This commit avoid this issue for normal testing by adding a 5-byte padding extension to the message if the length would otherwise be one of these lengths.
1 parent 23df63e commit d9d6801

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

testssl.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11827,6 +11827,7 @@ socksend_tls_clienthello() {
1182711827
# then add a padding extension (see RFC 7685)
1182811828
len_all=$((0x$len_ciph_suites + 0x2b + 0x$len_extension_hex + 0x2))
1182911829
"$offer_compression" && len_all+=2
11830+
[[ 0x$tls_low_byte -gt 0x03 ]] && len_all+=32 # TLSv1.3 ClientHello includes a 32-byte session id
1183011831
if [[ $len_all -ge 256 ]] && [[ $len_all -le 511 ]] && [[ ! "$extra_extensions_list" =~ " 0015 " ]]; then
1183111832
if [[ $len_all -gt 508 ]]; then
1183211833
len_padding_extension=1 # Final extension cannot be empty: see PR #792
@@ -11841,12 +11842,18 @@ socksend_tls_clienthello() {
1184111842
done
1184211843
len_extension=$len_extension+$len_padding_extension+0x4
1184311844
len_extension_hex=$(printf "%02x\n" $len_extension)
11845+
elif [[ ! "$extra_extensions_list" =~ " 0015 " ]] && ( [[ $((len_all%256)) -eq 10 ]] || [[ $((len_all%256)) -eq 14 ]] ); then
11846+
# Some servers fail if the length of the ClientHello is 522, 778, 1034, 1290, ... bytes.
11847+
# A few servers also fail if the length is 526, 782, 1038, 1294, ... bytes.
11848+
# So, if the ClientHello would be one of these length, add a 5-byte padding extension.
11849+
all_extensions="$all_extensions\\x00\\x15\\x00\\x01\\x00"
11850+
len_extension+=5
11851+
len_extension_hex=$(printf "%02x\n" $len_extension)
1184411852
fi
1184511853
len2twobytes "$len_extension_hex"
1184611854
all_extensions="
1184711855
,$LEN_STR # first the len of all extensions.
1184811856
,$all_extensions"
11849-
1185011857
fi
1185111858

1185211859
if [[ 0x$tls_low_byte -gt 0x03 ]]; then

0 commit comments

Comments
 (0)