Node: DNS resolution fails for internationalized domain names

Created on 18 Jan 2019  路  5Comments  路  Source: nodejs/node

  • Version: v10.14.2
  • Platform: Darwin november.local 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
  • Subsystem: dns, cares_wrap

Currently the DNS module seems to utf-8 encode the names passed to c-ares for DNS resolution: https://github.com/nodejs/node/blob/2c0a75118cd6a2eaf6b45fe8c67336f44c86ab0f/src/cares_wrap.cc#L1803

That doesn't work for internationalized domain names, which need to be IDNA encoded.

DNS is pretty much all ASCII, so IMHO Node shouldn't utf-8 encode on input.

Here is a list of international domain names to test.

This will produce an error:

> dns.resolve('espa帽a.icom.museum', function(r, e) { console.log(r, e) })`
> { Error: queryA ENOTFOUND espa帽a.icom.museum
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:197:19)
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'queryA',
  hostname: 'espa帽a.icom.museum' } undefined

Whereas the proper IDNA encoded version works:

> dns.resolve('xn--espaa-rta.icom.museum', function(e, r) { console.log(e, r) })
> null [ '91.194.60.138' ]
confirmed-bug dns v10.x

All 5 comments

All supported versions of Node are affected. I'm looking into it.

I'm quite surprised that this affects so many version. I'm pretty sure IDN did work at least at some point in time.

@santigimeno and I opened PRs but now that I think about it, this issue should be fixed once v10.x upgrades to libuv v1.24.0 because that's the first libuv release that includes https://github.com/libuv/libuv/pull/2046.

Landing the PRs would still be useful for:

  1. v6.x (and v8.x?), because libuv isn't upgraded on that branch, and
  2. z/os, because EBCDIC

I'm pretty sure IDN did work at least at some point in time.

@silverwind If you'll allow me to self-quote from https://github.com/nodejs/node/pull/25679#issue-247231927:

[..] Node.js left it up to the system resolver or c-ares.

Leaving it to the system resolver introduces platform differences
because:

    some support IDNA 2008
    some only IDNA 2003 (glibc until 2.28), and
    some don't support IDNA at all (musl libc)

In other words, Node's behavior is currently platform-dependent (bad.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielstaleiny picture danielstaleiny  路  3Comments

willnwhite picture willnwhite  路  3Comments

addaleax picture addaleax  路  3Comments

cong88 picture cong88  路  3Comments

seishun picture seishun  路  3Comments