The vulnerability exists in the CoreDNS DNS-over-HTTPS (DoH) GET request handler. A remote, unauthenticated attacker can send a GET request to the /dns-query endpoint with an oversized dns query parameter, causing a denial of service.
The root cause is the lack of input validation before processing the dns parameter. The analysis of the provided patches and vulnerability description reveals the following flow:
- The request is handled by the
DoH.RequestToMsg function in plugin/pkg/doh/doh.go.
- For GET requests,
DoH.RequestToMsg calls the requestToMsgGet function.
- The
requestToMsgGet function extracts the dns query parameter from the URL. Before the patch, it did not perform any size checks on this parameter's value.
- The potentially massive string is then passed to the
base64ToMsg function.
base64ToMsg attempts to Base64 decode the entire string, which consumes a large amount of CPU and memory.
The patch, introduced in commit c967ab5c1c4882ab3c8e548118d53032709e812b, adds a size check in the requestToMsgGet function, rejecting requests with an oversized dns parameter before the expensive decoding operation is performed.
The identified vulnerable functions are those in this processing chain that would appear in a runtime profile during an attack. The profiling data in the advisory confirms that DoH.RequestToMsg, requestToMsgGet, and base64ToMsg are the key functions involved in the vulnerable execution path.