Skip to content

Instantly share code, notes, and snippets.

@rep
Created August 15, 2022 21:04
Show Gist options
  • Save rep/a459f639cf267949e24c1f55c6c5aeeb to your computer and use it in GitHub Desktop.
Save rep/a459f639cf267949e24c1f55c6c5aeeb to your computer and use it in GitHub Desktop.
Windows ETW DNS event source bug
The Windows ETW event source for DNS returns incorrect QueryResults when the DNS server sends additional A / AAAA records in the "ADDITIONAL" section of the DNS response packet.
To fix, the code responsible for putting together the QueryResults value needs to only take into account records from the ANSWER section.
=============== ETW Event ===============
<Event MSec= "6447.1483" PID="7596" PName= "msedge" TID="5392" EventName="EventID(3008)" ProviderName="Microsoft-Windows-DNS-Client" FormattedMessage="DNS query is completed for the name baidu.com, type 1, query options 2,392,538,375,913,472 with status 0 Results 110.242.68.66;39.156.66.10;110.242.68.134;220.181.33.31;36.152.45.193;112.80.248.64;14.215.178.80;111.45.3.226;180.76.76.92;240e:bf:b801:1002:0:ff:b024:26de;240e:940:603:4:0:ff:b01b:589a; " QueryName="baidu.com" QueryType="1" QueryOptions="2,392,538,375,913,472" QueryStatus="0" QueryResults="110.242.68.66;39.156.66.10;110.242.68.134;220.181.33.31;36.152.45.193;112.80.248.64;14.215.178.80;111.45.3.226;180.76.76.92;240e:bf:b801:1002:0:ff:b024:26de;240e:940:603:4:0:ff:b01b:589a;"/>
=============== DNS response (dig) ===============
;; QUESTION SECTION:
;baidu.com. IN A
;; ANSWER SECTION:
baidu.com. 367 IN A 110.242.68.66
baidu.com. 367 IN A 39.156.66.10
;; AUTHORITY SECTION:
baidu.com. 39948 IN NS dns.baidu.com.
baidu.com. 39948 IN NS ns2.baidu.com.
baidu.com. 39948 IN NS ns7.baidu.com.
baidu.com. 39948 IN NS ns4.baidu.com.
baidu.com. 39948 IN NS ns3.baidu.com.
;; ADDITIONAL SECTION:
dns.baidu.com. 355 IN A 110.242.68.134
ns2.baidu.com. 83148 IN A 220.181.33.31
ns3.baidu.com. 83148 IN A 112.80.248.64
ns3.baidu.com. 83148 IN A 36.152.45.193
ns4.baidu.com. 83148 IN A 111.45.3.226
ns4.baidu.com. 83148 IN A 14.215.178.80
ns7.baidu.com. 83148 IN A 180.76.76.92
ns7.baidu.com. 86358 IN AAAA 240e:bf:b801:1002:0:ff:b024:26de
ns7.baidu.com. 86358 IN AAAA 240e:940:603:4:0:ff:b01b:589a
=============== Sysmon Event ===============
<EventData>
<Data Name="RuleName">-</Data>
<Data Name="UtcTime">2022-08-15 21:00:09.383</Data>
<Data Name="ProcessGuid">{45b1307f-b3ae-62fa-e604-000000000500}</Data>
<Data Name="ProcessId">7596</Data>
<Data Name="QueryName">baidu.com</Data>
<Data Name="QueryStatus">0</Data>
<Data Name="QueryResults">110.242.68.66;39.156.66.10;110.242.68.134;220.181.33.31;36.152.45.193;112.80.248.64;14.215.178.80;111.45.3.226;180.76.76.92;240e:bf:b801:1002:0:ff:b024:26de;240e:940:603:4:0:ff:b01b:589a;</Data>
<Data Name="Image">C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe</Data>
<Data Name="User">DESKTOP-PR68551\anna</Data>
</EventData>
@rep
Copy link
Author

rep commented Aug 15, 2022

Essentially you don't know which IPs are actual IPs for the QueryName and which ones are for other names from additional section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment