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

Wildcard entries returning answers for non-matching zone in authoritative nameserver #16

Open
pinheadmz opened this issue Apr 27, 2020 · 1 comment · May be fixed by #22
Open

Wildcard entries returning answers for non-matching zone in authoritative nameserver #16

pinheadmz opened this issue Apr 27, 2020 · 1 comment · May be fixed by #22

Comments

@pinheadmz
Copy link
Collaborator

Trying to run an AuthServer locally with both of these setups:

server.setOrigin('myzone.');
server.zone.fromString('*.myzone. 21600 IN A 10.20.30.40');
server.setOrigin('myzone.');
server.zone.fromString('* 21600 IN A 10.20.30.40');

In both cases I'm getting unexpected results for names that do not match the zone:

dig @127.0.0.1 -p 5300 test.com

; <<>> DiG 9.14.6 <<>> @127.0.0.1 -p 5300 test.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16083
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test.com.                      IN      A

;; ANSWER SECTION:
test.myzone.            21600   IN      A       10.20.30.40

;; Query time: 10 msec
;; SERVER: 127.0.0.1#5300(127.0.0.1)
;; WHEN: Mon Apr 27 15:01:21 EDT 2020
;; MSG SIZE  rcvd: 64

bns is attaching the first label in the query to the zone and returning.

@pinheadmz
Copy link
Collaborator Author

pinheadmz commented Apr 27, 2020

Possible solution:

diff --git a/lib/zone.js b/lib/zone.js
index 2568026..f52f051 100644
--- a/lib/zone.js
+++ b/lib/zone.js
@@ -532,6 +532,9 @@ function convert(name, rr) {

   assert(y.length > 0);

+  if (x[x.length - 1] !== y[y.length - 1])
+    return null;
+
   if (x.length < y.length)
     return rr;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant