home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / firewalls-faq < prev    next >
Text File  |  2001-07-02  |  102KB  |  2,124 lines

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!newsfeed.utk.edu!news-hog.berkeley.edu!ucberkeley!news.cis.ohio-state.edu!not-for-mail
  2. From: C Matthew Curtin <cmcurtin@interhack.net>
  3. Newsgroups: comp.security.firewalls,comp.security.unix,comp.security.misc,comp.answers,news.answers
  4. Subject: Firewalls FAQ
  5. Followup-To: poster
  6. Date: 2 Jul 2001 05:39:01 GMT
  7. Organization: The Ohio State University Dept. of Computer and Info. Science
  8. Lines: 2108
  9. Approved: news-answers-request@MIT.EDU
  10. Message-ID: <9hp1dl$3r2$1@news.cis.ohio-state.edu>
  11. NNTP-Posting-Host: epsilon.cis.ohio-state.edu
  12. Summary: Answers to Frequently Asked Questions about Internet Firewalls
  13. X-PostedBy: pfaq
  14. X-Face: L"IcL.b%SDN]0Kql2b`e.}+i05V9fi\yX#H1+Xl)3!+n/3?5`%-SA-HDg<IT;O8XnF>Pk9uTk<3dv^J5DCgal)-E{`zN#*o6F|y>r)\<<ui53(fC)EM]42*oF|P@Hm"Z+GK%"b#q'ycf=2s5%NNR0S;8"vcNN"O;O}YpB{&^1xazqDMg^v!6LS7S"5|}2uTl$NKV5}Bkca{M|Y^cZD@{1
  15. Xref: senator-bedfellow.mit.edu comp.security.firewalls:93148 comp.security.unix:69575 comp.security.misc:71895 comp.answers:46060 news.answers:210465
  16.  
  17. URL: http://www.interhack.net/pubs/fwfaq/
  18. Version: 10.0
  19. Archive-name: firewalls-faq
  20. Posting-Frequency: monthly 
  21.  
  22.                              Internet Firewalls:
  23.                          Frequently Asked Questions
  24.  
  25.                         Matt Curtin       Marcus J. Ranum
  26.  
  27.                    cmcurtin@interhack.net   mjr@nfr.com
  28.  
  29.                          Date: 2000/12/01 19:48:21
  30.                                Revision: 10.0
  31.  
  32. Contents
  33.  
  34.    * Contents
  35.    * 1 Administrativia
  36.         o 1.1 About the FAQ
  37.         o 1.2 For Whom Is the FAQ Written?
  38.         o 1.3 Before Sending Mail
  39.         o 1.4 Where Can I find the Current Version of the FAQ?
  40.         o 1.5 Where Can I Find Non-English Versions of the FAQ?
  41.         o 1.6 Contributors
  42.         o 1.7 Copyright and Usage
  43.    * 2 Background and Firewall Basics
  44.         o 2.1 What is a network firewall?
  45.         o 2.2 Why would I want a firewall?
  46.         o 2.3 What can a firewall protect against?
  47.         o 2.4 What can't a firewall protect against?
  48.         o 2.5 What about viruses?
  49.         o 2.6 Will IPSEC make firewalls obsolete?
  50.         o 2.7 What are good sources of print information on firewalls?
  51.         o 2.8 Where can I get more information on firewalls on the Internet?
  52.    * 3 Design and Implementation Issues
  53.         o 3.1 What are some of the basic design decisions in a firewall?
  54.         o 3.2 What are the basic types of firewalls?
  55.              + 3.2.1 Network layer firewalls
  56.              + 3.2.2 Application layer firewalls
  57.         o 3.3 What are proxy servers and how do they work?
  58.         o 3.4 What are some cheap packet screening tools?
  59.         o 3.5 What are some reasonable filtering rules for a kernel-based
  60.           packet screen?
  61.              + 3.5.1 Implementation
  62.              + 3.5.2 Explanation
  63.         o 3.6 What are some reasonable filtering rules for a Cisco?
  64.              + 3.6.1 Implementation
  65.              + 3.6.2 Explanations
  66.              + 3.6.3 Shortcomings
  67.         o 3.7 What are the critical resources in a firewall?
  68.         o 3.8 What is a DMZ, and why do I want one?
  69.         o 3.9 How might I increase the security and scalability of my DMZ?
  70.         o 3.10 What is a `single point of failure', and how do I avoid
  71.           having one?
  72.         o 3.11 How can I block all of the bad stuff?
  73.         o 3.12 How can I restrict web access so users can't view sites
  74.           unrelated to work?
  75.    * 4 Various Attacks
  76.         o 4.1 What is source routed traffic and why is it a threat?
  77.         o 4.2 What are ICMP redirects and redirect bombs?
  78.         o 4.3 What about denial of service?
  79.         o 4.4 What are some common attacks, and how can I protect my system
  80.           against them?
  81.              + 4.4.1 SMTP Server Hijacking (Unauthorized Relaying)
  82.              + 4.4.2 Exploiting Bugs in Applications
  83.              + 4.4.3 Bugs in Operating Systems
  84.    * 5 How Do I...
  85.         o 5.1 Do I really want to allow everything that my users ask for?
  86.         o 5.2 How do I make Web/HTTP work through my firewall?
  87.         o 5.3 How do I make SSL work through the firewall?
  88.         o 5.4 How do I make DNS work with a firewall?
  89.         o 5.5 How do I make FTP work through my firewall?
  90.         o 5.6 How do I make Telnet work through my firewall?
  91.         o 5.7 How do I make Finger and whois work through my firewall?
  92.         o 5.8 How do I make gopher, archie, and other services work through
  93.           my firewall?
  94.         o 5.9 What are the issues about X11 through a firewall?
  95.         o 5.10 How do I make RealAudio work through my firewall?
  96.         o 5.11 How do I make my web server act as a front-end for a database
  97.           that lives on my private network?
  98.         o 5.12 But my database has an integrated web server, and I want to
  99.           use that. Can't I just poke a hole in the firewall and tunnel that
  100.           port?
  101.         o 5.13 How Do I Make IP Multicast Work With My Firewall?
  102.    * A Some Commercial Products and Vendors
  103.    * B Glossary of Firewall-Related Terms
  104.    * C TCP and UDP Ports
  105.         o C.1 What is a port?
  106.         o C.2 How do I know which application uses what port?
  107.         o C.3 What are LISTENING ports?
  108.         o C.4 How do I determine what service the port is for?
  109.         o C.5 What ports are safe to pass through a firewall?
  110.         o C.6 The behavior of FTP
  111.         o C.7 What software uses what FTP mode?
  112.         o C.8 Is my firewall trying to connect outside?
  113.         o C.9 The anatomy of a TCP connection
  114.    * References
  115.  
  116. 1 Administrativia
  117.  
  118.  
  119.  
  120. 1.1 About the FAQ
  121.  
  122.  
  123.  
  124. The Firewalls FAQ is currently undergoing revision. The maintainers welcome
  125. input and comments on the contents of this FAQ. Comments related to the FAQ
  126. should be addressed to firewalls-faq@interhack.net. Before you send us mail,
  127. please be sure to see sections 1.2 and 1.3 to make sure this is the right
  128. document for you to be reading.
  129.  
  130. 1.2 For Whom Is the FAQ Written?
  131.  
  132.   Firewalls have come a long way from the days when this FAQ started.
  133. They've gone from being highly customized systems administered by their
  134. implementors to a mainstream commodity. Firewalls are no longer solely in
  135. the hands of those who design and implement security systems; even
  136. security-conscious end-users have them at home.
  137.  
  138. We wrote this FAQ for computer systems developers and administrators. We
  139. have tried to be fairly inclusive, making room for the newcomers, but we
  140. still assume some basic technical background. If you find that you don't
  141. understand this document, but think that you need to know more about
  142. firewalls, it might well be that you actually need to get more background in
  143. computer networking first. We provide references that have helped us;
  144. perhaps they'll also help you.
  145.  
  146. 1.3 Before Sending Mail
  147.  
  148.   Note that this collection of frequently-asked questions is a result of
  149. interacting with many people of different backgrounds in a wide variety of
  150. public fora. The firewalls-faq address is not a help desk. If you're trying
  151. to use an application that says that it's not working because of a firewall
  152. and you think that you need to remove your firewall, please do not send us
  153. mail asking how.
  154.  
  155. If you want to know how to ``get rid of your firewall'' because you cannot
  156. use some application, do not send us mail asking for help. We cannot help
  157. you. Really.
  158.  
  159. Who can help you? Good question. That will depend on what exactly the
  160. problem is, but here are several pointers. If none of these works, please
  161. don't ask us for any more. We don't know.
  162.  
  163.    * The provider of the software you're using.
  164.    * The provider of the network service you're using. That is, if you're on
  165.      AOL, ask them. If you're trying to use something on a corporate
  166.      network, talk to your system administrator.
  167.  
  168. 1.4 Where Can I find the Current Version of the FAQ?
  169.  
  170.   The FAQ can be found on the Web at
  171.  
  172.    * http://www.interhack.net/pubs/fwfaq/.
  173.    * http://www.ranum.com/pubs/fwfaq/
  174.  
  175. It's also posted monthly to
  176.  
  177.    * comp.security.firewalls,
  178.    * comp.security.unix,
  179.    * comp.security.misc,
  180.    * comp.answers, and
  181.    * news.answers.
  182.  
  183. Posted versions are archived in all the usual places. Unfortunately, the
  184. version posted to Usenet and archived from that version lack the pretty
  185. pictures and useful hyperlinks found in the web version.
  186.  
  187. 1.5 Where Can I Find Non-English Versions of the FAQ?
  188.  
  189.   Several translations are available. (If you've done a translation and it's
  190. not listed here, please write us so we can update the master document.)
  191.  
  192. Norwegian
  193.      Translation by Jon Haugsand
  194.      http://helmersol.nr.no/haandbok/doc/brannmur/brannmur-faq.html
  195.  
  196. 1.6 Contributors
  197.  
  198.   Many people have written helpful suggestions and thoughtful commentary.
  199. We're grateful to all contributors. We'd like to thank a few by name:
  200. Keinanen Vesa, Allen Leibowitz, Brent Chapman, Brian Boyle, D. Clyde
  201. Williamson, Paul D. Robertson, Richard Reiner, Humberto Ortiz Zuazaga, and
  202. Theodore Hope.
  203.  
  204. 1.7 Copyright and Usage
  205.  
  206.   Copyright ⌐1995-1996, 1998 Marcus J. Ranum. Copyright ⌐1998-2000 Matt
  207. Curtin. All rights reserved. This document may be used, reprinted, and
  208. redistributed as is providing this copyright notice and all attributions
  209. remain intact. Translations of the complete text from the original English
  210. to other languages are also explicitly allowed. Translators may add their
  211. names to the ``Contributors'' section.
  212.  
  213. 2 Background and Firewall Basics
  214.  
  215.   Before being able to understand a complete discussion of firewalls, it's
  216. important to understand the basic principles that make firewalls work.
  217.  
  218. 2.1 What is a network firewall?
  219.  
  220.   A firewall is a system or group of systems that enforces an access control
  221. policy between two networks. The actual means by which this is accomplished
  222. varies widely, but in principle, the firewall can be thought of as a pair of
  223. mechanisms: one which exists to block traffic, and the other which exists to
  224. permit traffic. Some firewalls place a greater emphasis on blocking traffic,
  225. while others emphasize permitting traffic. Probably the most important thing
  226. to recognize about a firewall is that it implements an access control
  227. policy. If you don't have a good idea of what kind of access you want to
  228. allow or to deny, a firewall really won't help you. It's also important to
  229. recognize that the firewall's configuration, because it is a mechanism for
  230. enforcing policy, imposes its policy on everything behind it. Administrators
  231. for firewalls managing the connectivity for a large number of hosts
  232. therefore have a heavy responsibility.
  233.  
  234. 2.2 Why would I want a firewall?
  235.  
  236.   The Internet, like any other society, is plagued with the kind of jerks
  237. who enjoy the electronic equivalent of writing on other people's walls with
  238. spraypaint, tearing their mailboxes off, or just sitting in the street
  239. blowing their car horns. Some people try to get real work done over the
  240. Internet, and others have sensitive or proprietary data they must protect.
  241. Usually, a firewall's purpose is to keep the jerks out of your network while
  242. still letting you get your job done.
  243.  
  244. Many traditional-style corporations and data centers have computing security
  245. policies and practices that must be adhered to. In a case where a company's
  246. policies dictate how data must be protected, a firewall is very important,
  247. since it is the embodiment of the corporate policy. Frequently, the hardest
  248. part of hooking to the Internet, if you're a large company, is not
  249. justifying the expense or effort, but convincing management that it's safe
  250. to do so. A firewall provides not only real security--it often plays an
  251. important role as a security blanket for management.
  252.  
  253. Lastly, a firewall can act as your corporate ``ambassador'' to the Internet.
  254. Many corporations use their firewall systems as a place to store public
  255. information about corporate products and services, files to download,
  256. bug-fixes, and so forth. Several of these systems have become important
  257. parts of the Internet service structure (e.g.: UUnet.uu.net, whitehouse.gov,
  258. gatekeeper.dec.com) and have reflected well on their organizational
  259. sponsors.
  260.  
  261. 2.3 What can a firewall protect against?
  262.  
  263.   Some firewalls permit only email traffic through them, thereby protecting
  264. the network against any attacks other than attacks against the email
  265. service. Other firewalls provide less strict protections, and block services
  266. that are known to be problems.
  267.  
  268. Generally, firewalls are configured to protect against unauthenticated
  269. interactive logins from the ``outside'' world. This, more than anything,
  270. helps prevent vandals from logging into machines on your network. More
  271. elaborate firewalls block traffic from the outside to the inside, but permit
  272. users on the inside to communicate freely with the outside. The firewall can
  273. protect you against any type of network-borne attack if you unplug it.
  274.  
  275. Firewalls are also important since they can provide a single ``choke point''
  276. where security and audit can be imposed. Unlike in a situation where a
  277. computer system is being attacked by someone dialing in with a modem, the
  278. firewall can act as an effective ``phone tap'' and tracing tool. Firewalls
  279. provide an important logging and auditing function; often they provide
  280. summaries to the administrator about what kinds and amount of traffic passed
  281. through it, how many attempts there were to break into it, etc.
  282.  
  283. This is an important point: providing this ``choke point'' can serve the
  284. same purpose on your network as a guarded gate can for your site's physical
  285. premises. That means anytime you have a change in ``zones'' or levels of
  286. sensitivity, such a checkpoint is appropriate. A company rarely has only an
  287. outside gate and no receptionist or security staff to check badges on the
  288. way in. If there are layers of security on your site, it's reasonable to
  289. expect layers of security on your network.
  290.  
  291. 2.4 What can't a firewall protect against?
  292.  
  293.   Firewalls can't protect against attacks that don't go through the
  294. firewall. Many corporations that connect to the Internet are very concerned
  295. about proprietary data leaking out of the company through that route.
  296. Unfortunately for those concerned, a magnetic tape can just as effectively
  297. be used to export data. Many organizations that are terrified (at a
  298. management level) of Internet connections have no coherent policy about how
  299. dial-in access via modems should be protected. It's silly to build a 6-foot
  300. thick steel door when you live in a wooden house, but there are a lot of
  301. organizations out there buying expensive firewalls and neglecting the
  302. numerous other back-doors into their network. For a firewall to work, it
  303. must be a part of a consistent overall organizational security architecture.
  304. Firewall policies must be realistic and reflect the level of security in the
  305. entire network. For example, a site with top secret or classified data
  306. doesn't need a firewall at all: they shouldn't be hooking up to the Internet
  307. in the first place, or the systems with the really secret data should be
  308. isolated from the rest of the corporate network.
  309.  
  310. Another thing a firewall can't really protect you against is traitors or
  311. idiots inside your network. While an industrial spy might export information
  312. through your firewall, he's just as likely to export it through a telephone,
  313. FAX machine, or floppy disk. Floppy disks are a far more likely means for
  314. information to leak from your organization than a firewall! Firewalls also
  315. cannot protect you against stupidity. Users who reveal sensitive information
  316. over the telephone are good targets for social engineering; an attacker may
  317. be able to break into your network by completely bypassing your firewall, if
  318. he can find a ``helpful'' employee inside who can be fooled into giving
  319. access to a modem pool. Before deciding this isn't a problem in your
  320. organization, ask yourself how much trouble a contractor has getting logged
  321. into the network or how much difficulty a user who forgot his password has
  322. getting it reset. If the people on the help desk believe that every call is
  323. internal, you have a problem.
  324.  
  325. Lastly, firewalls can't protect against tunneling over most application
  326. protocols to trojaned or poorly written clients. There are no magic bullets
  327. and a firewall is not an excuse to not implement software controls on
  328. internal networks or ignore host security on servers. Tunneling ``bad''
  329. things over HTTP, SMTP, and other protocols is quite simple and trivially
  330. demonstrated. Security isn't ``fire and forget''.
  331.  
  332. 2.5 What about viruses?
  333.  
  334.   Firewalls can't protect very well against things like viruses. There are
  335. too many ways of encoding binary files for transfer over networks, and too
  336. many different architectures and viruses to try to search for them all. In
  337. other words, a firewall cannot replace security-consciousness on the part of
  338. your users. In general, a firewall cannot protect against a data-driven
  339. attack--attacks in which something is mailed or copied to an internal host
  340. where it is then executed. This form of attack has occurred in the past
  341. against various versions of sendmail, ghostscript, and scripting mail user
  342. agents like OutLook.
  343.  
  344. Organizations that are deeply concerned about viruses should implement
  345. organization-wide virus control measures. Rather than trying to screen
  346. viruses out at the firewall, make sure that every vulnerable desktop has
  347. virus scanning software that is run when the machine is rebooted. Blanketing
  348. your network with virus scanning software will protect against viruses that
  349. come in via floppy disks, modems, and Internet. Trying to block viruses at
  350. the firewall will only protect against viruses from the Internet--and the
  351. vast majority of viruses are caught via floppy disks.
  352.  
  353. Nevertheless, an increasing number of firewall vendors are offering ``virus
  354. detecting'' firewalls. They're probably only useful for naive users
  355. exchanging Windows-on-Intel executable programs and malicious-macro-capable
  356. application documents. There are many firewall-based approaches for dealing
  357. with problems like the ``ILOVEYOU'' worm and related attacks, but these are
  358. really oversimplified approaches that try to limit the damage of something
  359. that is so stupid it never should have occurred in the first place. Do not
  360. count on any protection from attackers with this feature.
  361.  
  362. A strong firewall is never a substitute for sensible software that
  363. recognizes the nature of what it's handling--untrusted data from an
  364. unauthenticated party--and behaves appropriately. Do not think that because
  365. ``everyone'' is using that mailer or because the vendor is a gargantuan
  366. multinational company, you're safe. In fact, it isn't true that ``everyone''
  367. is using any mailer, and companies that specialize in turning technology
  368. invented elsewhere into something that's ``easy to use'' without any
  369. expertise are more likely to produce software that can be fooled.
  370.  
  371. 2.6 Will IPSEC make firewalls obsolete?
  372.  
  373.   Some have argued that this is the case. Before pronouncing such a sweeping
  374. prediction, however, it's worthwhile to consider what IPSEC is and what it
  375. does. Once we know this, we can consider whether IPSEC will solve the
  376. problems that we're trying to solve with firewalls.
  377.  
  378. IPSEC (IP SECurity) refers to a set of standards developed by the Internet
  379. Engineering Task Force (IETF). There are many documents that collectively
  380. define what is known as ``IPSEC'' [4]. IPSEC solves two problems which have
  381. plagued the IP protocol suite for years: host-to-host authentication (which
  382. will let hosts know that they're talking to the hosts they think they are)
  383. and encryption (which will prevent attackers from being able to watch the
  384. traffic going between machines).
  385.  
  386. Note that neither of these problems is what firewalls were created to solve.
  387. Although firewalls can help to mitigate some of the risks present on an
  388. Internet without authentication or encryption, there are really two classes
  389. of problems here: integrity and privacy of the information flowing between
  390. hosts and the limits placed on what kinds of connectivity is allowed between
  391. different networks. IPSEC addresses the former class and firewalls the
  392. latter.
  393.  
  394. What this means is that one will not eliminate the need for the other, but
  395. it does create some interesting possibilities when we look at combining
  396. firewalls with IPSEC-enabled hosts. Namely, such things as
  397. vendor-independent virtual private networks (VPNs), better packet filtering
  398. (by filtering on whether packets have the IPSEC authentication header), and
  399. application-layer firewalls will be able to have better means of host
  400. verification by actually using the IPSEC authentication header instead of
  401. ``just trusting'' the IP address presented.
  402.  
  403. 2.7 What are good sources of print information on firewalls?
  404.  
  405.  
  406.  
  407. There are several books that touch on firewalls. The best known are:
  408.  
  409.    * Building Internet Firewalls, 2d ed.
  410.      Authors
  411.           Elizabeth D. Zwicky, Simon Cooper, and D. Brent Chapman
  412.      Publisher
  413.           O'Reilly
  414.      Edition
  415.           2000
  416.      ISBN
  417.           1-56592-871-7
  418.    * Firewalls and Internet Security: Repelling the Wily Hacker
  419.      Authors
  420.           Bill Cheswick and Steve Bellovin
  421.      Publisher
  422.           Addison Wesley
  423.      Edition
  424.           1994
  425.      ISBN
  426.           0-201-63357-4
  427.    * Practical Internet & Unix Security
  428.      Authors
  429.           Simson Garfinkel and Gene Spafford
  430.      Publisher
  431.           O'Reilly
  432.      Edition
  433.           1996
  434.      ISBN
  435.           1-56592-148-8
  436.      Note
  437.           Discusses primarily host security.
  438.  
  439. Related references are:
  440.  
  441.    * Internetworking with TCP/IP Vols I, II, and III
  442.      Authors
  443.           Douglas Comer and David Stevens
  444.      Publisher
  445.           Prentice-Hall
  446.      Edition
  447.           1991
  448.      ISBN
  449.           0-13-468505-9 (I), 0-13-472242-6 (II), 0-13-474222-2 (III)
  450.      Comment
  451.           A detailed discussion on the architecture and implementation of
  452.           the Internet and its protocols. Volume I (on principles, protocols
  453.           and architecture) is readable by everyone. Volume 2 (on design,
  454.           implementation and internals) is more technical. Volume 3 covers
  455.           client-server computing.
  456.    * Unix System Security--A Guide for Users and System Administrators
  457.      Author
  458.           David Curry
  459.      Publisher
  460.           Addison Wesley
  461.      Edition
  462.           1992
  463.      ISBN
  464.           0-201-56327-4
  465.  
  466. 2.8 Where can I get more information on firewalls on the Internet?
  467.  
  468.  
  469.  
  470. Firewalls Mailing List
  471.      http://lists.gnac.net/firewalls/ The internet firewalls mailing list is
  472.      a forum for firewall administrators and implementors. To subscribe to
  473.      Firewalls, send subscribe firewalls in the body of a message (not in
  474.      the ``Subject:'' line) to majordomo@lists.gnac.net
  475. Firewall-Wizards Mailing List
  476.      http://www.nfr.net/forum/firewall-wizards.html The Firewall Wizards
  477.      Mailing List is a moderated firewall and security related list that is
  478.      more like a journal than a public soapbox.
  479. Firewall HOWTO
  480.      http://sunsite.unc.edu/LDP/HOWTO/Firewall-HOWTO.html Describes exactly
  481.      what is needed to build a firewall, particularly using Linux.
  482. Firewall Toolkit (FWTK) and Firewall Papers
  483.      ftp://ftp.tis.com/pub/firewalls/
  484. Marcus Ranum's firewall related publications
  485.      http://www.ranum.com/pubs/
  486. Papers on firewalls and breakins
  487.      ftp://ftp.research.att.com/dist/internet_security/
  488. Texas A&M University security tools
  489.      http://www.net.tamu.edu/ftp/security/TAMU/
  490. COAST Project Internet Firewalls page
  491.      http://www.cs.purdue.edu/coast/firewalls/
  492.  
  493. 3 Design and Implementation Issues
  494.  
  495.  
  496.  
  497. 3.1 What are some of the basic design decisions in a firewall?
  498.  
  499.   There are a number of basic design issues that should be addressed by the
  500. lucky person who has been tasked with the responsibility of designing,
  501. specifying, and implementing or overseeing the installation of a firewall.
  502.  
  503. The first and most important decision reflects the policy of how your
  504. company or organization wants to operate the system: is the firewall in
  505. place explicitly to deny all services except those critical to the mission
  506. of connecting to the Net, or is the firewall in place to provide a metered
  507. and audited method of ``queuing'' access in a non-threatening manner? There
  508. are degrees of paranoia between these positions; the final stance of your
  509. firewall might be more the result of a political than an engineering
  510. decision.
  511.  
  512. The second is: what level of monitoring, redundancy, and control do you
  513. want? Having established the acceptable risk level (e.g., how paranoid you
  514. are) by resolving the first issue, you can form a checklist of what should
  515. be monitored, permitted, and denied. In other words, you start by figuring
  516. out your overall objectives, and then combine a needs analysis with a risk
  517. assessment, and sort the almost always conflicting requirements out into a
  518. laundry list that specifies what you plan to implement.
  519.  
  520. The third issue is financial. We can't address this one here in anything but
  521. vague terms, but it's important to try to quantify any proposed solutions in
  522. terms of how much it will cost either to buy or to implement. For example, a
  523. complete firewall product may cost between $100,000 at the high end, and
  524. free at the low end. The free option, of doing some fancy configuring on a
  525. Cisco or similar router will cost nothing but staff time and a few cups of
  526. coffee. Implementing a high end firewall from scratch might cost several
  527. man-months, which may equate to $30,000 worth of staff salary and benefits.
  528. The systems management overhead is also a consideration. Building a
  529. home-brew is fine, but it's important to build it so that it doesn't require
  530. constant (and expensive) attention. It's important, in other words, to
  531. evaluate firewalls not only in terms of what they cost now, but continuing
  532. costs such as support.
  533.  
  534. On the technical side, there are a couple of decisions to make, based on the
  535. fact that for all practical purposes what we are talking about is a static
  536. traffic routing service placed between the network service provider's router
  537. and your internal network. The traffic routing service may be implemented at
  538. an IP level via something like screening rules in a router, or at an
  539. application level via proxy gateways and services.
  540.  
  541. The decision to make is whether to place an exposed stripped-down machine on
  542. the outside network to run proxy services for telnet, FTP, news, etc., or
  543. whether to set up a screening router as a filter, permitting communication
  544. with one or more internal machines. There are pluses and minuses to both
  545. approaches, with the proxy machine providing a greater level of audit and
  546. potentially security in return for increased cost in configuration and a
  547. decrease in the level of service that may be provided (since a proxy needs
  548. to be developed for each desired service). The old trade-off between
  549. ease-of-use and security comes back to haunt us with a vengeance.
  550.  
  551. 3.2 What are the basic types of firewalls?
  552.  
  553.   Conceptually, there are two types of firewalls:
  554.  
  555. 1.   Network layer
  556. 2.   Application layer
  557.  
  558. They are not as different as you might think, and latest technologies are
  559. blurring the distinction to the point where it's no longer clear if either
  560. one is ``better'' or ``worse.'' As always, you need to be careful to pick
  561. the type that meets your needs.
  562.  
  563. Which is which depends on what mechanisms the firewall uses to pass traffic
  564. from one security zone to another. The International Standards Organization
  565. (ISO) Open Systems Interconnect (OSI) model for networking defines seven
  566. layers, where each layer provides services that ``higher-level'' layers
  567. depend on. In order from the bottom, these layers are physical, data link,
  568. network, transport, session, presentation, application.
  569.  
  570. The important thing to recognize is that the lower-level the forwarding
  571. mechanism, the less examination the firewall can perform. Generally
  572. speaking, lower-level firewalls are faster, but are easier to fool into
  573. doing the wrong thing.
  574.  
  575. 3.2.1 Network layer firewalls
  576.  
  577. These generally make their decisions based on the source, destination
  578. addresses and ports (see Appendix C for a more detailed discussion of ports)
  579. in individual IP packets. A simple router is the ``traditional'' network
  580. layer firewall, since it is not able to make particularly sophisticated
  581. decisions about what a packet is actually talking to or where it actually
  582. came from. Modern network layer firewalls have become increasingly
  583. sophisticated, and now maintain internal information about the state of
  584. connections passing through them, the contents of some of the data streams,
  585. and so on. One thing that's an important distinction about many network
  586. layer firewalls is that they route traffic directly though them, so to use
  587. one you either need to have a validly assigned IP address block or to use a
  588. ``private internet'' address block [3]. Network layer firewalls tend to be
  589. very fast and tend to be very transparent to users.
  590.  
  591.  
  592.                               Figure 1: Screened Host Firewall
  593.  
  594.  [\begin{figure} \begin{center} \includegraphics {firewalls-faq1} \end{center}\end{figure}]
  595.  
  596. In Figure 1, a network layer firewall called a ``screened host firewall'' is
  597. represented. In a screened host firewall, access to and from a single host
  598. is controlled by means of a router operating at a network layer. The single
  599. host is a bastion host; a highly-defended and secured strong-point that
  600. (hopefully) can resist attack.
  601.  
  602.  
  603.                              Figure 2: Screened Subnet Firewall
  604.  
  605.  [\begin{figure} \begin{center} \includegraphics {firewalls-faq2} \end{center}\end{figure}]
  606.  
  607. Example Network layer firewall : In figure 2, a network layer firewall
  608. called a ``screened subnet firewall'' is represented. In a screened subnet
  609. firewall, access to and from a whole network is controlled by means of a
  610. router operating at a network layer. It is similar to a screened host,
  611. except that it is, effectively, a network of screened hosts.
  612.  
  613. 3.2.2 Application layer firewalls
  614.  
  615. These generally are hosts running proxy servers, which permit no traffic
  616. directly between networks, and which perform elaborate logging and auditing
  617. of traffic passing through them. Since the proxy applications are software
  618. components running on the firewall, it is a good place to do lots of logging
  619. and access control. Application layer firewalls can be used as network
  620. address translators, since traffic goes in one ``side'' and out the other,
  621. after having passed through an application that effectively masks the origin
  622. of the initiating connection. Having an application in the way in some cases
  623. may impact performance and may make the firewall less transparent. Early
  624. application layer firewalls such as those built using the TIS firewall
  625. toolkit, are not particularly transparent to end users and may require some
  626. training. Modern application layer firewalls are often fully transparent.
  627. Application layer firewalls tend to provide more detailed audit reports and
  628. tend to enforce more conservative security models than network layer
  629. firewalls.
  630.  
  631.  
  632.                                 Figure 3: Dual Homed Gateway
  633.  
  634.  [\begin{figure} \begin{center} \includegraphics {firewalls-faq3} \end{center}\end{figure}]
  635.  
  636. Example Application layer firewall : In figure 3, an application layer
  637. firewall called a ``dual homed gateway'' is represented. A dual homed
  638. gateway is a highly secured host that runs proxy software. It has two
  639. network interfaces, one on each network, and blocks all traffic passing
  640. through it.
  641.  
  642. The Future of firewalls lies someplace between network layer firewalls and
  643. application layer firewalls. It is likely that network layer firewalls will
  644. become increasingly ``aware'' of the information going through them, and
  645. application layer firewalls will become increasingly ``low level'' and
  646. transparent. The end result will be a fast packet-screening system that logs
  647. and audits data as it passes through. Increasingly, firewalls (network and
  648. application layer) incorporate encryption so that they may protect traffic
  649. passing between them over the Internet. Firewalls with end-to-end encryption
  650. can be used by organizations with multiple points of Internet connectivity
  651. to use the Internet as a ``private backbone'' without worrying about their
  652. data or passwords being sniffed.
  653.  
  654. 3.3 What are proxy servers and how do they work?
  655.  
  656.   A proxy server (sometimes referred to as an application gateway or
  657. forwarder) is an application that mediates traffic between a protected
  658. network and the Internet. Proxies are often used instead of router-based
  659. traffic controls, to prevent traffic from passing directly between networks.
  660. Many proxies contain extra logging or support for user authentication. Since
  661. proxies must ``understand'' the application protocol being used, they can
  662. also implement protocol specific security (e.g., an FTP proxy might be
  663. configurable to permit incoming FTP and block outgoing FTP).
  664.  
  665. Proxy servers are application specific. In order to support a new protocol
  666. via a proxy, a proxy must be developed for it. One popular set of proxy
  667. servers is the TIS Internet Firewall Toolkit (``FWTK'') which includes
  668. proxies for Telnet, rlogin, FTP, X-Window, HTTP/Web, and NNTP/Usenet news.
  669. SOCKS is a generic proxy system that can be compiled into a client-side
  670. application to make it work through a firewall. Its advantage is that it's
  671. easy to use, but it doesn't support the addition of authentication hooks or
  672. protocol specific logging. For more information on SOCKS, see
  673. http://www.socks.nec.com/.
  674.  
  675. 3.4 What are some cheap packet screening tools?
  676.  
  677.   The Texas AMU security tools include software for implementing screening
  678. routers. Karlbridge is a PC-based screening router kit available from
  679. ftp://ftp.net.ohio-state.edu/pub/kbridge/. A version of the Digital
  680. Equipment Corporation ``screend'' kernel screening software is available for
  681. BSD-derived operating systems. There are numerous kernel-level packet
  682. screens, including ipf, ipfw, and ipfwadm. Typically, these are included in
  683. various free Unix implementations, such as FreeBSD, OpenBSD, NetBSD, and
  684. Linux. You might also find these tools available in your commercial Unix
  685. implementation. If you're willing to get your hands a little dirty, it's
  686. completely possible to build a secure and fully functional firewall for the
  687. price of hardware and some of your time.
  688.  
  689. 3.5 What are some reasonable filtering rules for a kernel-based packet
  690. screen?
  691.  
  692.   This example is written specifically for ipfwadm on Linux, but the
  693. principles (and even much of the syntax) applies for other kernel interfaces
  694. for packet screening on ``open source'' Unix systems.
  695.  
  696. There are four basic categories covered by the ipfwadm rules:
  697.  
  698. -A
  699.      Packet Accounting
  700. -I
  701.      Input firewall
  702. -O
  703.      Output firewall
  704. -F
  705.      Forwarding firewall
  706.  
  707. ipfwadm also has masquerading (-M) capabilities. For more information on
  708. switches and options, see the ipfwadm man page.
  709.  
  710. 3.5.1 Implementation
  711.  
  712. Here, our organization is using a private (RFC 1918) Class C network
  713. 192.168.1.0. Our ISP has assigned us the address 201.123.102.32 for our
  714. gateway's external interface and 201.123.102.33 for our external mail
  715. server. Organizational policy says:
  716.  
  717.    * Allow all outgoing TCP connections
  718.    * Allow incoming SMTP and DNS to external mail server
  719.    * Block all other traffic
  720.  
  721. The following block of commands can be placed in a system boot file (perhaps
  722. rc.local on Unix systems).
  723.  
  724.       ipfwadm -F -f
  725.       ipfwadm -F -p deny
  726.       ipfwadm -F -i m -b -P tcp -S 0.0.0.0/0 1024:65535 -D 201.123.102.33 25
  727.       ipfwadm -F -i m -b -P tcp -S 0.0.0.0/0 1024:65535 -D 201.123.102.33 53
  728.       ipfwadm -F -i m -b -P udp -S 0.0.0.0/0 1024:65535 -D 201.123.102.33 53
  729.       ipfwadm -F -a m -S 192.168.1.0/24 -D 0.0.0.0/0 -W eth0
  730.  
  731.       /sbin/route add -host 201.123.102.33 gw 192.168.1.2
  732.  
  733. 3.5.2 Explanation
  734.  
  735.    * Line one flushes (-f) all forwarding (-F) rules.
  736.    * Line two sets the default policy (-p) to deny.
  737.    * Lines three through five are input rules (-i) in the following format:
  738.  
  739.      ipfwadm -F (forward) -i (input) m (masq.) -b (bi-directional) -P
  740.      protocol)[protocol]-S (source)[subnet/mask] [originating ports]-D
  741.      (destination)[subnet/mask][port]
  742.    * Line six appends (-a) a rule that permits all internal IP addresses out
  743.      to all external addresses on all protocols, all ports.
  744.    * Line eight adds a route so that traffic going to 201.123.102.33 will be
  745.      directed to the internal address 192.168.1.2.
  746.  
  747. 3.6 What are some reasonable filtering rules for a Cisco?
  748.  
  749.   The example in figure 4 shows one possible configuration for using the
  750. Cisco as filtering router. It is a sample that shows the implementation of
  751. as specific policy. Your policy will undoubtedly vary.
  752.  
  753.  
  754.                              Figure 4: Packet Filtering Router
  755.  
  756.  [\begin{figure} \begin{center} \includegraphics {firewalls-faq4} \end{center}\end{figure}]
  757.  
  758. In this example, a company has Class C network address 195.55.55.0. Company
  759. network is connected to Internet via IP Service Provider. Company policy is
  760. to allow everybody access to Internet services, so all outgoing connections
  761. are accepted. All incoming connections go through ``mailhost''. Mail and DNS
  762. are only incoming services.
  763.  
  764. 3.6.1 Implementation
  765.  
  766.    * Allow all outgoing TCP-connections
  767.    * Allow incoming SMTP and DNS to mailhost
  768.    * Allow incoming FTP data connections to high TCP port (>1024)
  769.    * Try to protect services that live on high port numbers
  770.  
  771. Only incoming packets from Internet are checked in this configuration. Rules
  772. are tested in order and stop when the first match is found. There is an
  773. implicit deny rule at the end of an access list that denies everything. This
  774. IP access list assumes that you are running Cisco IOS v. 10.3 or later.
  775.  
  776. no ip source-route
  777. !
  778. interface ethernet 0
  779. ip address 195.55.55.1
  780. no ip directed-broadcast
  781. !
  782. interface serial 0
  783. no ip directed-broadcast
  784. ip access-group 101 in
  785. !
  786. access-list 101 deny ip 127.0.0.0 0.255.255.255 any
  787. access-list 101 deny ip 10.0.0.0 0.255.255.255 any
  788. access-list 101 deny ip 172.16.0.0 0.15.255.255 any
  789. access-list 101 deny ip 192.168.0.0 0.0.255.255 any
  790. access-list 101 deny ip any 0.0.0.255 255.255.255.0
  791. access-list 101 deny ip any 0.0.0.0 255.255.255.0
  792. !
  793. access-list 101 deny ip 195.55.55.0 0.0.0.255
  794. access-list 101 permit tcp any any established
  795. !
  796. access-list 101 permit tcp any host 195.55.55.10 eq smtp
  797. access-list 101 permit tcp any host 195.55.55.10 eq dns
  798. access-list 101 permit udp any host 192.55.55.10 eq dns
  799. !
  800. access-list 101 deny tcp any any range 6000 6003
  801. access-list 101 deny tcp any any range 2000 2003
  802. access-list 101 deny tcp any any eq 2049
  803. access-list 101 deny udp any any eq 2049
  804. !
  805. access-list 101 permit tcp any 20 any gt 1024
  806. !
  807. access-list 101 permit icmp any any
  808. !
  809. snmp-server community FOOBAR RO 2
  810. line vty 0 4
  811. access-class 2 in
  812. access-list 2 permit 195.55.55.0 0.0.0.255
  813.  
  814. 3.6.2 Explanations
  815.  
  816.    * Drop all source-routed packets. Source routing can be used for address
  817.      spoofing.
  818.    * Drop directed broadcasts, which are used in smurf attacks.
  819.    * If an incoming packet claims to be from a local net, loopback network,
  820.      or private network, drop it.
  821.    * All packets which are part of already established TCP-connections can
  822.      pass through without further checking.
  823.    * All connections to low port numbers are blocked except SMTP and DNS.
  824.    * Block all services that listen for TCP connections on high port
  825.      numbers. X-windows (port 6000+), OpenWindows (port 2000+) are a few
  826.      candidates. NFS (port 2049) runs usually over UDP, but it can be run
  827.      over TCP, so you should block it.
  828.    * Incoming connections from port 20 into high port numbers are supposed
  829.      to be FTP data connections.
  830.    * Access-list 2 limits access to router itself (telnet & SNMP)
  831.    * All UDP traffic is blocked to protect RPC services
  832.  
  833. 3.6.3 Shortcomings
  834.  
  835.    * You cannot enforce strong access policies with router access lists.
  836.      Users can easily install backdoors to their systems to get over ``no
  837.      incoming telnet'' or ``no X'' rules. Also crackers install telnet
  838.      backdoors on systems where they break in.
  839.    * You can never be sure what services you have listening for connections
  840.      on high port numbers.
  841.    * Checking the source port on incoming FTP data connections is a weak
  842.      security method. It also breaks access to some FTP sites. It makes use
  843.      of the service more difficult for users without preventing bad guys
  844.      from scanning your systems.
  845.  
  846. Use at least Cisco version 9.21 so you can filter incoming packets and check
  847. for address spoofing. It's still better to use 10.3, where you get some
  848. extra features (like filtering on source port) and some improvements on
  849. filter syntax.
  850.  
  851. You have still a few ways to make your setup stronger. Block all incoming
  852. TCP-connections and tell users to use passive-FTP clients. You can also
  853. block outgoing ICMP echo-reply and destination-unreachable messages to hide
  854. your network and to prevent use of network scanners. Cisco.com use to have
  855. an archive of examples for building firewalls using Cisco routers, but it
  856. doesn't seem to be online anymore. There are some notes on Cisco access
  857. control lists, at least, at
  858. ftp://ftp.cisco.com/pub/mibs/app_notes/access-lists.
  859.  
  860. 3.7 What are the critical resources in a firewall?
  861.  
  862.   It's important to understand the critical resources of your firewall
  863. architecture, so when you do capacity planning, performance optimizations,
  864. etc., you know exactly what you need to do, and how much you need to do it
  865. in order to get the desired result.
  866.  
  867. What exactly the firewall's critical resources are tends to vary from site
  868. to site, depending on the sort of traffic that loads the system. Some people
  869. think they'll automatically be able to increase the data throughput of their
  870. firewall by putting in a box with a faster CPU, or another CPU, when this
  871. isn't necessarily the case. Potentially, this could be a large waste of
  872. money that doesn't do anything to solve the problem at hand or provide the
  873. expected scalability.
  874.  
  875. On busy systems, memory is extremely important. You have to have enough RAM
  876. to support every instance of every program necessary to service the load
  877. placed on that machine. Otherwise, the swapping will start and the
  878. productivity will stop. Light swapping isn't usually much of a problem, but
  879. if a system's swap space begins to get busy, then it's usually time for more
  880. RAM. A system that's heavily swapping is often relatively easy to push over
  881. the edge in a denial-of-service attack, or simply fall behind in processing
  882. the load placed on it. This is where long email delays start.
  883.  
  884. Beyond the system's requirement for memory, it's useful to understand that
  885. different services use different system resources. So the configuration that
  886. you have for your system should be indicative of the kind of load you plan
  887. to service. A 700 MHz processor isn't going to do you much good if all
  888. you're doing is netnews and mail, and are trying to do it on an IDE disk
  889. with an ISA controller.
  890.  
  891.  
  892.                   Table 1: Critical Resources for Firewall
  893.                                   Services
  894.  
  895.               Service     Critical Resource
  896.  
  897.               Email       Disk I/O
  898.  
  899.               Netnews     Disk I/O
  900.  
  901.               Web         Host OS Socket Performance
  902.  
  903.               IP Routing  Host OS Socket Performance
  904.  
  905.               Web Cache   Host OS Socket Performance, Disk I/O
  906.  
  907.  
  908. 3.8 What is a DMZ, and why do I want one?
  909.  
  910.   ``DMZ'' is an abbreviation for ``demilitarized zone''. In the context of
  911. firewalls, this refers to a part of the network that is neither part of the
  912. internal network nor directly part of the Internet. Typically, this is the
  913. area between your Internet access router and your bastion host, though it
  914. can be between any two policy-enforcing components of your architecture.
  915.  
  916. A DMZ can be created by putting access control lists on your access router.
  917. This minimizes the exposure of hosts on your external LAN by allowing only
  918. recognized and managed services on those hosts to be accessible by hosts on
  919. the Internet. Many commercial firewalls simply make a third interface off of
  920. the bastion host and label it the DMZ. The point is that the network is
  921. neither ``inside'' nor ``outside''.
  922.  
  923. For example, a web server running on NT might be vulnerable to a number of
  924. denial-of-service attacks against such services as RPC, NetBIOS and SMB.
  925. These services are not required for the operation of a web server, so
  926. blocking TCP connections to ports 135, 137, 138, and 139 on that host will
  927. reduce the exposure to a denial-of-service attack. In fact, if you block
  928. everything but HTTP traffic to that host, an attacker will only have one
  929. service to attack.
  930.  
  931. This illustrates an important principle: never offer attackers more to work
  932. with than is absolutely necessary to support the services you want to offer
  933. the public.
  934.  
  935. 3.9 How might I increase the security and scalability of my DMZ?
  936.  
  937.   A common approach for an attacker is to break into a host that's
  938. vulnerable to attack, and exploit trust relationships between the vulnerable
  939. host and more interesting targets.
  940.  
  941. If you are running a number of services that have different levels of
  942. security, you might want to consider breaking your DMZ into several
  943. ``security zones''. This can be done by having a number of different
  944. networks within the DMZ. For example, the access router could feed two
  945. ethernets, both protected by ACLs, and therefore in the DMZ.
  946.  
  947. On one of the ethernets, you might have hosts whose purpose is to service
  948. your organization's need for Internet connectivity. These will likely relay
  949. mail, news, and host DNS. On the other ethernet could be your web server(s)
  950. and other hosts that provide services for the benefit of Internet users.
  951.  
  952. In many organizations, services for Internet users tend to be less carefully
  953. guarded and are more likely to be doing insecure things. (For example, in
  954. the case of a web server, unauthenticated and untrusted users might be
  955. running CGI or other executable programs. This might be reasonable for your
  956. web server, but brings with it a certain set of risks that need to be
  957. managed. It is likely these services are too risky for an organization to
  958. run them on a bastion host, where a slip-up can result in the complete
  959. failure of the security mechanisms.)
  960.  
  961. By putting hosts with similar levels of risk on networks together in the
  962. DMZ, you can help minimize the effect of a breakin at your site. If someone
  963. breaks into your web server by exploiting some bug in your web server,
  964. they'll not be able to use it as a launching point to break into your
  965. private network if the web servers are on a separate LAN from the bastion
  966. hosts, and you don't have any trust relationships between the web server and
  967. bastion host.
  968.  
  969. Now, keep in mind that we're running ethernet here. If someone breaks into
  970. your web server, and your bastion host is on the same ethernet, an attacker
  971. can install a sniffer on your web server, and watch the traffic to and from
  972. your bastion host. This might reveal things that can be used to break into
  973. the bastion host and gain access to the internal network.
  974.  
  975. Splitting services up not only by host, but by network, and limiting the
  976. level of trust between hosts on those networks, you can greatly reduce the
  977. likelihood of a breakin on one host being used to break into the other.
  978. Succinctly stated: breaking into the web server in this case won't make it
  979. any easier to break into the bastion host.
  980.  
  981. You can also increase the scalability of your architecture by placing hosts
  982. on different networks. The fewer machines that there are to share the
  983. available bandwidth, the more bandwidth that each will get.
  984.  
  985. 3.10 What is a `single point of failure', and how do I avoid having one?
  986.  
  987.   An architecture whose security hinges upon one mechanism has a single
  988. point of failure. Software that runs bastion hosts has bugs. Applications
  989. have bugs. Software that controls routers has bugs. It makes sense to use
  990. all of these components to build a securely designed network, and to use
  991. them in redundant ways.
  992.  
  993. If your firewall architecture is a screened subnet, you have two packet
  994. filtering routers and a bastion host. (See question 3.2 from this section.)
  995. Your Internet access router will not permit traffic from the Internet to get
  996. all the way into your private network. However, if you don't enforce that
  997. rule with any other mechanisms on the bastion host and/or choke router, only
  998. one component of your architecture needs to fail or be compromised in order
  999. to get inside. On the other hand, if you have a redundant rule on the
  1000. bastion host, and again on the choke router, an attacker will need to defeat
  1001. three mechanisms.
  1002.  
  1003. Further, if the bastion host or the choke router needs to invoke its rule to
  1004. block outside access to the internal network, you might want to have it
  1005. trigger an alarm of some sort, since you know that someone has gotten
  1006. through your access router.
  1007.  
  1008. 3.11 How can I block all of the bad stuff?
  1009.  
  1010.   For firewalls where the emphasis is on security instead of connectivity,
  1011. you should consider blocking everything by default, and only specifically
  1012. allowing what services you need on a case-by-case basis.
  1013.  
  1014. If you block everything, except a specific set of services, then you've
  1015. already made your job much easier. Instead of having to worry about every
  1016. security problem with everything product and service around, you only need
  1017. to worry about every security problem with a specific set of services and
  1018. products. :-)
  1019.  
  1020. Before turning on a service, you should consider a couple of questions:
  1021.  
  1022.    * Is the protocol for this product a well-known, published protocol?
  1023.    * Is the application to service this protocol available for public
  1024.      inspection of its implementation?
  1025.    * How well known is the service and product?
  1026.    * How does allowing this service change the firewall architecture? Will
  1027.      an attacker see things differently? Could it be exploited to get at my
  1028.      internal network, or to change things on hosts in my DMZ?
  1029.  
  1030. When considering the above questions, keep the following in mind:
  1031.  
  1032.    * ``Security through obscurity'' is no security at all. Unpublished
  1033.      protocols have been examined by bad guys and defeated.
  1034.    * Despite what the marketing representatives say, not every protocol or
  1035.      service is designed with security in mind. In fact, the number that are
  1036.      is very few.
  1037.    * Even in cases where security is a consideration, not all organizations
  1038.      have competent security staff. Among those who don't, not all are
  1039.      willing to bring a competent consultant into the project. The end
  1040.      result is that otherwise-competent, well-intended developers can design
  1041.      insecure systems.
  1042.    * The less that a vendor is willing to tell you about how their system
  1043.      really works, the more likely it is that security (or other) problems
  1044.      exist. Only vendors with something to hide have a reason to hide their
  1045.      designs and implementations.
  1046.  
  1047. 3.12 How can I restrict web access so users can't view sites unrelated to
  1048. work?
  1049.  
  1050.   A few years ago, someone got the idea that it's a good idea to block
  1051. ``bad'' web sites, i.e., those that contain material that The Company views
  1052. ``inappropriate''. The idea has been increasing in popularity, but there are
  1053. several things to consider when thinking about implementing such controls in
  1054. your firewall.
  1055.  
  1056.    * It is not possible to practically block everything that an employer
  1057.      deems ``inappropriate''. The Internet is full of every sort of
  1058.      material. Blocking one source will only redirect traffic to another
  1059.      source of such material, or cause someone to figure a way around the
  1060.      block.
  1061.    * Most organizations do not have a standard for judging the
  1062.      appropriateness of material that their employees bring to work, i.e.,
  1063.      books, magazines, etc. Do you inspect everyone's briefcase for
  1064.      ``inappropriate material'' every day? If you do not, then why would you
  1065.      inspect every packet for ``inappropriate material''? Any decisions
  1066.      along those lines in such an organization will be arbitrary. Attempting
  1067.      to take disciplinary action against an employee where the only standard
  1068.      is arbitrary typically isn't wise, for reasons well beyond the scope of
  1069.      this document.
  1070.    * Products that perform site-blocking, commercial and otherwise, are
  1071.      typically easy to circumvent. Hostnames can be rewritten as IP
  1072.      addresses. IP addresses can be written as a 32-bit integer value, or as
  1073.      four 8-bit integers (the most common form). Other possibilities exist,
  1074.      as well. Connections can be proxied. Web pages can be fetched via
  1075.      email. You can't block them all. The effort that you'll spend trying to
  1076.      implement and manage such controls will almost certainly far exceed any
  1077.      level of damage control that you're hoping to have.
  1078.  
  1079. The rule-of-thumb to remember here is that you cannot solve social problems
  1080. with technical solutions. If there is a problem with someone going to an
  1081. ``inappropriate'' web site, that is because someone else saw it and was
  1082. offended by what he saw, or because that person's productivity is below
  1083. expectations. In either case, those are matters for the personnel
  1084. department, not the firewall administrator.
  1085.  
  1086. 4 Various Attacks
  1087.  
  1088.  
  1089.  
  1090. 4.1 What is source routed traffic and why is it a threat?
  1091.  
  1092.   Normally, the route a packet takes from its source to its destination is
  1093. determined by the routers between the source and destination. The packet
  1094. itself only says where it wants to go (the destination address), and nothing
  1095. about how it expects to get there.
  1096.  
  1097. There is an optional way for the sender of a packet (the source) to include
  1098. information in the packet that tells the route the packet should take to get
  1099. to its destination; thus the name ``source routing''. For a firewall, source
  1100. routing is noteworthy, since an attacker can generate traffic claiming to be
  1101. from a system ``inside'' the firewall. In general, such traffic wouldn't
  1102. route to the firewall properly, but with the source routing option, all the
  1103. routers between the attacker's machine and the target will return traffic
  1104. along the reverse path of the source route. Implementing such an attack is
  1105. quite easy; so firewall builders should not discount it as unlikely to
  1106. happen.
  1107.  
  1108. In practice, source routing is very little used. In fact, generally the main
  1109. legitimate use is in debugging network problems or routing traffic over
  1110. specific links for congestion control for specialized situations. When
  1111. building a firewall, source routing should be blocked at some point. Most
  1112. commercial routers incorporate the ability to block source routing
  1113. specifically, and many versions of Unix that might be used to build firewall
  1114. bastion hosts have the ability to disable or ignore source routed traffic.
  1115.  
  1116. 4.2 What are ICMP redirects and redirect bombs?
  1117.  
  1118.   An ICMP Redirect tells the recipient system to over-ride something in its
  1119. routing table. It is legitimately used by routers to tell hosts that the
  1120. host is using a non-optimal or defunct route to a particular destination,
  1121. i.e. the host is sending it to the wrong router. The wrong router sends the
  1122. host back an ICMP Redirect packet that tells the host what the correct route
  1123. should be. If you can forge ICMP Redirect packets, and if your target host
  1124. pays attention to them, you can alter the routing tables on the host and
  1125. possibly subvert the security of the host by causing traffic to flow via a
  1126. path the network manager didn't intend. ICMP Redirects also may be employed
  1127. for denial of service attacks, where a host is sent a route that loses it
  1128. connectivity, or is sent an ICMP Network Unreachable packet telling it that
  1129. it can no longer access a particular network.
  1130.  
  1131. Many firewall builders screen ICMP traffic from their network, since it
  1132. limits the ability of outsiders to ping hosts, or modify their routing
  1133. tables.
  1134.  
  1135. Before you decide to completely block ICMP, you should be aware of how the
  1136. TCP protocol does ``Path MTU Discovery'', to make certain that you don't
  1137. break connectivity to other sites. If you can't safely block it everywhere,
  1138. you can consider allowing selected types of ICMP to selected routing
  1139. devices. If you don't block it, you should at least ensure that your routers
  1140. and hosts don't respond to broadcast ping packets.
  1141.  
  1142. 4.3 What about denial of service?
  1143.  
  1144.   Denial of service is when someone decides to make your network or firewall
  1145. useless by disrupting it, crashing it, jamming it, or flooding it. The
  1146. problem with denial of service on the Internet is that it is impossible to
  1147. prevent. The reason has to do with the distributed nature of the network:
  1148. every network node is connected via other networks which in turn connect to
  1149. other networks, etc. A firewall administrator or ISP only has control of a
  1150. few of the local elements within reach. An attacker can always disrupt a
  1151. connection ``upstream'' from where the victim controls it. In other words,
  1152. if someone wanted to take a network off the air, they could do it either by
  1153. taking the network off the air, or by taking the networks it connects to off
  1154. the air, ad infinitum. There are many, many, ways someone can deny service,
  1155. ranging from the complex to the brute-force. If you are considering using
  1156. Internet for a service which is absolutely time or mission critical, you
  1157. should consider your fall-back position in the event that the network is
  1158. down or damaged.
  1159.  
  1160. TCP/IP's UDP echo service is trivially abused to get two servers to flood a
  1161. network segment with echo packets. You should consider commenting out unused
  1162. entries in /etc/inetd.conf of Unix hosts, adding no ip small-servers to
  1163. Cisco routers, or the equivalent for your components.
  1164.  
  1165. 4.4 What are some common attacks, and how can I protect my system against
  1166. them?
  1167.  
  1168.   Each site is a little different from every other in terms of what attacks
  1169. are likely to be used against it. Some recurring themes do arise, though.
  1170.  
  1171. 4.4.1 SMTP Server Hijacking (Unauthorized Relaying)
  1172.  
  1173. This is where a spammer will take many thousands of copies of a message and
  1174. send it to a huge list of email addresses. Because these lists are often so
  1175. bad, and in order to increase the speed of operation for the spammer, many
  1176. have resorted to simply sending all of their mail to an SMTP server that
  1177. will take care of actually delivering the mail.
  1178.  
  1179. Of course, all of the bounces, spam complaints, hate mail, and bad PR come
  1180. for the site that was used as a relay. There is a very real cost associated
  1181. with this, mostly in paying people to clean up the mess afterward.
  1182.  
  1183. The Mail Abuse Prevention System <URL:http://maps.vix.com/> Transport
  1184. Security Initiative <URL:http://maps.vix.com/tsi/> maintains a
  1185. complete description of the problem, and how to configure about every
  1186. mailer on the planet to protect against this attack.
  1187.  
  1188. 4.4.2 Exploiting Bugs in Applications
  1189.  
  1190. Various versions of web servers, mail servers, and other Internet service
  1191. software contain bugs that allow remote (Internet) users to do things
  1192. ranging from gain control of the machine to making that application crash
  1193. and just about everything in between.
  1194.  
  1195. The exposure to this risk can be reduced by running only necessary services,
  1196. keeping up to date on patches, and using products that have been around a
  1197. while.
  1198.  
  1199. 4.4.3 Bugs in Operating Systems
  1200.  
  1201. Again, these are typically initiated by users remotely. Operating systems
  1202. that are relatively new to IP networking tend to be more problematic, as
  1203. more mature operating systems have had time to find and eliminate their
  1204. bugs. An attacker can often make the target equipment continuously reboot,
  1205. crash, lose the ability to talk to the network, or replace files on the
  1206. machine.
  1207.  
  1208. Here, running as few operating system services as possible can help. Also,
  1209. having a packet filter in front of the operating system can reduce the
  1210. exposure to a large number of these types of attacks.
  1211.  
  1212. And, of course, chosing a stable operating system will help here as well.
  1213. When selecting an OS, don't be fooled into believing that ``the pricier, the
  1214. better''. Free operating systems are often much more robust than their
  1215. commercial counterparts
  1216.  
  1217. 5 How Do I...
  1218.  
  1219.  
  1220.  
  1221. 5.1 Do I really want to allow everything that my users ask for?
  1222.  
  1223.   It's entirely possible that the answer is ``no''. Each site has its own
  1224. policies about what is and isn't needed, but it's important to remember that
  1225. a large part of the job of being an organization's gatekeeper is education.
  1226. Users want streaming video, real-time chat, and to be able to offer services
  1227. to external customers that require interaction with live databases on the
  1228. internal network.
  1229.  
  1230. That doesn't mean that any of these things can be done without presenting
  1231. more risk to the organization than the supposed ``value'' of heading down
  1232. that road is worth. Most users don't want to put their organization at risk.
  1233. They just read the trade rags, see advertisements, and they want to do those
  1234. things, too. It's important to look into what it is that they really want to
  1235. do, and to help them understand how they might be able to accomplish their
  1236. real objective in a more secure manner.
  1237.  
  1238. You won't always be popular, and you might even find yourself being given
  1239. direction to do something incredibly stupid, like ``just open up ports foo
  1240. through bar''. If that happens, don't worry about it. It would be wise to
  1241. keep all of your exchanges on such an event so that when a 12-year-old
  1242. script kiddie breaks in, you'll at least be able to separate yourself from
  1243. the whole mess.
  1244.  
  1245. 5.2 How do I make Web/HTTP work through my firewall?
  1246.  
  1247.   There are three ways to do it.
  1248.  
  1249. 1.   Allow ``established'' connections out via a router, if you are using
  1250.      screening routers.
  1251. 2.   Use a web client that supports SOCKS, and run SOCKS on your bastion
  1252.      host.
  1253. 3.   Run some kind of proxy-capable web server on the bastion host. Some
  1254.      options include Squid <URL:http://squid.nlanr.net/>, Apache
  1255.      <URL:http://www.apache.org/docs/mod/mod_proxy.html>, Netscape
  1256.      Proxy <URL:http://home.netscape.com/proxy/v3.5/index.html>, and
  1257.      http-gw from the TIS firewall toolkit. Most of these can also proxy
  1258.      other protocols (such as gopher and ftp), and can cache objects
  1259.      fetched, which will also typically result in a performance boost for
  1260.      the users, and more efficient use of your connection to the Internet.
  1261.      Essentially all web clients (Mozilla, Internet Explorer, Lynx, etc.)
  1262.      have proxy server support built directly into them.
  1263.  
  1264. 5.3 How do I make SSL work through the firewall?
  1265.  
  1266.   SSL is a protocol that allows secure connections across the Internet.
  1267. Typically, SSL is used to protect HTTP traffic. However, other protocols
  1268. (such as telnet) can run atop SSL.
  1269.  
  1270. Enabling SSL through your firewall can be done the same way that you would
  1271. allow HTTP traffic, if it's HTTP that you're using SSL to secure, which is
  1272. usually true. The only difference is that instead of using something that
  1273. will simply relay HTTP, you'll need something that can tunnel SSL. This is a
  1274. feature present on most web object caches.
  1275.  
  1276. You can find out more about SSL from Netscape
  1277. <URL:http://developer.netscape.com/docs/manuals/security/sslin/contents.htm>.
  1278.  
  1279.  
  1280. 5.4 How do I make DNS work with a firewall?
  1281.  
  1282.   Some organizations want to hide DNS names from the outside. Many experts
  1283. don't think hiding DNS names is worthwhile, but if site/corporate policy
  1284. mandates hiding domain names, this is one approach that is known to work.
  1285. Another reason you may have to hide domain names is if you have a
  1286. non-standard addressing scheme on your internal network. In that case, you
  1287. have no choice but to hide those addresses. Don't fool yourself into
  1288. thinking that if your DNS names are hidden that it will slow an attacker
  1289. down much if they break into your firewall. Information about what is on
  1290. your network is too easily gleaned from the networking layer itself. If you
  1291. want an interesting demonstration of this, ping the subnet broadcast address
  1292. on your LAN and then do an ``arp -a.'' Note also that hiding names in the
  1293. DNS doesn't address the problem of host names ``leaking'' out in mail
  1294. headers, news articles, etc.
  1295.  
  1296. This approach is one of many, and is useful for organizations that wish to
  1297. hide their host names from the Internet. The success of this approach lies
  1298. on the fact that DNS clients on a machine don't have to talk to a DNS server
  1299. on that same machine. In other words, just because there's a DNS server on a
  1300. machine, there's nothing wrong with (and there are often advantages to)
  1301. redirecting that machine's DNS client activity to a DNS server on another
  1302. machine.
  1303.  
  1304. First, you set up a DNS server on the bastion host that the outside world
  1305. can talk to. You set this server up so that it claims to be authoritative
  1306. for your domains. In fact, all this server knows is what you want the
  1307. outside world to know; the names and addresses of your gateways, your
  1308. wildcard MX records, and so forth. This is the ``public'' server.
  1309.  
  1310. Then, you set up a DNS server on an internal machine. This server also
  1311. claims to be authoritative for your domains; unlike the public server, this
  1312. one is telling the truth. This is your ``normal'' nameserver, into which you
  1313. put all your ``normal'' DNS stuff. You also set this server up to forward
  1314. queries that it can't resolve to the public server (using a ``forwarders''
  1315. line in /etc/named.boot on a Unix machine, for example).
  1316.  
  1317. Finally, you set up all your DNS clients (the /etc/resolv.conf file on a
  1318. Unix box, for instance), including the ones on the machine with the public
  1319. server, to use the internal server. This is the key.
  1320.  
  1321. An internal client asking about an internal host asks the internal server,
  1322. and gets an answer; an internal client asking about an external host asks
  1323. the internal server, which asks the public server, which asks the Internet,
  1324. and the answer is relayed back. A client on the public server works just the
  1325. same way. An external client, however, asking about an internal host gets
  1326. back the ``restricted'' answer from the public server.
  1327.  
  1328. This approach assumes that there's a packet filtering firewall between these
  1329. two servers that will allow them to talk DNS to each other, but otherwise
  1330. restricts DNS between other hosts.
  1331.  
  1332. Another trick that's useful in this scheme is to employ wildcard PTR records
  1333. in your IN-ADDR.ARPA domains. These cause an an address-to-name lookup for
  1334. any of your non-public hosts to return something like
  1335. ``unknown.YOUR.DOMAIN'' rather than an error. This satisfies anonymous FTP
  1336. sites like ftp.uu.net that insist on having a name for the machines they
  1337. talk to. This may fail when talking to sites that do a DNS cross-check in
  1338. which the host name is matched against its address and vice versa.
  1339.  
  1340. 5.5 How do I make FTP work through my firewall?
  1341.  
  1342.   Generally, making FTP work through the firewall is done either using a
  1343. proxy server such as the firewall toolkit's ftp-gw or by permitting incoming
  1344. connections to the network at a restricted port range, and otherwise
  1345. restricting incoming connections using something like ``established''
  1346. screening rules. The FTP client is then modified to bind the data port to a
  1347. port within that range. This entails being able to modify the FTP client
  1348. application on internal hosts.
  1349.  
  1350. In some cases, if FTP downloads are all you wish to support, you might want
  1351. to consider declaring FTP a ``dead protocol'' and letting you users download
  1352. files via the Web instead. The user interface certainly is nicer, and it
  1353. gets around the ugly callback port problem. If you choose the FTP-via-Web
  1354. approach, your users will be unable to FTP files out, which, depending on
  1355. what you are trying to accomplish, may be a problem.
  1356.  
  1357. A different approach is to use the FTP ``PASV'' option to indicate that the
  1358. remote FTP server should permit the client to initiate connections. The PASV
  1359. approach assumes that the FTP server on the remote system supports that
  1360. operation. (See ``Firewall-Friendly FTP'' [1].)
  1361.  
  1362. Other sites prefer to build client versions of the FTP program that are
  1363. linked against a SOCKS library.
  1364.  
  1365. 5.6 How do I make Telnet work through my firewall?
  1366.  
  1367.   Telnet is generally supported either by using an application proxy such as
  1368. the firewall toolkit's tn-gw, or by simply configuring a router to permit
  1369. outgoing connections using something like the ``established'' screening
  1370. rules. Application proxies could be in the form of a standalone proxy
  1371. running on the bastion host, or in the form of a SOCKS server and a modified
  1372. client.
  1373.  
  1374. 5.7 How do I make Finger and whois work through my firewall?
  1375.  
  1376.   Many firewall admins permit connections to the finger port from only
  1377. trusted machines, which can issue finger requests in the form of: finger
  1378. user@host.domain@firewall. This approach only works with the standard Unix
  1379. version of finger. Controlling access to services and restricting them to
  1380. specific machines is managed using either tcp_wrappers or netacl from the
  1381. firewall toolkit. This approach will not work on all systems, since some
  1382. finger servers do not permit user@host@host fingering.
  1383.  
  1384. Many sites block inbound finger requests for a variety of reasons, foremost
  1385. being past security bugs in the finger server (the Morris internet worm made
  1386. these bugs famous) and the risk of proprietary or sensitive information
  1387. being revealed in user's finger information. In general, however, if your
  1388. users are accustomed to putting proprietary or sensitive information in
  1389. their .plan files, you have a more serious security problem than just a
  1390. firewall can solve.
  1391.  
  1392. 5.8 How do I make gopher, archie, and other services work through my
  1393. firewall?
  1394.  
  1395.   The majority of firewall administrators choose to support gopher and
  1396. archie through web proxies, instead of directly. Proxies such as the
  1397. firewall toolkit's http-gw convert gopher/gopher+ queries into HTML and vice
  1398. versa. For supporting archie and other queries, many sites rely on
  1399. Internet-based Web-to-archie servers, such as ArchiePlex. The Web's tendency
  1400. to make everything on the Internet look like a web service is both a
  1401. blessing and a curse.
  1402.  
  1403. There are many new services constantly cropping up. Often they are
  1404. misdesigned or are not designed with security in mind, and their designers
  1405. will cheerfully tell you if you want to use them you need to let port xxx
  1406. through your router. Unfortunately, not everyone can do that, and so a
  1407. number of interesting new toys are difficult to use for people behind
  1408. firewalls. Things like RealAudio, which require direct UDP access, are
  1409. particularly egregious examples. The thing to bear in mind if you find
  1410. yourself faced with one of these problems is to find out as much as you can
  1411. about the security risks that the service may present, before you just allow
  1412. it through. It's quite possible the service has no security implications.
  1413. It's equally possible that it has undiscovered holes you could drive a truck
  1414. through.
  1415.  
  1416. 5.9 What are the issues about X11 through a firewall?
  1417.  
  1418.   The X Windows System is a very useful system, but unfortunately has some
  1419. major security flaws. Remote systems that can gain or spoof access to a
  1420. workstation's X display can monitor keystrokes that a user enters, download
  1421. copies of the contents of their windows, etc.
  1422.  
  1423. While attempts have been made to overcome them (E.g., MIT ``Magic Cookie'')
  1424. it is still entirely too easy for an attacker to interfere with a user's X
  1425. display. Most firewalls block all X traffic. Some permit X traffic through
  1426. application proxies such as the DEC CRL X proxy (FTP crl.dec.com). The
  1427. firewall toolkit includes a proxy for X, called x-gw, which a user can
  1428. invoke via the Telnet proxy, to create a virtual X server on the firewall.
  1429. When requests are made for an X connection on the virtual X server, the user
  1430. is presented with a pop-up asking them if it is OK to allow the connection.
  1431. While this is a little unaesthetic, it's entirely in keeping with the rest
  1432. of X.
  1433.  
  1434. 5.10 How do I make RealAudio work through my firewall?
  1435.  
  1436.   RealNetworks maintains some information about how to get RealAudio
  1437. working through your firewall <URL:http://www.real.com/firewall/>.  It
  1438. would be unwise to make any changes to your firewall without
  1439. understanding what the changes will do, exactly, and knowing what
  1440. risks the new changes will bring with them.
  1441.  
  1442. 5.11 How do I make my web server act as a front-end for a database that
  1443. lives on my private network?
  1444.  
  1445.   The best way to do this is to allow very limited connectivity between your
  1446. web server and your database server via a specific protocol that only
  1447. supports the level of functionality you're going to use. Allowing raw SQL,
  1448. or anything else where custom extractions could be performed by an attacker
  1449. isn't generally a good idea.
  1450.  
  1451. Assume that an attacker is going to be able to break into your web server,
  1452. and make queries in the same way that the web server can. Is there a
  1453. mechanism for extracting sensitive information that the web server doesn't
  1454. need, like credit card information? Can an attacker issue an SQL select and
  1455. extract your entire proprietary database?
  1456.  
  1457. ``E-commerce'' applications, like everything else, are best designed with
  1458. security in mind from the ground up, instead of having security ``added'' as
  1459. an afterthought. Review your architecture critically, from the perspective
  1460. of an attacker. Assume that the attacker knows everything about your
  1461. architecture. Now ask yourself what needs to be done to steal your data, to
  1462. make unauthorized changes, or to do anything else that you don't want done.
  1463. You might find that you can significantly increase security without
  1464. decreasing functionality by making a few design and implementation
  1465. decisions.
  1466.  
  1467. Some ideas for how to handle this:
  1468.  
  1469.    * Extract the data you need from the database on a regular basis so
  1470.      you're not making queries against the full database, complete with
  1471.      information that attackers will find interesting.
  1472.    * Greatly restrict and audit what you do allow between the web server and
  1473.      database.
  1474.  
  1475. 5.12 But my database has an integrated web server, and I want to use that.
  1476. Can't I just poke a hole in the firewall and tunnel that port?
  1477.  
  1478.   If your site firewall policy is sufficiently lax that you're willing to
  1479. manage the risk that someone will exploit a vulnerability in your web server
  1480. that will result in partial or complete exposure of your database, then
  1481. there isn't much preventing you from doing this.
  1482.  
  1483. However, in many organizations, the people who are responsible for tying the
  1484. web front end to the database back end simply do not have the authority to
  1485. take that responsibility. Further, if the information in the database is
  1486. about people, you might find yourself guilty of breaking a number of laws if
  1487. you haven't taken reasonable precautions to prevent the system from being
  1488. abused.
  1489.  
  1490. In general, this isn't a good idea. See question 5.11 for some ideas on
  1491. other ways to accomplish this objective.
  1492.  
  1493. 5.13 How Do I Make IP Multicast Work With My Firewall?
  1494.  
  1495.   IP multicast is a means of getting IP traffic from one host to a set of
  1496. hosts without using broadcasting; that is, instead of every host getting the
  1497. traffic, only those that want it will get it, without each having to
  1498. maintain a separate connection to the server. IP unicast is where one host
  1499. talks to another, multicast is where one host talks to a set of hosts, and
  1500. broadcast is where one host talks to all hosts.
  1501.  
  1502. The public Internet has a multicast backbone (``MBone'') where users can
  1503. engage in multicast traffic exchange. Common uses for the MBone are streams
  1504. of IETF meetings and similar such interaction. Getting one's own network
  1505. connected to the MBone will require that the upstream provider route
  1506. multicast traffic to and from your network. Additionally, your internal
  1507. network will have to support multicast routing.
  1508.  
  1509. The role of the firewall in multicast routing, conceptually, is no different
  1510. from its role in other traffic routing. That is, a policy that identifies
  1511. which multicast groups are and aren't allowed must be defined and then a
  1512. system of allowing that traffic according to policy must be devised. Great
  1513. detail on how exactly to do this is beyond the scope of this document.
  1514. Fortunately, RFC 2588 [2] discusses the subject in more detail. Unless your
  1515. firewall product supports some means of selective multicast forwarding or
  1516. you have the ability to put it in yourself, you might find forwarding
  1517. multicast traffic in a way consistent with your security policy to be a
  1518. bigger headache than it's worth.
  1519.  
  1520. A Some Commercial Products and Vendors
  1521.  
  1522.   We feel this topic is too sensitive to address in a FAQ, however, an
  1523. independently maintained list (no warranty or recommendations are implied)
  1524. can be found online.  <URL:http://www.thegild.com/firewall/>
  1525.  
  1526. B Glossary of Firewall-Related Terms
  1527.  
  1528.  
  1529.  
  1530. Abuse of Privilege
  1531.      When a user performs an action that they should not have, according to
  1532.      organizational policy or law.
  1533.  
  1534. Access Control Lists
  1535.      Rules for packet filters (typically routers) that define which packets
  1536.      to pass and which to block.
  1537.  
  1538. Access Router
  1539.      A router that connects your network to the external Internet.
  1540.      Typically, this is your first line of defense against attackers from
  1541.      the outside Internet. By enabling access control lists on this router,
  1542.      you'll be able to provide a level of protection for all of the hosts
  1543.      ``behind'' that router, effectively making that network a DMZ instead
  1544.      of an unprotected external LAN.
  1545.  
  1546. Application-Layer Firewall
  1547.      A firewall system in which service is provided by processes that
  1548.      maintain complete TCP connection state and sequencing. Application
  1549.      layer firewalls often re-address traffic so that outgoing traffic
  1550.      appears to have originated from the firewall, rather than the internal
  1551.      host.
  1552.  
  1553. Authentication
  1554.      The process of determining the identity of a user that is attempting to
  1555.      access a system.
  1556.  
  1557. Authentication Token
  1558.      A portable device used for authenticating a user. Authentication tokens
  1559.      operate by challenge/response, time-based code sequences, or other
  1560.      techniques. This may include paper-based lists of one-time passwords.
  1561.  
  1562. Authorization
  1563.      The process of determining what types of activities are permitted.
  1564.      Usually, authorization is in the context of authentication: once you
  1565.      have authenticated a user, they may be authorized different types of
  1566.      access or activity.
  1567.  
  1568. Bastion Host
  1569.      A system that has been hardened to resist attack, and which is
  1570.      installed on a network in such a way that it is expected to potentially
  1571.      come under attack. Bastion hosts are often components of firewalls, or
  1572.      may be ``outside'' web servers or public access systems. Generally, a
  1573.      bastion host is running some form of general purpose operating system
  1574.      (e.g., Unix, VMS, NT, etc.) rather than a ROM-based or firmware
  1575.      operating system.
  1576.  
  1577. Challenge/Response
  1578.      An authentication technique whereby a server sends an unpredictable
  1579.      challenge to the user, who computes a response using some form of
  1580.      authentication token.
  1581.  
  1582. Chroot
  1583.      A technique under Unix whereby a process is permanently restricted to
  1584.      an isolated subset of the filesystem.
  1585.  
  1586. Cryptographic Checksum
  1587.      A one-way function applied to a file to produce a unique
  1588.      ``fingerprint'' of the file for later reference. Checksum systems are a
  1589.      primary means of detecting filesystem tampering on Unix.
  1590.  
  1591. Data Driven Attack
  1592.      A form of attack in which the attack is encoded in innocuous-seeming
  1593.      data which is executed by a user or other software to implement an
  1594.      attack. In the case of firewalls, a data driven attack is a concern
  1595.      since it may get through the firewall in data form and launch an attack
  1596.      against a system behind the firewall.
  1597.  
  1598. Defense in Depth
  1599.      The security approach whereby each system on the network is secured to
  1600.      the greatest possible degree. May be used in conjunction with
  1601.      firewalls.
  1602.  
  1603. DNS spoofing
  1604.      Assuming the DNS name of another system by either corrupting the name
  1605.      service cache of a victim system, or by compromising a domain name
  1606.      server for a valid domain.
  1607.  
  1608. Dual Homed Gateway
  1609.      A dual homed gateway is a system that has two or more network
  1610.      interfaces, each of which is connected to a different network. In
  1611.      firewall configurations, a dual homed gateway usually acts to block or
  1612.      filter some or all of the traffic trying to pass between the networks.
  1613.  
  1614. Encrypting Router
  1615.      see Tunneling Router and Virtual Network Perimeter.
  1616.  
  1617. Firewall
  1618.      A system or combination of systems that enforces a boundary between two
  1619.      or more networks.
  1620.  
  1621. Host-based Security
  1622.      The technique of securing an individual system from attack. Host based
  1623.      security is operating system and version dependent.
  1624.  
  1625. Insider Attack
  1626.      An attack originating from inside a protected network.
  1627.  
  1628. Intrusion Detection
  1629.      Detection of break-ins or break-in attempts either manually or via
  1630.      software expert systems that operate on logs or other information
  1631.      available on the network.
  1632.  
  1633. IP Spoofing
  1634.      An attack whereby a system attempts to illicitly impersonate another
  1635.      system by using its IP network address.
  1636.  
  1637. IP Splicing / Hijacking
  1638.      An attack whereby an active, established, session is intercepted and
  1639.      co-opted by the attacker. IP Splicing attacks may occur after an
  1640.      authentication has been made, permitting the attacker to assume the
  1641.      role of an already authorized user. Primary protections against IP
  1642.      Splicing rely on encryption at the session or network layer.
  1643.  
  1644. Least Privilege
  1645.      Designing operational aspects of a system to operate with a minimum
  1646.      amount of system privilege. This reduces the authorization level at
  1647.      which various actions are performed and decreases the chance that a
  1648.      process or user with high privileges may be caused to perform
  1649.      unauthorized activity resulting in a security breach.
  1650.  
  1651. Logging
  1652.      The process of storing information about events that occurred on the
  1653.      firewall or network.
  1654.  
  1655. Log Retention
  1656.      How long audit logs are retained and maintained.
  1657.  
  1658. Log Processing
  1659.      How audit logs are processed, searched for key events, or summarized.
  1660.  
  1661. Network-Layer Firewall
  1662.      A firewall in which traffic is examined at the network protocol packet
  1663.      layer.
  1664.  
  1665. Perimeter-based Security
  1666.      The technique of securing a network by controlling access to all entry
  1667.      and exit points of the network.
  1668.  
  1669. Policy
  1670.      Organization-level rules governing acceptable use of computing
  1671.      resources, security practices, and operational procedures.
  1672.  
  1673. Proxy
  1674.      A software agent that acts on behalf of a user. Typical proxies accept
  1675.      a connection from a user, make a decision as to whether or not the user
  1676.      or client IP address is permitted to use the proxy, perhaps does
  1677.      additional authentication, and then completes a connection on behalf of
  1678.      the user to a remote destination.
  1679.  
  1680. Screened Host
  1681.      A host on a network behind a screening router. The degree to which a
  1682.      screened host may be accessed depends on the screening rules in the
  1683.      router.
  1684.  
  1685. Screened Subnet
  1686.      A subnet behind a screening router. The degree to which the subnet may
  1687.      be accessed depends on the screening rules in the router.
  1688.  
  1689. Screening Router
  1690.      A router configured to permit or deny traffic based on a set of
  1691.      permission rules installed by the administrator.
  1692.  
  1693. Session Stealing
  1694.      See IP Splicing.
  1695.  
  1696. Trojan Horse
  1697.      A software entity that appears to do something normal but which, in
  1698.      fact, contains a trapdoor or attack program.
  1699.  
  1700. Tunneling Router
  1701.      A router or system capable of routing traffic by encrypting it and
  1702.      encapsulating it for transmission across an untrusted network, for
  1703.      eventual de-encapsulation and decryption.
  1704.  
  1705. Social Engineering
  1706.      An attack based on deceiving users or administrators at the target
  1707.      site. Social engineering attacks are typically carried out by
  1708.      telephoning users or operators and pretending to be an authorized user,
  1709.      to attempt to gain illicit access to systems.
  1710.  
  1711. Virtual Network Perimeter
  1712.      A network that appears to be a single protected network behind
  1713.      firewalls, which actually encompasses encrypted virtual links over
  1714.      untrusted networks.
  1715.  
  1716. Virus
  1717.      A replicating code segment that attaches itself to a program or data
  1718.      file. Viruses might or might not not contain attack programs or
  1719.      trapdoors. Unfortunately, many have taken to calling any malicious code
  1720.      a ``virus''. If you mean ``trojan horse'' or ``worm'', say ``trojan
  1721.      horse'' or ``worm''.
  1722.  
  1723. Worm
  1724.      A standalone program that, when run, copies itself from one host to
  1725.      another, and then runs itself on each newly infected host. The widely
  1726.      reported ``Internet Virus'' of 1988 was not a virus at all, but
  1727.      actually a worm.
  1728.  
  1729. C TCP and UDP Ports
  1730.  
  1731.  
  1732.                                                            by Mikael Olsson
  1733.  
  1734. This appendix will begin at a fairly ``basic'' level, so even if the first
  1735. points seem childishly self-evident to you, you might still learn something
  1736. from skipping ahead to something later in the text.
  1737.  
  1738. C.1 What is a port?
  1739.  
  1740.   A ``port'' is ``virtual slot'' in your TCP and UDP stack that is used to
  1741. map a connection between two hosts, and also between the TCP/UDP layer and
  1742. the actual applications running on the hosts.
  1743.  
  1744. They are numbered 0-65535, with the range 0-1023 being marked as
  1745. ``reserved'' or ``privlileged'', and the rest (1024-65535) as ``dynamic'' or
  1746. ``unprivileged''.
  1747.  
  1748. There are basically two uses for ports:
  1749.  
  1750.    * ``Listening'' on a port.
  1751.      This is used by server applications waiting for users to connect, to
  1752.      get to some ``well known service'', for instance HTTP (TCP port 80),
  1753.      Telnet (TCP port 21), DNS (UDP and sometimes TCP port 53).
  1754.    * Opening a ``dynamic'' port.
  1755.      Both sides of a TCP connection need to be identified by IP addresses
  1756.      and port numbers. Hence, when you want to ``connect'' to a server
  1757.      process, your end of the communications channel also needs a ``port''.
  1758.      This is done by choosing a port above 1024 on your machine that is not
  1759.      currently in use by another communications channel, and using it as the
  1760.      ``sender'' in the new connection.
  1761.  
  1762. Dynamic ports may also be used as ``listening'' ports in some applications,
  1763. most notably FTP.
  1764.  
  1765. Ports in the range 0-1023 are almost always server ports. Ports in the range
  1766. 1024-65535 are usually dynamic ports (i.e., opened dynamically when you
  1767. connect to a server port). However, any port may be used as a server port,
  1768. and any port may be used as an ``outgoing'' port.
  1769.  
  1770. So, to sum it up, here's what happens in a basic connection:
  1771.  
  1772.    * At some point in time, a server application on host 1.2.3.4 decides to
  1773.      ``listen'' at port 80 (HTTP) for new connections.
  1774.    * You (5.6.7.8) want to surf to 1.2.3.4, port 80, and your browser issues
  1775.      a connect call to it.
  1776.    * The connect call, realising that it doesn't yet have local port number,
  1777.      goes hunting for one. The local port number is necessary since when the
  1778.      replies come back some time in the future, your TCP/IP stack will have
  1779.      to know to what application to pass the reply. It does this by
  1780.      remembering what application uses which local port number. (This is
  1781.      grossly simplified, no flames from programmers, please.)
  1782.    * Your TCP stack finds an unused dynamic port, usually somewhere above
  1783.      1024. Let's assume that it finds 1029.
  1784.    * Your first packet is then sent, from your local IP, 5.6.7.8, port 1029,
  1785.      to 1.2.3.4, port 80.
  1786.    * The server responds with a packet from 1.2.3.4, port 80, to you,
  1787.      5.6.7.8, port 1029.
  1788.    * This procedure is actually longer than this, read on for a more
  1789.      in-depth explanation of TCP connect sequences.
  1790.  
  1791. C.2 How do I know which application uses what port?
  1792.  
  1793.   There are several lists outlining the ``reserved'' and ``well known''
  1794. ports, as well as ``commonly used'' ports, and the best one is:
  1795. ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers. For those of you
  1796. still reading RFC 1700 to find out what port number does what, STOP DOING
  1797. IT. It is horribly out of date, and it won't be less so tomorrow. Now, as
  1798. for trusting this information: These lists do not, in any way, constitute
  1799. any kind of holy bible on which ports do what.
  1800.  
  1801. Wait, let me rephrase that: THERE IS NO WAY OF RELIABLY DETERMINING WHAT
  1802. PORT DOES WHAT SIMPLY BY LOOKING IN A LIST.
  1803.  
  1804. C.3 What are LISTENING ports?
  1805.  
  1806.   Suppose you did ``netstat -a'' on your machine and ports 1025 and 1030
  1807. showed up as LISTENing. What do they do?
  1808.  
  1809. Right, let's take a look in the assigned port numbers list.
  1810.  
  1811.     blackjack       1025/tcp   network blackjack
  1812.     iad1            1030/tcp   BBN IAD
  1813.  
  1814. Wait, what's happening? Has my workstation stolen my VISA number and decided
  1815. to go play blackjack with some rogue server on the internet? And what's that
  1816. software that BBN has installed?
  1817.  
  1818. This is NOT where you start panicking and send mail to the firewalls list.
  1819. In fact, this question has been asked maybe a dozen times during the past
  1820. six months, and every time it's been answered. Not that THAT keeps people
  1821. from asking the same question again.
  1822.  
  1823. If you are asking this question, you are most likely using a windows box.
  1824. The ports you are seeing are (most likely) two listening ports that the RPC
  1825. subsystem opens when it starts up.
  1826.  
  1827. This is an example of where dynamicly assigned ports may be used by server
  1828. processes. Applications using RPC will later on connect to port 135 (the
  1829. netbios ``portmapper'') to query where to find some RPC service, and get an
  1830. answer back saying that that particular service may be contacted on port
  1831. 1025.
  1832.  
  1833. Now, how do we know this, since there's no ``list'' describing these ports?
  1834. Simple: There's no substitute for experience. And using the mailing list
  1835. search engines also helps a hell of a lot.
  1836.  
  1837. C.4 How do I determine what service the port is for?
  1838.  
  1839.  
  1840.  
  1841. Since it is impossible to learn what port does what by looking in a list,
  1842. how do i do it?
  1843.  
  1844. The old hands-on way of doing it is by shutting down nearly every
  1845. service/daemon running on your machine, doing netstat -a and taking note of
  1846. what ports are open. There shouldn't be very many listening ones. Then you
  1847. start turning all the services on, one by one, and take note of what new
  1848. ports show up in your netstat output.
  1849.  
  1850. Another way, that needs more guess work, is simply telnetting to the ports
  1851. and see what comes out. If nothing comes out, try typing some gibberish and
  1852. slamming Enter a few times, and see if something turns up. If you get binary
  1853. garble, or nothing at all, this obviously won't help you. :-)
  1854.  
  1855. However, this will only tell you what listening ports are used. It won't
  1856. tell you about dynamically opened ports that may be opened later on by these
  1857. applications.
  1858.  
  1859. There are a few applications that might help you track down the ports used.
  1860.  
  1861. On Unix systems, there's a nice utility called lsof that comes preinstalled
  1862. on many systems. It will show you all open port numbers and the names of the
  1863. applications that are using them. This means that it might show you a lot of
  1864. locally opened files aswell as TCP/IP sockets. Read the help text. :-)
  1865.  
  1866. On windows systems, nothing comes preinstalled to assist you in this task.
  1867. (What's new?) There's a utility called ``Inzider'' which installs itself
  1868. inside the windows sockets layer and dynamically remembers which process
  1869. opens which port. The drawback of this approach is that it can't tell you
  1870. what ports were opened before inzider started, but it's the best that you'll
  1871. get on windows (to my knowledge). http://ntsecurity.nu/toolbox/inzider/.
  1872.  
  1873. C.5 What ports are safe to pass through a firewall?
  1874.  
  1875.   ALL.
  1876.  
  1877. No, wait, NONE.
  1878.  
  1879. No, wait, uuhhh... I've heard that all ports above 1024 are safe since
  1880. they're only dynamic??
  1881.  
  1882. No. Really. You CANNOT tell what ports are safe simply by looking at its
  1883. number, simply because that is really all it is. A number. You can't mount
  1884. an attack through a 16-bit number.
  1885.  
  1886. The security of a ``port'' depends on what application you'll reach through
  1887. that port.
  1888.  
  1889. A common misconception is that ports 25 (SMTP) and 80 (HTTP) are safe to
  1890. pass through a firewall. *meep* WRONG. Just because everyone is doing it
  1891. doesn't mean that it is safe.
  1892.  
  1893. Again, the security of a port depends on what application you'll reach
  1894. through that port.
  1895.  
  1896. If you're running a well-written web server, that is designed from the
  1897. ground up to be secure, you can probably feel reasonably assured that it's
  1898. safe to let outside people access it through port 80. Otherwise, you CAN'T.
  1899.  
  1900. The problem here is not in the network layer. It's in how the application
  1901. processes the data that it receives. This data may be received through port
  1902. 80, port 666, a serial line, floppy or through singing telegram. If the
  1903. application is not safe, it does not matter how the data gets to it. The
  1904. application data is where the real danger lies.
  1905.  
  1906. If you are interested in the security of your application, go
  1907. subscribe to bugtraq <URL:http://www.securityfocus.com> or try
  1908. searching their archives.
  1909.  
  1910. This is more of an application security issue rather than a firewall
  1911. security issue. One could argue that a firewall should stop all possible
  1912. attacks, but with the number of new network protocols, NOT designed with
  1913. security in mind, and networked applications, neither designed with security
  1914. in mind, it becomes impossible for a firewall to protect against all
  1915. data-driven attacks.
  1916.  
  1917. C.6 The behavior of FTP
  1918.  
  1919.   Or, ``Why do I have to open all ports above 1024 to my FTP server?''
  1920.  
  1921. FTP doesn't really look a whole lot like other applications from a
  1922. networking perspective.
  1923.  
  1924. It keeps one listening port, port 21, which users connect to. All it does is
  1925. let people log on, and establish ANOTHER connection to do actual data
  1926. transfers. This second connection is usually on some port above 1024.
  1927.  
  1928. There are two modes, ``active'' (normal) and ``passive'' mode. This word
  1929. describes the server's behaviour.
  1930.  
  1931. In active mode, the client (5.6.7.8) connects to port 21 on the server
  1932. (1.2.3.4) and logs on. When file transfers are due, the client allocates a
  1933. dynamic port above 1024, informs the server about which port it opened, and
  1934. then the server opens a new connection to that port. This is the ``active''
  1935. role of the server: it actively establishes new connections to the client.
  1936.  
  1937. In passive mode, the connection to port 21 is the same. When file transfers
  1938. are due, the SERVER allocates a dynamic port above 1024, informs the client
  1939. about which port it opened, and then the CLIENT opens a new connection to
  1940. that port. This is the ``passive'' role of the server: it waits for the
  1941. client to establish the second (data) connection.
  1942.  
  1943. If your firewall doesn't inspect the application data of the FTP command
  1944. connection, it won't know that it needs to dynamically open new ports above
  1945. 1024.
  1946.  
  1947. On a side note: The traditional behaviour of FTP servers in active mode is
  1948. to establish the data session FROM port 20, and to the dynamic port on the
  1949. client. FTP servers are steering away from this behaviour somewhat due to
  1950. the need to run as ``root'' on unix systems in order to be able to allocate
  1951. ports below 1024. Running as ``root'' is not good for security, since if
  1952. there's a bug in the software, the attacker would be able to compromise the
  1953. entire machine. The same goes for running as ``Administrator'' or ``SYSTEM''
  1954. (``LocalSystem'') on NT machines, although the low port problem does not
  1955. apply on NT.
  1956.  
  1957. To sum it up, if your firewall understands FTP, it'll be able to handle the
  1958. data connections by itself, and you won't have to worry about ports above
  1959. 1024.
  1960.  
  1961. If it does NOT, there are four issues that you need to address:
  1962.  
  1963.    * Firewalling an FTP server in active mode
  1964.      You need to let your server open new connections to the outside world
  1965.      on ports 1024 and above
  1966.    * Firewalling an FTP server in passive mode
  1967.      You need to let the outside world connect to ports 1024 and above on
  1968.      your server. CAUTION!!!! There may be applications running on some of
  1969.      these ports that you do NOT want outside people using. Disallow access
  1970.      to these ports before allowing access to the 1024-65535 port range.
  1971.    * Firewalling FTP clients in active mode
  1972.      You need to let the outside world connect to ports 1024 and above on
  1973.      your clients. CAUTION!!!! There may be applications running on some of
  1974.      these ports that you do NOT want outside people using. Disallow access
  1975.      to these ports before allowing access to the 1024-65535 port range.
  1976.    * Firewalling FTP clients in passive mode
  1977.      You need to let your clients open new connections to the outside world
  1978.      on ports 1024 and above.
  1979.  
  1980. Again, if your firewall understands FTP, none of the four points above apply
  1981. to you. Let the firewall do the job for you.
  1982.  
  1983. C.7 What software uses what FTP mode?
  1984.  
  1985.   It is up to the client to decide what mode to use; the default mode when a
  1986. new connection is opened is ``active mode''.
  1987.  
  1988. Most FTP clients come preconfigured to use active mode, but provide an
  1989. option to use ``passive'' (``PASV'') mode. An exception is the windows
  1990. command line FTP client which only operates in active mode.
  1991.  
  1992. Web Browsers generally use passive mode when connecting via FTP, with a
  1993. weird exception: MSIE 5 will use active FTP when FTP:ing in ``File
  1994. Explorer'' mode and passive FTP when FTP:ing in ``Web Page'' mode. There is
  1995. no reason whatsoever for this behaviour; my guess is that someone in Redmond
  1996. with no knowledge of FTP decided that ``Of course we'll use active mode when
  1997. we're in file explorer mode, since that looks more active than a web page''.
  1998. Go figure.
  1999.  
  2000. C.8 Is my firewall trying to connect outside?
  2001.  
  2002.   My firewall logs are telling me that my web server is trying to connect
  2003. from port 80 to ports above 1024 on the outside. What is this?!
  2004.  
  2005. If you are seeing dropped packets from port 80 on your web server (or from
  2006. port 25 on your mail server) to high ports on the outside, they usually DO
  2007. NOT mean that your web server is trying to connect somewhere.
  2008.  
  2009. They are the result of the firewall timing out a connection, and seeing the
  2010. server retransmitting old responses (or trying to close the connection) to
  2011. the client.
  2012.  
  2013. TCP connections always involve packets traveling in BOTH directions in the
  2014. connection.
  2015.  
  2016. If you are able to see the TCP flags in the dropped packets, you'll see that
  2017. the ACK flag is set but not the SYN flag, meaning that this is actually not
  2018. a new connection forming, but rather a response of a previously formed
  2019. connection.
  2020.  
  2021. Read point 8 below for an in-depth explanation of what happens when TCP
  2022. connections are formed (and closed)
  2023.  
  2024. C.9 The anatomy of a TCP connection
  2025.  
  2026.   TCP is equipped with 6 ``flags'', which may be ON or OFF. These flags are:
  2027.  
  2028. FIN
  2029.      ``Controlled'' connection close
  2030. SYN
  2031.      Open new connection
  2032. RST
  2033.      ``Immediate'' connection close
  2034. PSH
  2035.      Instruct receiver host to push the data up to the application rather
  2036.      than just queue it
  2037. ACK
  2038.      ``Acknowledge'' a previous packet
  2039. URG
  2040.      ``Urgent'' data which needs to be processed immediately
  2041.  
  2042. In this example, your client is 5.6.7.8, and the port assigned to you
  2043. dynamically is 1049. The server is 1.2.3.4, port 80.
  2044.  
  2045. You begin the connection attempt:
  2046.  
  2047. 5.6.7.8:1049 -> 1.2.3.4:80 SYN=ON
  2048.  
  2049. The server receives this packet and understands that someone wants to form a
  2050. new connection. A response is sent:
  2051.  
  2052. 1.2.3.4:80 -> 5.6.7.8:1049 SYN=ON ACK=ON
  2053.  
  2054. The client receives the response, and informs that the response is received
  2055.  
  2056. 5.6.7.8:1049 -> 1.2.3.4:80 ACK=ON
  2057.  
  2058. Here, the connection is opened. This is called a three-way handshake. Its
  2059. purpose is to verify to BOTH hosts that they have a working connection
  2060. between them.
  2061.  
  2062. The internet being what it is, unreliable and flooded, there are provisions
  2063. to compensate for packet loss.
  2064.  
  2065. If the client sends out the initial SYN without receiving a SYN+ACK within a
  2066. few seconds, it'll resend the SYN.
  2067.  
  2068. If the server sends out the SYN+ACK without receiving an ACK in a few
  2069. seconds, it'll resend the SYN+ACK packet.
  2070.  
  2071. The latter is actually the reason that SYN flooding works so well. If you
  2072. send out SYN packets from lots of different ports, this will tie up a lot of
  2073. resources on the server. If you also refuse to respond to the returned
  2074. SYN+ACK packets, the server will KEEP these connections for a long time,
  2075. resending the SYN+ACK packets. Some servers will not accept new connections
  2076. while there are enough connections currently forming; this is why SYN
  2077. flooding works.
  2078.  
  2079. All packets transmitted in either direction after the three-way handshake
  2080. will have the ACK bit set. Stateless packet filters make use of this in the
  2081. so called ``established'' filters: They will only let packets through that
  2082. have the ACK bit set. This way, no packet may pass through in a certain
  2083. direction that could form a new connection. Typically, you don't allow
  2084. outside hosts to open new connections to inside hosts by requiring the ACK
  2085. bit set on these packets.
  2086.  
  2087. When the time has come to close the connection, there are two ways of doing
  2088. it: Using the FIN flag, or using the RST flag. Using FIN flags, both
  2089. implementations are required to send out FIN flags to indicate that they
  2090. want to close the connection, and then send out acknowledgements to these
  2091. FINs, indicating that they understood that the other end wants to close the
  2092. connection. When sending out RST's, the connection is closed forcefully, and
  2093. you don't really get an indication of whether the other end understood your
  2094. reset order, or that it has in fact received all data that you sent to it.
  2095.  
  2096. The FIN way of closing the connection also exposes you to a
  2097. denial-of-service situation, since the TCP stack needs to remember the
  2098. closed connection for a fairly long time, in case the other end hasn't
  2099. received one of the FIN packets.
  2100.  
  2101. If sufficiently many connections are opened and closed, you may end up
  2102. having ``closed'' connections in all your connection slots. This way, you
  2103. wouldn't be able to dynamically allocate more connections, seeing that
  2104. they're all used. Different OSes handle this situation differently.
  2105.  
  2106. References
  2107.  
  2108. 1    Steven M. Bellovin.
  2109.      Firewall-friendly FTP.
  2110.      RFC 1579.
  2111.  
  2112. 2    R. Finlayson.
  2113.      Ip multicast and firewalls.
  2114.      RFC 2588, May 1999.
  2115.  
  2116. 3    Y. Rekhter, B. Moskowitz, D. Karrenberg, G. J. de Groot, and E. Lear.
  2117.      Address allocation for private internets.
  2118.      RFC 1918, February 1996.
  2119.  
  2120. 4    R. Thayer, N. Doraswamy, and R. Glenn.
  2121.      IP Security Document Roadmap.
  2122.      RFC 2411, November 1998.
  2123.  
  2124.