Ticket #64 (closed Problem: Solved)

Opened 3 years ago

Last modified 6 weeks ago

DNS lookup routines may return either string or addr

Reported by: mej Owned by: robin
Priority: Normal Milestone:
Component: Bro Version: 1.4
Keywords: Cc:

Description

I encountered an issue where DNS failure resulted in a return value that was a string value ("<dns-timeout>" in this instance). Looking at LookupHostCallback? in src/bro.bif, it would appear that in cases of error or failure, a StringVal? object is returned instead of a set of addrs.

I'm new to Bro, so I don't know if this is intentional or not, but Robin says it's a bug, so I'm filing it. ;-)

I can provide a reproducer if needed.

Attachments

irc-hosts-bug.bro Download (1.2 KB) - added by mej 3 years ago.
Reproducer
dns-mgr.diff Download (1.0 KB) - added by robin 3 years ago.

Change History

comment:1 Changed 3 years ago by robin

  • Status changed from new to seen

Yeah, that's definitely a bug. If you have the reproducer at hand, please add it; otherwise, don't bother, it should be pretty straight-forward to trigger the problem.

Changed 3 years ago by mej

Reproducer

comment:2 Changed 3 years ago by mej

I took your irc-hosts-c.bro script from Lab #6 of the Bro class and made one change:

  • local dns_addrs = find_all(message, /[a-z]+{1,}\.[a-z]+{1,}\.[a-z]+{1,}\.[a-z]+{1,}/);

+ local dns_addrs = find_all(message, /[[:space:]]*\.[A-Za-z][A-Za-z]*/);

The pattern I used caught a lot more than hostnames (obviously), which is why it triggered the bug. You'll see errors like this followed by (potentially) a seg fault:

$ bro -r irc-2.pcap irc-hosts-bug.bro
1182977234.025658 run-time error: can't issue DNS request
1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(< and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(d and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(n and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(s and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(- and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(t and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(i and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(m and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(e and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(o and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(u and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(t and list of addr): error, index type doesn't match table

1182977234.025658 <no location> and ./irc-hosts-bug.bro, line 14

(> and list of addr): error, index type doesn't match table

.size
Segmentation fault

You'll need your irc-2.pcap file also, but I assume you still have that. ;-)

Changed 3 years ago by robin

comment:3 Changed 3 years ago by robin

  • Owner set to robin
  • Status changed from seen to accepted

I'm attaching a patch which seems to fix the problem. It needs a bit more of testing though because it changes the return value for failed DNS requests: from a string containing an error description ("<dns-timeout>") to a set[addr] with one element 0.0.0.0. The alternative would be returning an empty set but I'm suspecting that would confuse some scripts (and I hope nobody actually depends on a string being returned in the error case ...)

comment:4 Changed 3 years ago by matthias

After applying the patch, I don't experience crashes with the following error anymore:

<no location> (127.0.0.2): bad tag in Val::CONST_ACCESSOR (types/string)

Rather, I routinely get the this error:

run-time error: can't issue DNS request

comment:5 Changed 15 months ago by seth

  • Milestone set to Bro1.6

Has this patch been integrated? I thought it was but perhaps not. I'll go ahead and set it as a milestone for the 1.6 release for now.

comment:6 Changed 14 months ago by robin

Seems this has been partially integrated.

comment:7 Changed 14 months ago by robin

  • Status changed from accepted to closed
  • Resolution set to Solved

Oops no, the patch has been correctly integrated already.

comment:8 Changed 6 weeks ago by robin

  • Milestone Bro2.0 deleted

Milestone Bro2.0 deleted

Note: See TracTickets for help on using tickets.