Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 22 Sep 2015 11:16:25 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: getaddrinfo usage with wrong ip family

On Tue, Sep 22, 2015 at 04:40:30PM +0200, Julien Ramseier wrote:
> Hello,
> 
> I discovered a potential problem in getaddrinfo/__lookup_name.
> When calling getaddrinfo  with an IP string not matching the specified family,
> name_from_numeric() in __lookup_name() will not recognize it and the 
> external dns resolver will be used.
> 
> So the following code:
> 
> const struct addrinfo hints = {
>     .ai_flags = AI_ADDRCONFIG,
>     .ai_family = AF_INET,
>     .ai_socktype = SOCK_STREAM,
> };
> 
> getaddrinfo("::1", NULL, &hints, &result);
> 
> will actually succeed instead of returning EAI_NONAME,
> and perform a "A ::1" query.
> Some misbehaving dns servers will then answer with 0.0.0.1.
> 
> I don’t know if this behavior is desirable. If not, I’m still not sure
> where this should be fixed. Maybe should we prevent sending
> A and AAAA dns queries with IP as hostname in __res_mkquery() ?

Sometime (it's been "soon" for a long time) I intend to add IDN
support, so the same place that goes would be the natural place to
pre-validate strings before sending them off in DNS queries. But I'm
not sure what the right filtering would be.

Another approach might be having __lookup_numeric always parse with
AF_UNSPEC, but return error rather than 0 results if the resulting
family does not match the requested family.

Anyone else have opinions on these ideas?

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.