-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
The net.Lookup{Addr,CNAME,Host} functions don't do any filtering of returned host name string types when using the pure Go resolver, allowing for invalid names to be returned to the caller. If the caller expects these names to be valid they may use them in an unsanitized context, allowing for injection of unexpected content. Depending on the implementation, the cgo resolver may do some level of filtering, for instance the glibc implementation of getaddrinfo does impose its own filtering.
The simple approach to this is to check returned names with the existing isDomainName function, which applies RFC 1035 LDH rules (as well as allowing underscores for SRV style names), and failing out if the returned names are not considered proper. This should mostly match glibc behavior. In order to avoid diverging behavior across implementations, the check should probably be done at the Resolver level, rather than just in the pure Go Lookup... implementations.
This is CVE-2021-33195.