[Snort-devel] integer overflow issue in PAWS window checks
Nilesh K. Patel
Nilesh.k.Patel at Sophos.com
Fri Dec 22 07:45:20 EST 2017
There is a issue in PAWS window checks in snort_steam_tcp.c
Consider you got big timestamp in last segment and current segment has 0(zero) or less timestamp.
ts_last = 2331162992 and tdb->ts = 0 (bad segment) and dry run below code.
int result = 0;
if (listener->tcp_policy->policy == STREAM_POLICY_LINUX)
/* Linux 2.6 accepts timestamp values that are off
* by one. */
result = (int)((tdb->ts - talker->ts_last) + 1);
result = (int)(tdb->ts - talker->ts_last);
Here we expect result should negative as tdb->ts is less than ts_last. But as last segment got big timestamp which actually negative number in 32bit integer and if we do 0 - 2331162992 will become positive number 1963804304, but expect < 0.
if(result < 0)
"Packet outside PAWS window, dropping\n"););
/* bail, we've got a packet outside the PAWS window! */
*eventcode |= EVENT_BAD_TIMESTAMP;
if(listener->tcp_policy->flags & STREAM_CONFIG_ENABLE_ALERTS)
It must fall in this if and drop this bad segment, however it is bypassing this checks due to wrongly handled comparison.
There are other checks after this, which actually updates the timestamp wrongly.
As I see this should be change or am I missing something here. Happy to give patch if you agree.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Snort-devel