mirror of
https://github.com/tailscale/tailscale.git
synced 2026-09-22 03:25:16 -04:00
dnsQueryForName builds the query for GET /dns-query?q=<name>, the peerAPI's interactive debug mode. The name comes from the peer's query string and the only thing done to it is appending a trailing dot, but the query is built with dnsmessage.MustNewName, which panics as soon as the name is longer than 255 bytes. The panic happens before the query reaches the resolver, so the nameAllowed filter never gets a say and only sourceAllowed has to be true: any of the user's own untagged devices, and any peer an extension hook lets through, such as a client using this node as an exit node with DNS proxying allowed. http.Server recovers it, so tailscaled survives, but the peer's connection is dropped instead of answered and the node logs a panic trace per request. Just under the limit the name was mishandled too: a 255-byte name is accepted by NewName but rejected by Question when it packs the name, and that error was dropped, so Finish returned a well-formed query with no question in it which was then handed to the resolver. Have dnsQueryForName use NewName, check the error from Question, and return the error from Finish. handleDNSQuery turns a name it cannot build a query for into the 400 it already uses for the other malformed-request cases. Fixes #21307 Change-Id: I7c1a4b7e4f9a1d2c3b5e8f0a6d4c2b9e1f3a7d50 Signed-off-by: leoca <leo.camus23@gmail.com>