home *** CD-ROM | disk | FTP | other *** search
/ Cuteskunk BBS / cuteskunk.zip / cuteskunk / Unix-Hacking-Documents / ftp-paper.txt < prev    next >
Text File  |  2003-06-29  |  6KB  |  92 lines

  1.  
  2.    Some problems with the File Transfer Protocol, a failure of common
  3.    implementations, and suggestions for repair.
  4.  
  5.    By David Sacerdote (davids@secnet.com April, 1996)
  6.  
  7.    FTP servers can operate in two modes: active and passive. In active
  8.    mode, when data is transferred, the client listens on a TCP port,
  9.    tells the server which port it is listening on, and then the server
  10.    opens a TCP connection from port 20 to the specified port on the
  11.    client. Data is then transferred over this connection. In passive
  12.    mode, the client tells the server that it is ready for data transfer,
  13.    the server listens on an unprivileged TCP port, and tells the client
  14.    which port. The client then opens a tcp connection to the specified
  15.    port on the server, and data is exchanged over this connection.
  16.  
  17.    The problem with these auxiliary connections is that the existing FTP
  18.    protocol lacks any method of assuring that the client or server which
  19.    initiates the connection is really the one attached to the associated
  20.    control connection. This, combined with the fact that most operating
  21.    systems allocate tcp ports in increasing order, means that the ftp
  22.    protocol has an inherent race condition, which allows an attacker to
  23.    either obtain data which somebody else is transferring, or to replace
  24.    that data with their own. These attacks take slightly different forms
  25.    in active mode and passive mode. When the data transfers are done in
  26.    active mode, the attacker guesses the number of the TCP port where the
  27.    target client will be doing a listen. He or she then repeatedly sends
  28.    the ftp server to which the client is connected the commands PORT
  29.    ip,of,client,machine,port,port RETR filename or STOR filename.
  30.  
  31.    Using RETR if he wishes to replace data transmitted to the client, and
  32.    STOR if he is trying to intercept data the client would send to the
  33.    server. Alternatively, the attacker could use known TCP sequence
  34.    number prediction attacks, and spoof a connection from the server to
  35.    the client. However, while using this type of attack, it is not
  36.    possible to intercept transferred data; merely replace it with your
  37.    own. In poor FTP client implementations, the client might not validate
  38.    the source port and ip address of the server, making a sequencing
  39.    attack unnecessary, however, the 4.2BSD ftp client does do this
  40.    validation, meaning that most ftp clients out there probably do as
  41.    well. In passive mode, matters are slightly different however. Neither
  42.    the Solaris 2.5 (SVR4) ftp server, nor wu-ftpd, common starting points
  43.    for writing FTP servers, bother checking the ip address of the
  44.    secondary tcp connections initiated by the client. This means that not
  45.    only are passive mode transfers vulnerable to attacks analogous to the
  46.    ones for active mode, involving either some kind of access to the
  47.    client, or a sequencing attack, but a mere TCP connection from
  48.    anywhere on the network is sufficient to intercept or replace data
  49.    transferred. To exploit this implementation problem, an attacker would
  50.    merely guess the TCP port which the server will next listen on, and
  51.    bombard it with connection attempts. If the server was then attempting
  52.    to send data to the client, it will be sent to the attacker.
  53.    Otherwise, the attacker can send data to the server, replacing data
  54.    which the client would have been sending to the server.
  55.  
  56.    Unfortunately, having FTP servers operating in passive mode check the
  57.    source IP address of the incoming connection to see if it matches the
  58.    IP address associated with the control connection is neither practical
  59.    nor solves the problem. Seeing that the existing protocol is
  60.    exceedingly vulnerable to both data corruption and interception by an
  61.    attacker who does not have control over the network across which the
  62.    session is maintained, it is necessary to extend the protocol so as to
  63.    prevent these attacks. One method of doing this would be to have both
  64.    client and server establish a data connection, and then, before
  65.    transmitting anything over it, send the ip addresses and port numbers
  66.    they see as associated with the data connection across the control
  67.    connection. Since the establishment of another connection by an
  68.    attacker would prevent either the client or the server from
  69.    establishing a connection, this would effectively block such attacks.
  70.    Furthermore, since the ip address is transmitted as well, this will
  71.    not cause compatibility problems. There is however a performance price
  72.    which will need to be paid, namely the amount of time required to
  73.    transmit the ip address and port number information. However, even on
  74.    the slower network connections in use today, namely SLIP and PPP
  75.    connections, it should not be excessive.
  76.  
  77.    A second method of authenticating the data connections would be a
  78.    cookie exchange, similar to the MIT-MAGIC-COOKIE-1 system used by X11.
  79.    If the server and client pass large random numbers over the control
  80.    channel, and then pass them over the data channels when established,
  81.    thus establishing that the client and server on the data connection
  82.    are the same as those on the control connection. The problem with this
  83.    method is that the capacity for an attacker to intercept a cookie will
  84.    mean that new cookies will need to be generated for each connection.
  85.    In addition, generating large numbers of cryptographically secure
  86.    pseudo-random numbers is likely to be a computationally expensive
  87.    task.
  88.  
  89.    ----------------------------------------------------------------------
  90.  
  91.    (c) 1996, Secure Networks Inc.
  92.