It's Not Paranoia, They Are Out To Get You!
A Firewall "Why-To"

by
Shannon Dealy, DeaTech Research Inc.
dealy@deatech.com -- www.deatech.com

Just what we need, another firewall tutorial

 

Browsing the net, looking for information on securing your Linux system or network, it seems like there are more than enough choices without adding one more.  Unfortunately, I have found that most of them will tell you what to do and how to do it without telling you why to do it, so rather than a "how-to", this is more of a "why-to", why you are doing it.  The problem with the "how-to" approach is that if you don't understand what you are doing and why, you are more likely to make a mistake that could leave your systems vulnerable, and you will find it more difficult to adapt a particular firewall scheme to your particular specialized needs.  Many firewall tutorials also emphasize just one aspect of protecting your system and leave out any information on what the real or potential deficiencies of their approach is.  Over time as this document evolves, hopefully it will become a useful source for this missing part of the firewall puzzle, and a pointer to the relevant "how-to" information.

Total Firewall Security

Installing a firewall computer does not make your network secure, it just makes it less insecure.  This may seem like a silly distinction, but it is important to recognize that the only 100% foolproof way to protect your data from theft is to completely destroy all copies of it before it is stolen!  All other approaches are compromises where we try to balance the value of our being able to access the data against the probability and dangers of it being stolen (you did want to access it didn't you?).  Even if you eliminate all outside connections to your computer, someone may break-in and steal the computer itself.

So what makes me an expert?

I'm not, and don't claim to be, unfortunately, neither are many, if not most, of those who do make this claim.  I do however have a great deal of relevant knowledge and experience that gives me a good understanding of the mechanisms behind security breaches, and have been managing the security of a full-time internet connection for about seven years, during which time I have seen pretty much every type of attack described in the firewalling literature.  My specialty (if it could truly be said that I have one anymore) is actually real-time embedded systems and device drivers, though I have worked on virtually every aspect of computers from hardware design to artificial intelligence. 

Frankly, I would love to be able to just buy a firewall and forget it, but so far every one I've looked at either doesn't have the flexibility I need for configuring my internet connections, or has been breached in the six months prior to when I looked it over, usually both.  I don't bother to look at anything that hasn't been on the market for at least nine months, since it takes time for the hackers and crackers of the world to look these things over and demonstrate how insecure they really are.  It could be argued that since pretty much any firewall system is vulnerable, it would be better to leave it in the hands of the experts rather than doing it yourself, but how do you determine which firewall vendor is truly "expert"?  Many breaches of commercial firewall products that I've looked over, were not due to some new form of attack and did not use any novel holes in the system, rather the vendor simply forgot (or worse, wasn't aware of) a well documented existing security hole.  Some of the other cases were down right stupid in that the vendor's wonderful point and click user interface or some other aspect of their non-security related custom software was the source of the security hole.  Other breaches, while not technically the vendor's fault, were due to the fact that the user was allowed to configure the product in a manner which was inherently insecure, which means that anyone using the product must completely understand firewalls in order to use it properly, in which case they might as well roll their own!

Why bother?

Until very recently, if you just used an occasional dial-up connection to the internet, it was not unreasonable to just take a few minor precautions and not worry about security, though of course for those of us with full time connections at least a primitive firewall was generally considered to be a minimum requirement.  Most people could get away with this by virtue of the fact that there were very few people on the net (relatively speaking) who had both the knowledge and the inclination to break into other peoples computers, and when they did go after someone, it was usually a large and/or high profile company, so for the rest of us, we were safe by virtue of being small and not worth their time.  Today this has all changed, the few who have the skills now put their knowledge into automated programs and shell scripts which can be used to scan for security holes and attack many computers simultaneously.  What's worse, once a system is breached they can put that computer to work scanning for openings and attacking more computers.  The situation was bad enough at this point, but they went one step further and started using the internet to distribute the attack programs they had created, so that anyone who wanted to could attack other computers.  This created the "script kiddie" phenomenon which is basically thousands of bored children (or childish adults) who lack the expertise to be any kind of a threat, using software downloaded from the internet to implement broad scale attacks against anyone and everyone on the net.  Because of this new approach, no one connected to the net is safe at any time, since the entire internet is continuously being scanned for insecure systems from many different sources.  It is probably a rare computer IP address which does not get probed for security holes at least once a week, I usually see probes one or more times each day if I bother to check the log files for it.

Internet Communication Protocols

There are many communication protocols used for passing information over the internet, some are for local communication such as ethernet and various modem protocols, used to relay information between directly connected computers.  Layered on top of these low level communication protocols are higher level ones which are used to relay information across the many different interconnected computers and devices which make up the internet.  The most important protocols are:

