Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns.resolveMx returns invalid result in Node <22 #53708

Open
analogic opened this issue Jul 3, 2024 · 7 comments
Open

dns.resolveMx returns invalid result in Node <22 #53708

analogic opened this issue Jul 3, 2024 · 7 comments
Labels
cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. confirmed-bug Issues with confirmed bugs. dns Issues and PRs related to the dns subsystem. v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch. v20.x v20.x Issues that can be reproduced on v20.x or PRs targeting the v20.x-staging branch.

Comments

@analogic
Copy link

analogic commented Jul 3, 2024

Version

v20.15.0

Platform

linux & docker

Subsystem

dns

What steps will reproduce the bug?

I have this code:

const dns = require('dns');
const ign = dns.resolveMx("blek.cz", (err, addresses) => console.log([err, addresses]));

And results:

$ docker run -ti node:16 node
[ null, [ { exchange: 'blekmx1.blek.cz', priority: 100 } ] ]

$ docker run -ti node:18 node
[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]

$ docker run -ti node:20 node
[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]

$ docker run -ti node:20-alpine node
[ null, [ { exchange: 'blek.cz', priority: 100 } ] ]

$ docker run -ti node:22 node
[ null, [ { exchange: 'blekmx1.blek.cz', priority: 100 } ] ]

How often does it reproduce? Is there a required condition?

Might be system/resolver dependent. Also there should be something unusual about this particular domain

What is the expected behavior? Why is that the expected behavior?

$ dig +short mx blek.cz
100 blekmx1.blek.cz.

What do you see instead?

Bare "blek.cz" host even don't have SMTP port open so it makes emails undeliverable

Additional information

No response

@RedYetiDev RedYetiDev added dns Issues and PRs related to the dns subsystem. v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch. v20.x v20.x Issues that can be reproduced on v20.x or PRs targeting the v20.x-staging branch. labels Jul 3, 2024
@JQuags
Copy link

JQuags commented Jul 4, 2024

I am able to reproduce this on freebsd (13.3) with blek.cz and visa.com but not gmail.com and other domains however unlike the above test it also is an issue in v22.3.0 installed from ports.

@targos
Copy link
Member

targos commented Jul 5, 2024

I verified that it was fixed by #53155 in Node.js 22.3.0.

Probably due to this (from c-ares changelog):

Due to a logic flaw dns name compression writing was not properly implemented
which would result in the name prefix not being written for a partial match.
This could cause issues in various record types such as MX records when using
the deprecated API. Regression introduced in 1.28.0. Issue #757

@RedYetiDev
Copy link
Member

Does that make this is a known limitation?

@targos
Copy link
Member

targos commented Jul 6, 2024

No

@RedYetiDev
Copy link
Member

So, IIUC the solution would be to backport c-ares/c-ares@d7c14a1?

@targos
Copy link
Member

targos commented Jul 6, 2024

No, the solution is to cherry-pick or backport #53155. That's why I added lts-watch- labels to it.

@RedYetiDev
Copy link
Member

Oh, thanks, I don't know that much about backporting, thanks for the info!

@RedYetiDev RedYetiDev added the cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. confirmed-bug Issues with confirmed bugs. dns Issues and PRs related to the dns subsystem. v18.x Issues that can be reproduced on v18.x or PRs targeting the v18.x-staging branch. v20.x v20.x Issues that can be reproduced on v20.x or PRs targeting the v20.x-staging branch.
Projects
None yet
Development

No branches or pull requests

4 participants