Closed gwillcox-r7 closed 2 years ago
@gwillcox-r7 Good catch - let me know if you're handling this, or if I should fire up a PR :+1:
@adfoster-r7 Just putting up a PR now, should be up soon :)
@adfoster-r7 PR now up at https://github.com/rapid7/rex-socket/pull/48 which should fix this, simple change.
https://github.com/rapid7/rex-socket/blob/master/lib/rex/socket/ssl_tcp.rb#L131 has a bug in that it should be
elsif
notelse
. Otherwise what happens is that the case that is provided will be ignored and we will always trigger theelse
condition if the aboveself.peerhostname
condition isn't true. In reality we only want to execute that code if!Rex::Socket.dotted_ip?(self.peerhost)
evaluates to true, in which case we then executeself.sslsock.hostname = self.peerhost
.In its current case we will be setting
self.sslsock.hostname = self.peerhost
even in cases whereself.peerhost
is a dotted IP address, which defeats the purpose of the check that was added here.We can confirm this is the case with a simple test bit of code.
As you can see in the
elsif
case, both conditions are properly skipped over. However in theif...else
case, the second condition is executed even though the condition passed toelse
was false, sinceelse
doesn't expect an argument and therefore will ignore the argument.