Files
dylanhuff-at-coder ae76be47d3 fix: prevent tailnet coordination panics (#29300)
Malformed coordinate requests can panic per-connection coordinator
goroutines and terminate coderd. Disconnect requests and nested cleanup
of peers with full response buffers can also attempt to send on or close
an already-closed channel.

Validate request structure before authorization or state mutation in
both tailnet coordinators, stop processing after disconnect, and avoid
removing a peer twice during nested cleanup. Unexpected per-connection
panics close the affected connection through the existing lost-peer
cleanup.


https://linear.app/codercom/issue/PLAT-595/security-nil-node-in-tailnet-updateself-crashes-entire-coderd-process
2026-09-22 09:31:49 -07:00

32 lines
786 B
Go

package tailnet
import (
"slices"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/tailnet/proto"
)
// ValidateCoordinateRequest checks the structural invariants required by the
// coordinator before authorization or state updates.
func ValidateCoordinateRequest(req *proto.CoordinateRequest) error {
if req == nil {
return xerrors.New("coordinate request is required")
}
if err := validateUpdateSelf(req); err != nil {
return err
}
if slices.Contains(req.ReadyForHandshake, nil) {
return xerrors.New("ready_for_handshake entries must not be nil")
}
return nil
}
func validateUpdateSelf(req *proto.CoordinateRequest) error {
if upd := req.GetUpdateSelf(); upd != nil && upd.GetNode() == nil {
return xerrors.New("update_self node is required")
}
return nil
}