IP - Internet Protocol
This is the core protocol used for transporting virtually all information across the internet, most other protocols (including the ones which follow) use this as their underlying communication layer.
ICMP - Internet Control Message Protocol
This protocol is used for passing connection and control information across the net.  It's what is used when you ping another computer or use traceroute to see where problems are occurring on the net.
UDP - User Datagram Protocol
Provides unreliable unidirectional packet transmission.  Basically, a data packet is sent but whether or not it is received is not reported and no retransmission is attempted by this protocol.  This may seem silly, but on a reliable network where the overwhelming majority of packets get through, this can greatly increase throughput because of the lower overhead required in sending a packet this way.  Even though UDP is not as popular as TCP (see below), common services on many computers are available using either TCP or UDP.
TCP - Transmission Control Protocol
Provides a reliable bidirectional connection between two computers, will deliver the packet, or let you know it failed.  This is the primary work horse of high level internet information transfer, though it is much less efficient than UDP.

While these higher level protocols are the primary means by which useful information is passed across the internet (such as email and web pages), there are many other protocols available as well, but since they are usually rather specialized and rarely used (relatively speaking), there is little point in dealing with them further at this point. 

A Few Useful Terms

Filtering

A technique where network data packets are either stopped at or allowed to pass through a network connection based on the contents of the packet.  Typical criteria used for filtering include:

Filtering techniques could also include analysis of the rest of the packet's contents, multiple related packets, or any combination of the above.

NAT (Network Address Translation)

A technique where a network connection to a port is re-routed to another network port, possibly on a different computer system.  This effectively hides from the connecting computer, the actual destination it is connecting to.  This technique can be used to allow several computers to share a single IP address on the internet, so long as they do not require the use of the same port on that IP address.

Proxy Server

A program (possibly running on a separate proxy server computer) which accepts information transfer requests on behalf of one or more other computers, and sends appropriate responses to those requests.  A typical use of the proxy server is a caching proxy for web browsers which is used by Internet Service Providers (ISP).  This type of proxy server accepts requests for web pages, gets a copy from the target computer, makes a temporary copy for itself, and then sends the information back to the web browser that made the original request.  The next time anyone makes a request for this web page, it can use the temporary copy it made earlier in order to save time and reduce the load on it's internet connection.  This same proxy server could also be used to block access to undesirable sites, or remove undesirable information contained on a web page, such as an obnoxious javascript program, or a reference to an advertising site, or even a competitors web site.  Many other types of proxy servers and services are also possible.

Types of attack

Before deciding what to do, it is important to understand what types of attacks may occur and how they will affect you and your computer system. The following list (which is by no means complete) gives the general classes of attack along with some common or well-known examples and specific solutions to these problems:

External Attacks
Attacks originating from outside your home or office computer/network.
Denial of Service (DOS)
the purpose of this type of attack is not to gain control over your computer, rather it is to prevent anyone from making use of one or more of the services that the attacked computer provides.  Some examples include:
  • SYN Attack -- A "SYN" packet is used to initiate a connection between computers using the TCP protocol, it is part of a three way handshake used by TCP to set up a connection.  In this attack, repeated "SYN" packets are sent to the computer under attack, the attacked computer sends it's response handshake packet, and waits for the final handshake packet from the attacking computer (which never sends it).  Each of these incomplete connection attempts ties up one network port on the computer until it times out, if enough are sent before the timeout occurs, the system runs out of ports and/or other resources at which point no one else can connect.

    Linux Solution: there is a kernel feature called "syn-cookies," which while it won't stop the attack will quite effectively prevent it from causing any real problems.  This feature must be configured in your Linux kernel to make use of it, and (for some strange reason) this function must be specifically enabled each time the system is rebooted (it is off by default).  This is a no brainer, if your computer is connected to the internet, you want this feature.  I did initially have a problem with syn-cookies being ineffective until I increased the number of local network ports available to the system by changing the settings in:

    /proc/sys/net/ipv4/ip_local_port_range

    the default is rather small (only about four thousand ports), and apparently didn't allow enough margin for timeouts, etc.. I now run with it configured for about 31000 ports.

  • Process Table Overflow -- Most computers have some kind of limit on the total number of processes that can be active at one time, in many cases if this limit is ever reached, the system will crash or at least become virtually unusable.  One way to do this is to simply establish as many connections as possible to as many different system services as possible.  Many standard services will create a new process for each connection, quickly using up all space in the process table.

    Linux Solution: the best solution to this problem is to configure each service on your computer to limit the number of processes it can spawn so that the maximum total number of processes that will be used by these services is less than the maximum size of the process table.  As a supplemental form of protection it is a good idea to install a program called watchdog which monitors your system for a variety of problems that could stop it from responding -- including a full process table, or running out of memory.  Whenever a condition occurs which could or does lock up your computer, watchdog forces a reboot of the system.  Highly recommended for any computer that needs to be up 24x7, and not a bad idea for other systems as well.  It does require your kernel be modified to support the /dev/watchdog device.

  • Network/Server Overload -- No matter how fast your connection to the internet is, someone else has a faster one, and if they make requests faster than your server or internet connection can handle them, your site will become virtually unusable to everyone else.  Even if the person attacking you doesn't have a faster link, they can use other computers that they have compromised to launch multiple attacks which, when combined, exceed the capabilities of your server.

    Linux Solution: there is no complete solution for this problem, Linux or otherwise.  You can use iptables or ipchains to block all connections from computers involved in the attack, but for a truly wide spread attack launched from hundreds or thousands of systems this may not be practical, since it is necessary to determine which are legitimate connection attempts, and which are part of the attack.  In any case, this requires active monitoring of the system and manual intervention, which is usually not practical except for large server systems and e-commerce sites. Ultimately, the only long term solution is to analyze your log files to determine the source of the attack(s), use the "whois" command to find contact information for the ISP that manages the IP addresses the attacks are coming from and report the problem to them.

  • Ping of Death -- This one should be fixed in any computer operating system which has been updated in the last couple of years, but it is a classic example of how easy it can be to knock a system off-line.  In this attack, a person simply sent a 64k+ byte "ping" packet to the target system.  This would overflow the receive buffer and crash the network link if not the entire computer.

