The practice that WireGuard employs here is called "Silence is a Virtue"[0]. That's done to provide DoS mitigation[1] and to prevent other classes of attacks. To quote the paper[0]:
> Several classes of attacks are avoided by not allowing unauthenticated packets to influence any state.
WireGuard servers not responding to unauthenticated clients is a design decision that leads to an advantage, because implementations won't need to allocate any dynamic memory for them. Even further, the protocol can be implemented in such a way, that servers won't need to allocate any dynamic memory for any client. To quote the paper[0] again:
> And more generally, it is possible to implement WireGuard in a way that requires no dynamic memory allocation at all, [...]
On the other hand, SSH servers MUST[2] give a response to all clients and will allocate dynamic memory for unauthenticated peers AFAICS.
So in practice, this means that unauthenticated peers can force OOM errors on SSH servers, where the WireGuard protocol — by design — makes this impossible. SSH DoS mitigations have to be done through other means, e.g. upstream services, which no non-enterprise uses in practice.
Whether or not to decide if that's "dangerous" for you, is up to each individual.
All TCP servers must allocate memory per client. Wireguard is cutting across abstractions for efficiency.
Actually a TCP server could also choose to ignore a client, but only based on the client's IP address and only if you hook into the kernel or use iptables -j DROP
Actually a UDP server also has to allocate memory per client, it's just that it can choose to free it immediately and treat the same client as a new client when it comes back. Then the bottleneck is bandwidth.
No idea about real implementations but is there no stack which allows to preallocate and reuse that memory, for instance for each client's initial negotation phase? So only allocation is needed once the decision is made to continue with the client? That would, at least to me, seem like a rather logical thing to do.
AFAICS your suggestion is exactly what's achieved with UDP and WireGuard, but you're not making the differentiation between kernel and user space. UDP shifts the responsibility of segment handling to the application side, and that can be an advantage to mitigate DoS attacks.
Datagram sockets (UDP) are "connectionless sockets" and the receiving end can stream any segments into pre-allocated memory. Meaning, the kernel streams segments to the application side, where static memory can be emptied and reused, either after allocation limit, after a timeout or after the first unusable segment has been reached.
The issue with TCP here lies in its built-in reliability features. Fixing out-of-sequence segments, and the detection of missing or erroneous segments requires intermediate state. These allocations need to be kept as long as we expect the corrected segments on the kernel side. The application side doesn't need to care for individual segments and only ever sees valid packages. This segment handling is entirely up to the network stack, and there's nothing the application level can do individually. That's up to system-wide TCP settings (tcp_fin_timeout, tcp_keepalive_time, tcp_retries2, tcp_syn_retries, ...)[0].
So the issue with every exposed TCP port is that its memory configurations are applied solely per system/kernel, and not per application. I would be hesitant to run other networking applications on a system alongside an exposed SSH server, but wouldn't be that hesitant alongside an exposed WireGuard server.
So you'd allocate memory per negotiating client. The hypothetical DoS attacker will stack up clients in the negotiation phase if that's where you hold the memory.
> Wireguard is cutting across abstractions for efficiency.
*and security.
SSH uses TCP, WireGuard uses UDP. Like you wrote, the bottleneck in bandwidth could annoy my ISP more, and trigger its DDoS protection, than it annoys the network stack on my VPN server.