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

Warning: Message parser reports malformed message packet. #8

Closed
ptorrent opened this issue Sep 17, 2019 · 6 comments
Closed

Warning: Message parser reports malformed message packet. #8

ptorrent opened this issue Sep 17, 2019 · 6 comments

Comments

@ptorrent
Copy link

ptorrent commented Sep 17, 2019

Hello,

When i execute : "dig wbc.weble.ch +trace"

I've this result :

; <<>> DiG 9.10.3-P4-Raspbian <<>> wbc.weble.ch +trace
;; global options: +cmd
.                       72776   IN      NS      e.root-servers.net.
.                       72776   IN      NS      f.root-servers.net.
.                       72776   IN      NS      g.root-servers.net.
.                       72776   IN      NS      h.root-servers.net.
.                       72776   IN      NS      i.root-servers.net.
.                       72776   IN      NS      j.root-servers.net.
.                       72776   IN      NS      k.root-servers.net.
.                       72776   IN      NS      l.root-servers.net.
.                       72776   IN      NS      m.root-servers.net.
.                       72776   IN      NS      a.root-servers.net.
.                       72776   IN      NS      b.root-servers.net.
.                       72776   IN      NS      c.root-servers.net.
.                       72776   IN      NS      d.root-servers.net.
;; Received 811 bytes from 172.16.1.1#53(172.16.1.1) in 3 ms

ch.                     172800  IN      NS      a.nic.ch.
ch.                     172800  IN      NS      b.nic.ch.
ch.                     172800  IN      NS      c.nic.ch.
ch.                     172800  IN      NS      d.nic.ch.
ch.                     172800  IN      NS      e.nic.ch.
ch.                     172800  IN      NS      f.nic.ch.
ch.                     172800  IN      NS      g.nic.ch.
ch.                     172800  IN      NS      h.nic.ch.
ch.                     86400   IN      DS      11896 13 2 24EE6537B1C452D3AEBF439DCF74024717054152DA7F206D5FCBA1A9 0F70711F
ch.                     86400   IN      RRSIG   DS 8 1 86400 20190930050000 20190917040000 59944 . kaGRIHYMMuruHaWAIHb9kVXZNH9tzDNkqgQcX9oFotbd86puoY6/sRp6 +y8lhBxUgm7qi7GM3JxTZ3iZ3/dpgNv7PTVLskDUwrscSQC5jkxzOzvB 5oo59keBmC9X2UlJ+rLJoLNLNuao+6LyMPZtSgW7DudvN1rMQpZM39is XuG5URCG9qSBzkJt3FPESMBT+h356sbvN4Jz8GvwPLaE2mpdNnuBwAIG qBYaqDiWhE0pLuSVwdLlPftCnJ7RT1dNfTI3wJfSl2fDI6TpHPgr8bSt 4H5HDutqvsZuTQp1p2CqKLtAJOCIKBPOfact7SyYaVFlmuqhQMZLwFDP UnZDiQ==
;; Received 860 bytes from 193.0.14.129#53(k.root-servers.net) in 11 ms

weble.ch.               3600    IN      NS      ns1.switchplus.ch.
weble.ch.               3600    IN      NS      ns2.switchplus.ch.
HS53IQDLBM00MIRD1LPS0J47BPJP5SF8.ch. 900 IN NSEC3 1 1 2 87E195EB HS63KNDB8F15206UBJQDIRIISQ1EK7N7 NS SOA RRSIG DNSKEY NSEC3PARAM
HS53IQDLBM00MIRD1LPS0J47BPJP5SF8.ch. 900 IN RRSIG NSEC3 13 2 900 20191013161405 20190913160114 7967 ch. GZsRnHBemsdnY1WI6R9+O9NjL9a7s479t3Oqcw6j28LVsYZWOjqUPnSK bjRHaSKp4hZrtxX9gMzIRAJChgL3AQ==
LBHUG80GC3VGPEU435F60L91DBJ3LJE8.ch. 900 IN NSEC3 1 1 2 87E195EB LBK2U02LTLKUCOCKTKJG1O2EMMOK0HBB NS DS RRSIG
LBHUG80GC3VGPEU435F60L91DBJ3LJE8.ch. 900 IN RRSIG NSEC3 13 2 900 20191010205442 20190911113001 7967 ch. UdhiNXu1UZx2JE1qg/WI+I51OMtCanyanuqtArGcuMc+GyFZR7NeLK9l GpMKl5wmdz3EDm+TL+y8X7XWncNf8w==
;; Received 487 bytes from 194.146.106.10#53(f.nic.ch) in 13 ms

