Add QUIC support for Minetest
Problem
In the current Minetest protocol, servers are unauthenticated and the connection is unencrypted. It is therefore always possible for a MITM to hijack or snoop on a connection after a successful login.
Additionally, the protocol uses UDP, and so must implement features such as reliability (re-transmission), flow control, packet re-ordering, and channels. The implementations of these features are necessarily simple and unlikely to be optimal, compared to implementations by well-funded network engineering teams.
Solutions
Minetest can make use of QUIC as an alternative to UDP for establishing connections to a server.
How QUIC works
QUIC uses the same security mechanism as https, so a connection to a server with a host name will be secure by default. The server operator will need to generate a certificate for their domain or subdomain, e.g., using Let's Encrypt or other provider.
Connecting to a server by IP will still be encrypted, but using an unverified certificate (which could be self-signed). The user will be warned that this is insecure. The server's certificate will be cached, so that subsequent connects expect the same certificate. If the certificate changes, the user will be loudly warned. This can't prevent a MITM attack from occurring on the very first connect, but it can detect and prevent future attacks.
After the TLS handshake, QUIC connections remain encrypted using a negotiated ephemeral cipher. The details are handled by the QUIC protocol.
How Minetest can use QUIC
QUIC provides channels (streams), reliable transmission, and in-order packet delivery. Minetest's protocol currently emulates these things over UDP. It will be possible to use QUIC for all of these features, in addition to raw datagrams (rfc 9221) for plain UDP-like delivery.
It may also be possible to have Minetest serve both the UDP protocol and QUIC protocol on the same port. (Investigation is needed)
Source: luanti-org/luanti