Alternate port randomization approaches

From: Mike Silbersack (silby_at_silby.com)
Date: 12/18/04

  • Next message: Donatas: "double vlans - once again."
    Date: Sat, 18 Dec 2004 04:03:11 -0600 (CST)
    To: net@freebsd.org
    
    
    

    There have been a few reports by users of front end web proxies and other
    systems under FreeBSD that port randomization causes them problems under
    load. This seems to be due to a combination of port randomization and
    rapid connections to the same host causing ports to be recycled before the
    ISN has advanced past the end of the previous connection, thereby causing
    the TIME_WAIT socket on the receiving end to ignore the new SYN.

    I haven't proven it, but I imagine that part of the problem is due to the
    interaction of established and finished connections. Say that ports 1500
    -> 1600 have established connections, and that arc4random picks port 1504
    as the next one to try. Rather than picking another random port, we
    simply look sequentially through the rest of the ports, and will pick
    1601. I had considered continuing to do random port guesses until an
    unused one was found, but that has the nasty property of looping an
    undetermined amount of time, and it would most likely not help anything
    anyway.

    The solution I've come up with that should provide a decent tradeoff
    between the increased security of port randomization and the realities of
    the problem of quick port recycling is attached. What it does is only
    randomize the first net.inet.ip.portrange.randomized ports assigned each
    second. Beyond that, it uses sequentual allocation. The default I
    picked, 20, is arbitrary. Initial testing by a front-end web proxy admin
    shows that 20 is too high to avoid problems in his case, but 1 works
    decently.

    Although this isn't a perfect fix, I think that it should be acceptable
    for the vast majority of systems, and I'd like to get it in before
    4.11-release ships. To be conservative, I'll probably choose a value like
    5, which should be fine for most systems out there. Super specialized
    users will always be able to lower it to 0.

    Since this is an important issue, I was wondering if anyone had any
    suggestions on how to improve this method, or how to solve the problem in
    another way.

    Remember that 4.11 ships in the next few weeks, so any solution which gets
    added to it must be relatively simple, we can't be doing anything like
    changing the TCP state machine. (Yes, I've considered removing the ISN >
    window requirement from the TIME_WAIT state, but that's not something to
    be changing on a whim.)

    Also note that 5.x and 6.x handle TIME_WAIT recycling in the exact same
    way 4.x does; the sequence number check is just now in the function
    tcp_timewait rather than in tcp_input. So, the same problems plagues all
    versions. (Despite my other modifications to sequence number generation
    which were attempts to fix it.)

    Comments appreciated,

    Mike "Silby" Silbersack

    
    
    
    

    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"




  • Next message: Donatas: "double vlans - once again."

    Relevant Pages

    • Re: [PATCH 3/3] Convert the UDP hash lock to RCU
      ... bias on the port randomization. ... idea with following patch: ... We select the shortest chain to chose a port ...
      (Linux-Kernel)
    • Re: NFS mount hangs when using one specific IP
      ... When I perform a mount from another host, the initial sequence is the same ... Transmission Control Protocol, Src Port: 32781, Dst Port: sunrpc ... Next sequence number: 61 (relative sequence number) ... Flags: 0x0018 (PSH, ACK) ...
      (comp.os.linux.networking)
    • RE: Spoofed scans
      ... Sequence numbers would not be as ... target ADENA for an open TCP port 22. ... His plan is to get relative sequence numbers from PATSY while ... /* A couple of words on spoofing should be mentioned. ...
      (Incidents)
    • Re: Naming output files
      ... You will need to either set up a convoy orchestration to process one ... to see if there is a usable sequence number there. ... in the Message1 construct shape, then send Message1 out to a FILE send port: ...
      (microsoft.public.biztalk.general)
    • Re: block_ssh_guessers
      ... be bothered to set up certificates, google for port knocking. ... port-knocking--don't be bloody stupid. ... As I said in another message, a simple setup to change the sequence every ... than it is to launch a buffer overflow attack against a port that is just ...
      (comp.os.linux.security)