On the bright side, for these kinds of attack your data is not in any danger of being stolen or corrupted, and in some cases the simplest course if you are not running an E-commerce or other high availability site, may be to just ignore the problem until you get enough attacks to be irritating.  I ignored a system bug for a couple years which aided in a process table overflow attack.  The system was already running the watchdog program mentioned above, and since this type of attack on the computer was relatively rare and the down-time was always less than two minutes, it was only a minor irritation that would hardly have been worth the time to perform a kernel upgrade to "cure" the problem.
Break-in
the reasons for this type of attack are virtually unlimited, it can be anything from just proving they can break into your system, to revenge.
  • Standard accounts and password scans -- This type of attack simply attempts to log-in using any available login service (telnet, ssh, rsh, etc.) by using common account names (root, games, mail, etc.) or the names of users discovered by looking at internet discussion groups, company web sites and other sources.  Armed with a potential list of account names, the attacker will use a list of common passwords or simply words from the dictionary in an automated attempt to log-in to the system.  A more serious attacker dedicated to breaking into your computer specifically, will research people with accounts on the system and apply birth dates, names of children and other personal information in order to find a working account and password.  This type of attack is also a common internal attack, but is even more likely to succeed since personal information is even more readily available to those on the inside.

    What to do about it -- Because these approaches will often succeed in any concerted attack, it is best to disable any login access from the internet.  If you must allow it, require strong computer generated passwords on any account with access from the outside, allow access only through an encrypted connections such as provided by a secure sockets version of telnet (telnet-ssl) or secure shell log in such as openssh, and preferably if possible, only allow login from specific known external computer systems.  For internal attacks, these same approaches can be applied to internal computer systems as well.

  • Known bugs, common bugs and security holes -- In this type of attack, the attacker looks for bugs or system security holes in your computer which can be used to gain access.  Once they have one of these bugs or holes, it is used to break into the computer.

    Solution -- regardless of operating system, there is only one viable solution to this problem, keep the computer's operating system up-to-date with the latest security patches, and subscribe to a security notification list for your particular operating system.  I believe most Linux distributions do maintain a security email list for this purpose.  It is important to note here that the fewer programs and services you have installed on a computer, the better your chances that any given bug or security hole won't apply to your system and can be safely ignored.

  • Computer viruses -- Many people today only think of computer viruses and worms as an irritation which may delete files on their hard disk or display silly messages, unfortunately, many of them are very discrete and instead gather information to send out to their originator so that they can better attack your network, or even just install a program to give their originator direct access to your network.

    What to do -- an obvious first step is to install anti-virus programs on all computer systems, but since new viruses occur on a regular basis and may not be caught by your "up-to-date" anti-virus program, it is important to block the unintended entry of any executable program into your network, particularly those which can be "accidentally" run by someone using an email program.  In order to do this, the email server should have filters to catch all the common executable attachment file types, and all web browsers should go through a proxy server with similar filtering installed.

Launch platform

