Commit Graph
25 Commits
Author SHA1 Message Date
David Fifield 10951d6216 Consistent parameter naming. 2021-11-27 06:08:55 -07:00
David Fifield aeaa0d1eca Small comment fixes. 2021-11-27 06:05:42 -07:00
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 12098e15ca Remove a line of unreachable code.
Was identical to the "else" immediately above it.
2021-04-20 18:04:11 -06:00
David Fifield 15ff06af9b Comment typo. 2020-10-06 12:21:04 -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 b209ba29ed Add a fuzzing harness for the dns module. 2020-05-06 14:39:55 -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 d14deab12b Documentation and light refactoring. 2020-04-19 17:16:27 -06:00
David Fifield d42f7ea187 Add test for dns.EncodeRDataTXT. 2020-04-19 11:05:36 -06:00
David Fifield c33077e885 Refactor MessageFromWireFormat and writeMessage.
Make MessageFromWireFormat responsible for checking the EOF condition.
2020-04-19 10:57:55 -06:00
David Fifield f168777a13 dns Message.Opcode method. 2020-04-19 10:33:40 -06:00
David Fifield 0022cdd16c EDNS check 2020-04-18 14:33:39 -06:00
David Fifield 584dc3950d Advertise EDNS(0) in client. 2020-04-18 14:33:39 -06:00
David Fifield 2050034fb1 Factor out separate sending and receiving threads. 2020-04-18 14:29:30 -06:00
David Fifield 22f5633521 Do name compression in writing. 2020-04-18 14:29:14 -06:00
David Fifield 9f72a8a87d client 2020-04-18 14:28:53 -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
David Fifield cdeecf2ec6 Starting on server. 2020-04-18 13:18:04 -06:00