The vulnerability lies in the DNS C2 listener's handling of TOTP bootstrap messages. The core of the issue is in the server/c2/dns.go file, where the handleHello function would create a new DNS session for any incoming TOTP message without performing any authentication. This is explicitly shown by the complete removal of the handleHello function in the patch. The handleC2 function was responsible for routing these TOTP messages to the vulnerable handleHello function.
Furthermore, the accumulateInitData function was also vulnerable to resource exhaustion. It lacked checks to limit the number of pending message reassemblies, allowing an attacker to flood the server with partial messages and consume all available memory. The patch addresses this by adding a hard cap on pending initializations and a garbage collection mechanism.
The exploitation of this vulnerability would involve an attacker sending a continuous stream of specially crafted DNS queries of type TOTP. In a runtime profile, this would result in frequent calls to c2.handleC2 and, in the vulnerable version, to c2.handleHello, leading to a rapid increase in the number of DNSSession objects and memory usage. The c2.accumulateInitData function would also be heavily utilized if the attacker sends fragmented messages.