These attacks and/or abuses of the internet are intended to simply gain enough access to allow your computer to be used to hide the real identity of a person engaged in some obnoxious activity.  While this is a common approach for attacking computer systems, it is even more commonly used for sending spam.  Because of the limited use they want to make of your computer, this may not even disrupt normal operations for you (other than using up some of your connection bandwidth).  Of course, since they are using your computers against someone else on the internet, the person or company on the receiving end may come after you, since you are the "source" of the problem.  Often, this approach does not even require that your system be breached, they may simply make use of services which you provide for them without realizing it.

  • Forged return address -- one way to implement a DOS attack is to flood a system with garbage sent by other computers, to do this an attacker can simply send a stream of requests to other computer systems using a forged return address so that the responses (which could be much larger than the requests) will be sent to the computer under attack.  This kind of attack can't work using TCP connections because of the three way handshake required to setup a connection, so to reduce the risk, or prevent your system from being used for this purpose, you only need to shutdown any unnecessary ICMP and UDP related services.  Technically, some other services might be able to be used for this as well, but since only TCP, ICMP and UDP are used by most systems, if your system is running any other protocols, then presumably you need them for some reason.

  • SMTP relay -- probably one of the single most annoying problems for everyone on the internet.  A spammer, after finding out that your mail server allows relaying, will route all of their spam messages through your email server out to the rest of the internet.  If your computer is configured to provide email services, you must make sure that the mail server program you are running has been configured to prevent relaying out to the internet, any messages which come in from the internet.  Be careful when doing this, the most common mistake made by ISP's tightening up the security of their mail systems is to block the relaying of messages to other mail servers within their domain, or to other domains for which they are supposed to be providing the mail services.

Internal Attacks

if you have a large network shared by many people, an internal attack should be a major concern, since most networks are least protected against this.  Small or single user networks generally do not give this any consideration at all, but it could be a big mistake to do so.  Once your firewall is breached by an outside attack, the next stage of the attack is in fact an internal attack!  There are far too many different kinds of internal attacks to list them all here, but some of the more common general approaches include:

Philosophy 101

The basic philosophy of any good network firewall/security system will be "security by design" which is simply a restatement of the obvious approach, a carefully crafted design intended to insure the security of the system.  While security by design is unquestionably the best approach, it does not gaurantee success.  There are at least two other approaches which can be used to supplement the design of your security system.  Generally, these are only used by the truly paranoid because they are usually too much work for the limited value they provide:

Design of the system

When designing your firewall system, in order to determine the approach that is best suited to your needs, you need to decide several things:

A typical approach to securing networks generally goes something like this:

Remove, disable, and/or block access to everything on the network, then install/enable only those items which you need, but only to the most minimal level necessary to perform the required function. 

Because it is usually rather inconvenient to maintain this level of security on computers used for day-to-day operations, usually networks are split into a high security external network which provides services to the internet (sometimes referred to as the DMZ) and an internal network with relatively weak security that accesses the internet using connections which go through the more tightly secured external network.  Implementing this philosophy usually goes something like this:

An Improved Approach

As with all things there are trade-offs, and for the small office, the totally paranoid approach mentioned earlier where each service is placed on a separate computer is simply not practical.  Fortunately, there is a new option available, using VMWare's virtual machine technology I have taken a new approach, using a single hardware computer system, it's now possible to set up a series of virtual computers, one to handle each service, with a number of additional advantages over other approaches:

     Using VMWare with multiple virtual machines
      (each node is a separate virtual machine)

         Internet Internet Internet
           ||       ||       ||
     +-----||-------||-------||----------------+
     |     ||       ||       ||                |
     |   external external external . . .      |
     |   link VM  link VM  link VM             |
     |       \       |        |     /          |
     |        ----------------------           |
     |                 |                       |
     |                 |        /- Logging     |
     | Firewall    filter/NAT   |              |  +--------------------+
     | Network       router   --|- Proxy       |  |                    |
     |                 |        |              |  |                    |
     |                 |        \- Bridge ========== Internal Network  |
     |                 |                       |  |                    |
     |  -  -  -  -  -  |  -  -  -  -  -  -  -  |  |                    |
     |                 |                       |  +--------------------+
     | External        |                       |
     | Servers         |                       |
     |                 |                       |
     |         --------------------            |
     |        /   |   |   |   |    \           |
     |       web ftp vpn DNS SMTP  . . .       |
     |                                         |
     +-----------------------------------------+

Resources

Now that you (hopefully) have a better understanding of why things are done, you can move on to the specifics of how they are done.  This section lists some resources that will give you the "how-to" information for configuring your firewall system.

Important documents:

Important programs:

Programs to Test the Security of Your Firewall

Google
 
Web www.deatech.com

Revision 01.00

Presentation given to the Mid-Willamette Valley Linux User Group, May 5th, 2001

This was supposed to be the outline/overview of the talk, I got a little carried away :-) it will undoubtedly be expanded at a later date to fill in some areas I short changed on this revision.

If you should find an error in this document, please let me know (relevant references, online or otherwise much appreciated), the only thing I hate worse than being wrong (and the embarassment that goes with it), is the dissemination of incorrect information to others.

Thank you,

Shannon Dealy
dealy@deatech.com