lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [task #13763] tcp_next_iss(): use LWIP_RAND()?


From: David van Moolenbroek
Subject: [lwip-devel] [task #13763] tcp_next_iss(): use LWIP_RAND()?
Date: Sat, 17 Dec 2016 20:38:00 -0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0

Follow-up Comment #2, task #13763 (project lwip):

In my opinion, this is a seriously important issue. TCP spoofing can be a big
deal, and lwIP's current ISN algorithm requires an attacker to make only two
connections before they can blindly predict the ISN for a third. However,
while the algorithm proposed by RFC 6528 (the update to RFC 1948) is the most
preferable solution, I believe it requires "ingredients" that can and should
not be provided by lwIP itself: a high-resolution timer and a cryptographic
hash function. As such, I think that lwIP should provide the means to
implement such an algorithm, but not the implementation.

Thus, I am proposing the attached patch: a TCP ISN generation hook that may
override lwIP's default algorithm. The hook provides the 4-tuple of the new
TCP connection to allow implementing RFC 6528's algorithm, but -if desired-
can also simply be set to LWIP_RAND(), thus ignoring the 4-tuple and instead
providing a faster way to provide a somewhat better defense against TCP
spoofing.

Commit message reproduced below. As always, I would be happy to make changes
if that helps. For example, it would be possible to replace hook's the 4-tuple
parameters with a single tcp_pcb pointer, leaving the hook implementation to
obtain individual fields as needed.

===

Add hook for TCP Initial Sequence Number generation

lwIP produces a TCP Initial Sequence Number (ISN) for each new TCP connection.
The current algorithm is simple and predictable however. The result is that
lwIP TCP connections may be the target of TCP spoofing attacks.  The problem
of such attacks is well known, and a recommended ISN generation algorithm is
standardized in RFC 6528. This algorithm requires a high-resolution timer and
cryptographic hashing function, though.  The implementation (or best-effort
approximation) of both of these aspects is well beyond the scope of lwIP
itself.

For that reason, this patch adds LWIP_HOOK_TCP_ISN, a hook that allows each
platform to implement its own ISN generation using locally available means. 
The hook provides full flexibility, in that the hook may generate anything
from a simple random number (by being set to LWIP_RAND()) to a full RFC 6528
implementation.

Implementation note:

Users of the hook would typically declare the function prototype of the hook
function in arch/cc.h, as this is the last place where such prototypes can be
supplied.  However, at that point, the ip_addr_t type has not yet been
defined.  For that reason, this patch removes the leading underscore from
"struct _ip_addr", so that a prototype of the hook function can use "struct
ip_addr" instead of "ip_addr_t".

(file #38822)
    _______________________________________________________

Additional Item Attachment:

File name: 0001-Add-hook-for-TCP-Initial-Sequence-Number-generation.patch
Size:6 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?13763>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]