The vulnerability exists in the aardvark-dns server's handling of TCP DNS requests. Specifically, the CoreDns::handle_tcp_stream function, which is responsible for reading DNS messages from a TCP stream, enters an infinite loop if it receives a malformed packet that causes a parsing error.
The root cause is improper error handling within a loop. The function hickory_stream.next() returns a Result. In the vulnerable code, this Result was passed down to CoreDns::process_message. process_message would log the error and return, but the loop in handle_tcp_stream would not be broken. This caused the code to repeatedly attempt to read from the faulty stream, resulting in 100% CPU utilization.
The patch addresses this by checking the Result from hickory_stream.next() directly within handle_tcp_stream. If an error is present, it now logs the error and executes a break statement, terminating the loop and closing the problematic TCP connection. The signature of CoreDns::process_message was also changed to no longer accept a Result, enforcing that error handling happens at the stream-handling layer.
Therefore, during exploitation, a profiler would show high activity in CoreDns::handle_tcp_stream as it spins in the infinite loop. CoreDns::process_message would also be called repeatedly in the vulnerable version.