DNS query randomisation
A lot has been said in the last few weeks about the need to randomise the source port used to issue DNS queries to mitigate the risk of cache poisoning attacks.
The need to randomise the 16-bit Query IDs was recognised long ago, and is implemented widely. However investigation of the DNS traffic hitting Nominet’s .uk name servers shows that even now Query ID randomisation is not 100% correctly implemented!
A snapshot was taken of all incoming traffic to one of the .uk authoritative name servers for a 10 minute window around 12:00 BST (11:00 GMT) for each of the last six days, and then filtered to exclude any client that issued less than 500 queries in total across those sampling periods.
The results below showed 16 clients were found to be only using Query IDs in the range 0 - 16383 (i.e. 14 bits) and another two only using the range 0 - 32767 (15 bits).
| queries | num of qids | stddev | min | max |
|---|---|---|---|---|
| 986 | 887 | 4799.8014 | 36 | 16356 |
| 1417 | 795 | 4823.0908 | 29 | 16372 |
| 833 | 777 | 4747.0796 | 22 | 16374 |
| 1109 | 1042 | 4774.1761 | 13 | 16364 |
| 508 | 415 | 4908.3115 | 32 | 16320 |
| 578 | 559 | 4682.2742 | 0 | 16344 |
| 584 | 195 | 5001.5020 | 50 | 16376 |
| 806 | 767 | 4687.1233 | 48 | 16374 |
| 520 | 500 | 4716.7800 | 9 | 16361 |
| 811 | 796 | 9675.4265 | 3 | 32761 |
| 840 | 787 | 4691.5559 | 15 | 16336 |
| 667 | 658 | 9363.0246 | 13 | 32762 |
| 661 | 373 | 4856.5800 | 22 | 16317 |
| 654 | 654 | 1251.1737 | 4006 | 12936 |
| 13070 | 6925 | 4729.9155 | 8 | 16381 |
| 817 | 774 | 4545.2894 | 16 | 16361 |
| 2459 | 2126 | 4703.9213 | 24 | 16382 |
| 4298 | 3308 | 4714.6598 | 8 | 16383 |
Servers using the full 16 bits for Query ID have a typical standard deviation in excess of 17,000.
It’s likely that those using only 14 bits are running some version of MS Windows, and have not been patched following Microsoft’s Security Bulletin MS08-020 published in April this year. This bug was originally reported to Microsoft by my colleague Roy Arends.
Further investigation of the data even found one low volume client only using Query IDs in the range 0 - 127, a mere 7 bits of entropy!