wbc.weble.ch.           3600    IN      NS      ns1.weble.ch.
wbc.weble.ch.           3600    IN      NS      ns2.weble.ch.
;; Received 109 bytes from 193.223.77.3#53(ns2.switchplus.ch) in 119 ms

**;; Warning: Message parser reports malformed message packet.**
wbc.weble.ch.           300     IN      A       213.193.121.210
;; Received 67 bytes from 213.193.121.211#53(ns1.weble.ch) in 31 ms

Here the response object :

var response = new dns.Packet(request);
	response.header.qr = 1;


	response.answers.push({
		name: oDomain,
		address: target.target,
		type	: dns.Packet.TYPE.A,
		ttl 	: ttl,
		class	: dns.Packet.CLASS.IN
	});

And in console I've:
image

Is there a link between this error and the warning ;; Warning: Message parser reports malformed message packet. ?

Is there something wrong ?

@andsens
Copy link

andsens commented Mar 16, 2020

I'm seeing the exact same issue. I'm a bit down the rabbit hole from minikube ingress-dns to cryptexlabs/minikube-ingress-dns:0.2.1, to the sourcecode, to this package.

My issue arises when the systemd-resolverd stub-resolver performs a query. Using dig to query the server directly is no problem. Here's the wireshark disector output:
Screenshot from 2020-03-16 12-48-57

@andris9
Copy link
Contributor

andris9 commented May 1, 2020

This happens when dns2 tries to answer to a request it did not understand (mostly OPT RR). The solution in my case was to filter out unsupported types from prepared responses.

// create a filter of supported data types
const SUPPORTED_TYPES = new Set(
  Object.keys(dns.Packet.TYPE)
    .map((key) => dns.Packet.TYPE[key])
    .filter((val) => typeof val === "number")
);

const server = dns.createServer(function (request, send) {
	// filter out unsupported requests (eg. EDNS)
	if (request.additionals && request.additionals.length) {
	  request.additionals = request.additionals.filter((additional) =>
	    SUPPORTED_TYPES.has(additional.type)
	  );
	}
	....

@lsongdev
Copy link
Owner

Simply clears out the additionals field in the response:

response.additionals = [];

@ardarico
Copy link

Thank you.

response.additionals = []; removed the error message about unknown encoder, but the "unknown parser type: undefined(41) is still there.

@andsens
Copy link

andsens commented Jun 22, 2020

but the "unknown parser type: undefined(41) is still there.

That's because the encoder for that packet type doesn't exist in dns2.
Check my PR on gitlab for a more in-depth explanation.
TL;DR: This mostly (exclusively?) happens when the DNS client sends edns queries (DNS with some crypto auth request attached).

@bambusoft
Copy link

bambusoft commented Mar 21, 2021

Hi:
Running the example server for IPv6 I recieve => Warning: Message parser reports malformed message packet.

dwuser@darwin:~$ dig @localhost -p 5333 google.com aaaa
;; Warning: Message parser reports malformed message packet.

; <<>> DiG 9.16.1-Ubuntu <<>> @localhost -p 5333 google.com aaaa
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1036
;; flags: qr rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; WARNING: Message has 10 extra bytes at end

;; QUESTION SECTION:
;google.com. IN AAAA

;; Query time: 8 msec
;; SERVER: 127.0.0.1#5333(127.0.0.1)
;; WHEN: Sun Mar 21 14:01:50 CST 2021
;; MSG SIZE rcvd: 60

This is the code I m using:

const dns2 = require('dns2');
const { Packet } = dns2;
const server = dns2.createUDPServer((request, send, rinfo) => {
const response = Packet.createResponseFromRequest(request);
const [ question ] = request.questions;
const { name } = question;
response.additionals = [];
response.answers.push({
name,
type: Packet.TYPE.AAAA,
class: Packet.CLASS.IN,
ttl: 300,
address: '2001:4860:4860::8888'
});
send(response);
});

server.on('request', (request, response, rinfo) => {
console.log(request.header.id, request.questions[0]);
});
server.listen(5333);

Thank you

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

No branches or pull requests

6 participants