Commit Graph
11 Commits
Author SHA1 Message Date
David Fifield 34df3508cd Have TestNameString test the full repertoire of bytes. 2021-08-12 15:04:02 -06:00
David Fifield 2eb03bb746 Escape DNS names that appear in logs.
The dnstt-server log line "NXDOMAIN: not authoritative for %s" copied
bytes directly from an attacker-controlled DNS name to the log. Because
DNS labels may contain any byte values, this made possible various
injection attacks, for example:
* A label containing a newline byte could break the format of a log
  file, or be used to inject false log lines.
* If the log output were going to a terminal (as it does by default), a
  DNS name could affect the terminal by including escape sequences.
* A DNS label containing the dot character (\x2e) could give a
  misleading impression of the contents of a query; for example the
  names ["a" "example" "com"] and ["a\x2eexample" "com"] would both be
  logged as "a.example.com".
The former ambiguity with the dot character might have confused the name
compressor in messageBuilder.WriteName, but I do not think any of
dnstt's uses of messageBuilder could have been affected.

The Name.String method now does backslash hex escaping of unusual bytes
in labels.

This vulnerability was called to mind by "Injection Attacks Reloaded:
Tunnelling Malicious Payloads over DNS" by Jeitner and Shulman. See
particularly Section 3.2 for \x2e injection.
https://www.usenix.org/conference/usenixsecurity21/presentation/jeitner
2021-08-12 13:20:41 -06:00
David Fifield ebb82e62e9 Simplify with gofmt -s. 2020-08-21 14:11:58 -06:00
David Fifield cd40a072ba Add another test case for a truncated DNS name compression pointer. 2020-05-15 11:02:13 -06:00
David Fifield 8616ac4f91 Fix dns.TestEncodeRDataTXT.
It was always failing because of a debugging line I had left in.
2020-05-06 14:39:55 -06:00
David Fifield e5b6d48b41 Fix some comment typos. 2020-04-25 19:50:26 -06:00
David Fifield d42f7ea187 Add test for dns.EncodeRDataTXT. 2020-04-19 11:05:36 -06:00
David Fifield 6633ee8b8d Exchange payloads. 2020-04-18 14:23:11 -06:00
David Fifield 32bf8ef5db Generating a response. 2020-04-18 13:18:08 -06:00
David Fifield 23b395bac1 WireFormat 2020-04-18 13:18:08 -06:00
David Fifield 57dbb4a4a8 MessageFromWireFormat 2020-04-18 13:18:08 -06:00