home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / phrack2 / p49_06.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  9.4 KB  |  202 lines

  1.                              .oO Phrack Magazine Oo.
  2.  
  3.                           Volume Seven, Issue Forty-Nine
  4.                                      
  5.                                   File 06 of 16
  6.  
  7.                     [ Project Loki ]
  8.  
  9.                 whitepaper by daemon9 AKA route
  10.                sourcecode by daemon9 && alhambra
  11.                  for Phrack Magazine
  12.               August 1996 Guild Productions, kid
  13.  
  14.        comments to route@infonexus.com/alhambra@infonexus.com
  15.  
  16.  
  17.         --[ Introduction ]--
  18.  
  19.  
  20.     Ping traffic is ubiquitous to almost every TCP/IP based network and 
  21. subnetwork.  It has a standard packet format recognized by every IP-speaking
  22. router and is used universally for network management, testing, and 
  23. measurement.  As such, many firewalls and networks consider ping traffic 
  24. to be benign and will allow it to pass through, unmolested.  This project 
  25. explores why that practice can be insecure.  Ignoring the obvious threat of 
  26. the done-to-death denial of service attack, use of ping traffic can open up 
  27. covert channels through the networks in which it is allowed.
  28.  
  29.     Loki, Norse God of deceit and trickery, the 'Lord of Misrule' was 
  30. well known for his subversive behavior.  Inversion and reversal of all sorts 
  31. was typical for him.  Due to it's clandestine nature, we chose to name this 
  32. project after him.
  33.  
  34.     The Loki Project consists of a whitepaper covering this covert channel
  35. in detail.  The sourcecode is not for distribution at this time.
  36.  
  37.  
  38.         --[ Overview  ]--
  39.  
  40.  
  41.     This whitepaper is intended as a complete description of the covert
  42. channel that exists in networks that allow ping traffic (hereon referred to 
  43. in the more general sense of ICMP_ECHO traffic --see below) to pass.  It is 
  44. organized into sections:
  45.  
  46.     Section I.    ICMP Background Info and the Ping Program
  47.     Section II.    Basic Firewall Theory and Covert Channels
  48.     Section III.    The Loki Premise
  49.     Section IV.    Discussion, Detection, and Prevention
  50.     Section V.    References
  51.  
  52. (Note that readers unfamiliar with the TCP/IP protocol suite may wish to first
  53. read ftp://ftp.infonexus.com/pub/Philes/NetTech/TCP-IP/tcipIp.intro.txt.gz)
  54.  
  55.  
  56.         Section I.    ICMP Background Info and the Ping Program
  57.  
  58.  
  59.     The Internet Control Message Protocol is an adjunct to the IP layer.
  60. It is a connectionless protocol used to convey error messages and other 
  61. information to unicast addresses.  ICMP packets are encapsulated inside of IP
  62. datagrams.  The first 4-bytes of the header are same for every ICMP message, 
  63. with the remainder of the header differing for different ICMP message types.
  64. There are 15 different types of ICMP messages.  
  65.  
  66.     The ICMP types we are concerned with are type 0x0 and type 0x8.  
  67. ICMP type 0x0 specifies an ICMP_ECHOREPLY (the response) and type 
  68. 0x8 indicates an ICMP_ECHO (the query).  The normal course of action is 
  69. for a type 0x8 to elicit a type 0x0 response from a listening server.  
  70. (Normally, this server is actually the OS kernel of the target host.  Most 
  71. ICMP traffic is, by default, handled by the kernel).  This is what the ping 
  72. program does.  
  73.  
  74.     Ping sends one or more ICMP_ECHO packets to a host.  The purpose
  75. may just be to determine if a host is in fact alive (reachable).  ICMP_ECHO 
  76. packets also have the option to include a data section.  This data section 
  77. is used when the record route option is specified, or, the more common case, 
  78. (usually the default) to store timing information to determine round-trip 
  79. times.  (See the ping(8) man page for more information on these topics).  
  80. An excerpt from the ping man page:
  81.  
  82.  "...An IP header without options is 20 bytes.  An ICMP ECHO_REQUEST packet
  83.      contains an additional 8 bytes worth of ICMP header followed by an 
  84.      arbitrary-amount of data.  When a packetsize is given, this indicated the
  85.      size of this extra piece of data (the default is 56).  Thus the amount of
  86.      data received inside of an IP packet of type ICMP ECHO_REPLY will always
  87.      be 8 bytes more than the requested data space (the ICMP header)..."
  88.  
  89.     Although the payload is often timing information, there is no check by
  90. any device as to the content of the data.  So, as it turns out, this amount of 
  91. data can also be arbitrary in content as well.  Therein lies the covert 
  92. channel.
  93.  
  94.  
  95.         Section II.    Basic Firewall Theory and Covert Channels
  96.  
  97.  
  98.     The basic tenet of firewall theory is simple:  To shield one network
  99. from another.  This can be clarified further into 3 provisional rules:
  100. 1. All traffic passing between the two networks must pass through the firewall.
  101. 2. Only traffic authorized by the firewall may pass through (as dictated by 
  102. the security policy of the site it protects).
  103. 3. The firewall itself is immune to compromise.    
  104.  
  105.     A covert channel is a vessel in which information can pass, but this
  106. vessel is not ordinarily used for information exchange.  Therefore, as a 
  107. matter of consequence, covert channels are impossible to detect and deter 
  108. using a system's normal (read: unmodified) security policy.  In theory, 
  109. almost any process or bit of data can be a covert channel.  In practice, it 
  110. is usually quite difficult to elicit meaningful data from most covert 
  111. channels in a timely fashion.  In the case of Loki, however, it is quite 
  112. simple to exploit.
  113.  
  114.     A firewall, in it's most basic sense, seeks to preserve the security 
  115. policy of the site it protects.  It does so by enforcing the 3 rules above.
  116. Covert channels, however, by very definition, are not subject to a site's 
  117. normal security policy.
  118.  
  119.  
  120.         Section III.    The Loki Premise
  121.  
  122.  
  123.     The concept of the Loki Project is simple: arbitrary information 
  124. tunneling in the data portion of ICMP_ECHO and ICMP_ECHOREPLY packets.  Loki 
  125. exploits the covert channel that exists inside of ICMP_ECHO traffic.  This 
  126. channel exists because network devices do not filter the contents of ICMP_ECHO
  127. traffic.  They simply pass them, drop them, or return them. The trojan packets
  128. themselves are masqueraded as common ICMP_ECHO traffic.  We can encapsulate 
  129. (tunnel) any information we want.  From here on out, Loki traffic will refer 
  130. to ICMP_ECHO traffic that tunnels information.  (Astute readers will note that
  131. Loki is simply a form of steganography).
  132.  
  133.     Loki is not a compromise tool.  It has many uses, none of which are 
  134. breaking into a machine.  It can be used as a backdoor into a system by 
  135. providing a covert method of getting commands executed on a target machine.
  136. It can be used as a way of clandestinely leeching information off of a 
  137. machine.  It can be used as a covert method of user-machine or user-user 
  138. communication.  In essence the channel is simply a way to secretly shuffle
  139. data (confidentiality and authenticity can be added by way of cryptography). 
  140.  
  141.     Loki is touted as a firewall subversion technique, but in reality it
  142. is simple a vessel to covertly move data.  *Through* exactly what we move this
  143. data is not so much an issue, as long as it passes ICMP_ECHO traffic.  It does
  144. not matter: routers, firewalls, packet-filters, dual-homed hosts, etc...  all
  145. can serve as conduits for Loki.
  146.  
  147.  
  148.         Section IV.    Discussion, Detection and Prevention
  149.  
  150.  
  151.     If ICMP_ECHO traffic is allowed, then this channel exists.  If this 
  152. channel exists, then it is unbeatable for a backdoor (once the system is 
  153. compromised).  Even with extensive firewalling and packet-filtering 
  154. mechanisms in place, this channel continues to exist (provided, of course,
  155. they do not deny the passing of ICMP_ECHO traffic).  With a proper 
  156. implementation, the channel can go completely undetected for the duration of
  157. its existence.  
  158.  
  159.     Detection can be difficult.  If you know what to look for, you may
  160. find that the channel is being used on your system.  However, knowing when
  161. to look, where to look, and the mere fact that you *should* be looking all
  162. have to be in place.  A surplus of ICMP_ECHOREPLY packets with a garbled
  163. payload can be ready indication the channel is in use.  The standalone Loki 
  164. server program can also be a dead give-away.  However, if the attacker can 
  165. keep traffic on the channel down to a minimum, and was to hide the Loki 
  166. server *inside* the kernel, detection suddenly becomes much more difficult.
  167.  
  168.     Disruption of this channel is simply preventative.  Disallow ICMP_ECHO
  169. traffic entirely.  ICMP_ECHO traffic, when weighed against the security 
  170. liabilities it imposes, is simply not *that* necessary.  Restricting ICMP_ECHO
  171. traffic to be accepted from trusted hosts only is ludicrous with a 
  172. connectionless protocol such as ICMP.  Forged traffic can still reach the 
  173. target host.  The LOKI packet with a forged source IP address will arrive at 
  174. the target (and will elicit a legitimate ICMP_ECHOREPLY, which will 
  175. travel to the spoofed host, and will be subsequently dropped silently) and 
  176. can contain the 4-byte IP address of the desired target of the Loki response 
  177. packets, as well as 51-bytes of malevolent data...  While the possibility 
  178. exists for a smart packet filter to check the payload field and ensure that 
  179. it *only* contains legal information, such a filter for ICMP is not in wide 
  180. usage, and could still be open to fooling.  The only sure way to destroy this
  181. channel is to deny ALL ICMP_ECHO traffic into your network.
  182.  
  183. NOTE: This channel exists in many other protocols.  Loki Simply covers 
  184. ICMP, but in theory (and practice) any protocol is vulnerable to covert 
  185. data tunneling.  All that is required is the ingenuity...
  186.  
  187.         Section V.    References
  188.  
  189.  
  190.         Books:    TCP Illustrated vols. I, II, III
  191.         RFCs:    rfc 792
  192.         Source:    Loki v1.0
  193.         Ppl:    We did not pioneer this concept  To our knowledge, 
  194.         it was discovered independently of our efforts, prior to our
  195.         research.  This party wishes to remain aloof.
  196.  
  197.  
  198. This project made possible by a grant from the Guild Corporation.
  199.  
  200.  
  201. EOF
  202.