Skip to content

Commit ecd0f72

Browse files
authored
Don't set dns.resolved_ip with invalid IP addresses (#18436)
Sometimes the DNS IP addresses from Sysmon in `winlog.event_data.QueryResults` are truncated. The leads to mapping exceptions since the value is not of type `ip` in Elasticsearch. To fix this the module will now filter any results that are not valid IP addresses. Fixes #18432
1 parent 78b957a commit ecd0f72

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
186186

187187
*Winlogbeat*
188188

189+
- Fix invalid IP addresses in DNS query results from Sysmon data. {issue}18432[18432] {pull}18436{18436}
189190

190191
*Functionbeat*
191192

x-pack/winlogbeat/module/sysmon/config/winlogbeat-sysmon.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var sysmon = (function () {
1616
var path = require("path");
1717
var processor = require("processor");
1818
var winlogbeat = require("winlogbeat");
19+
var net = require("net");
1920

2021
// Windows error codes for DNS. This list was generated using
2122
// 'go run gen_dns_error_codes.go'.
@@ -432,17 +433,19 @@ var sysmon = (function () {
432433
} else {
433434
// Convert V4MAPPED addresses.
434435
answer = answer.replace("::ffff:", "");
435-
ips.push(answer);
436+
if (net.isIP(answer)) {
437+
ips.push(answer);
436438

437-
// Synthesize record type based on IP address type.
438-
var type = "A";
439-
if (answer.indexOf(":") !== -1) {
440-
type = "AAAA";
439+
// Synthesize record type based on IP address type.
440+
var type = "A";
441+
if (answer.indexOf(":") !== -1) {
442+
type = "AAAA";
443+
}
444+
answers.push({
445+
type: type,
446+
data: answer,
447+
});
441448
}
442-
answers.push({
443-
type: type,
444-
data: answer,
445-
});
446449
}
447450
}
448451

x-pack/winlogbeat/module/sysmon/test/testdata/sysmon-10.2-dns.evtx.golden.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13341,10 +13341,6 @@
1334113341
{
1334213342
"data": "2001:502:7094::30",
1334313343
"type": "AAAA"
13344-
},
13345-
{
13346-
"data": "192.5",
13347-
"type": "A"
1334813344
}
1334913345
],
1335013346
"question": {
@@ -13403,8 +13399,7 @@
1340313399
"192.43.172.30",
1340413400
"2001:503:39c1::30",
1340513401
"192.48.79.30",
13406-
"2001:502:7094::30",
13407-
"192.5"
13402+
"2001:502:7094::30"
1340813403
]
1340913404
},
1341013405
"event": {

0 commit comments

Comments
 (0)