mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: getaddrinfo usage with wrong ip family
Date: Tue, 22 Sep 2015 11:16:25 -0400	[thread overview]
Message-ID: <20150922151625.GX17773@brightrain.aerifal.cx> (raw)
In-Reply-To: <06898546-AC9C-40F0-A2F5-2F1CC02E185C@gmail.com>

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


  reply	other threads:[~2015-09-22 15:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 14:40 Julien Ramseier
2015-09-22 15:16 ` Rich Felker [this message]
2015-09-24 10:27   ` Julien Ramseier
2015-09-24 10:59     ` Szabolcs Nagy
2015-09-24 15:11       ` Julien Ramseier
2015-09-24 15:39         ` Rich Felker
2015-09-25  1:48           ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150922151625.GX17773@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).