






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Suppose you are given a machine, and asked to harden it against external attack. How do you do it?
One starting point is to look at the network services that this machine is providing to the outside world. If any of its network services are buggy or have security holes, a hacker may be able to penetrate your machine by interacting with that application. As we know, bugs are inevitable, and bugs in security-critical applications often lead to security holes. Thus, the more network services your machine runs, the greater the risk.
This suggests one simple way to reduce the risk of external attack. Turn off every unnecessary network service. Disable every network-accessible application that isn’t absolutely needed. Build a stripped-down box that is running the least amount of code necessary; after all, any code that you don’t run, can’t harm you. And for any network service that you do have to run, double-check that is has been implemented and configured securely, and take every precaution you can to render its use safe. This is an intuitive and effective approach, and it can work well when you only have one or two machines to secure, but now let’s consider what happens when we scale things up.
Suppose you are in charge of security for all of Macrosloth Corp. Your job is to protect the computer systems, networks, and computing infrastructure of the entire company from external attack. How are you going to do it?
If the company has thousands of computers, it won’t be easy to harden every single machine individually. There may be many different operating systems and hardware platforms. Different users may have vastly different users, and a service that can be disabled for one user might be necessary to another user’s job. Moreover, new machines are bought all the time, machines come and go every day, and users upgrade their machines. At this scale, it is often hard even to get an accurate list of all machines inside the company—and if you miss even one machine, it is then a vulnerable point that can be broken into and might serve as a jumping-off point for attackers to use to attack the rest of your network. The sheer complexity of managing all of this might make it infeasible to harden each machine individually.
Nonetheless, it’s still true that one risk factor is the number of network services that are accessible to out- siders. This suggests a defense. If we could block, in the network , outsiders from being able to interact with many of the network services running on internal machines, we could reduce the risk. This is exactly the concept behind firewalls : the firewall is a device designed to block access to network services running on internal machines.
At this point, it’s clear that there are two questions we’ll have to settle:
Internet (^) Internal Network
Figure 1: An example network topology, with a single link connecting the internal and external networks.
We’ll tackle these each on their own.
A little bit of background. In its simplest form, we can visualize the topology of the internal network as shown in Figure 1. We have an internal network, which hosts all the company’s machines, and the external world (e.g., the rest of the Internet), and a communications link between the two.
How do we decide what is inside, and what is outside? We might decide that we trust all company employ- ees, but we don’t trust anyone else (a very simple threat model). Then we’ll define the internal network to contain machines owned by trusted employees, and the external world to include everything else. The link to our ISP might be the link between these two worlds.
The very simplest security policy is an outbound-only policy. Let’s distinguish between inbound and out- bound connections. Inbound connections are initiated by external users and attempt to connect to services running on internal machines, while outbound connections are attempts by internal users to initiate contact with external services. An outbound-only policy would permit all outbound connections (reasoning: inter- nal users are trusted; if they want to open a connection, we’ll let them), but all inbound connections would be strictly denied. The effect is that none of our network services are visible to the outside world, though of course they can still be accessed by internal users. Unfortunately, this policy is probably too restrictive for any large organization, since it means that the company cannot run a webserver, a mail server, a FTP server, and so on. Therefore, we will need a little more flexibility in how we define the security policy.
In general, the security policy is going to be a particular kind of access control policy. We will have two subjects: an anonymous external user, and a generic inside user^1. The objects are the set of network services that are run on all inside machines; if there are 1000 machines, and each machine runs 5 network services, we end up with 5000 objects. The access control policy should then specify, for each subject and each object, whether that subject has permission to access that object.
Firewalls are usually used to enforce a particularly simple kind of access control policy. Inside users are permitted to connect to any network service desired. External users are restricted: there are some services that are intended to be externally visible, and external users are permitted to connect to these services, but there are also other services that are not intended to be accessible from the outside world, and those services are blocked by the access policy.
The first thing the security administrator needs to do is identify a security policy, or in other words, which services external users should and shouldn’t be given access to. How should we do it? Broadly speaking, there are two philosophies we might use to determine which services we allow external users to connect to:
Internet (^) Internal Network Firewall
Figure 2: A network topology with a firewall restricting inbound access.
Therefore, each network service can be identified with a triplet ( m , r , p ), where m is the IP address of a machine, r is a protocol identifier (e.g., TCP or UDP), and p is the port number. For instance, the company might have its official web server hosted on machine 1.2.3.4, and then (1.2.3.4, TCP, 80 ) would be added to the allowed list. In a default-deny policy, the list of network services that should be externally visible would be represented as a set of these triplets.
The key trick behind enforcing such a security policy is to do it at a chokepoint in the network. In Figure 1, there is only a single link connecting the inside and outside networks. Therefore, we will replace that link with a firewall that filters network connections and blocks any connections that are denied by the security policy. See Figure 2 for the result.
The existence of a central chokepoint gives us a single place to stand, where we can easily enforce a security policy on thousands of machines with minimal effort. The idea is a familiar one from physical security. For instance, at the airport, all passengers are funneled through a security checkpoint where access can be controlled. It’s a lot easier to perform such checks at one or a few checkpoints than at dozens or hundreds of entrances.
The simplest kind of firewall is a packet filter. A packet filter is a router that is augmented with an access control list, usually specified as a list of rules. When any packet is received by the router, the security rules are consulted to decide whether the packet should be forwarded or should be dropped. A rule can specify which packets it will apply to, based on the header fields of the packets. For instance, the rule might specify source and destination IP addresses and port numbers and protocol names, or wild cards for each of these. Each rule also specifies what action will be taken for matching packets; typical values might be ALLOW or DROP. As each packet is processed, the list of rules is examined one-by-one, and the first matching rule determines how the packet will be handled.
Let’s try an example. What does this ruleset do?
drop tcp : -> *: allow * : -> :
Answer: it blocks all TCP packets destined to port 23^3 and forwards all other traffic undisturbed. Notation: 1.2.3.4:25 indicates IP address 1.2.3.4 and port 25 ; * is a wildcard, which may appear anywhere.
One problem with this policy is that it has no notion of a connection, or of inbound vs outbound connections. It will drop outbound telnet connections initiated by inside users, which might be undesirable. Another problem is that this is a default-allow policy: it allows everything except one explicitly listed service. As we’ve argued before, that’s bad form.
(^3) Port 23 happens to be the telnet port; telnet is a major security hole, because it transmits passwords in cleartext.
So let’s suppose that we’ve carefully built a security policy and decided that we want to allow inbound connections to port 25 of our mail server (1.2.3.4), and allow all outbound connections, and that’s it. Let’s suppose we’ve predefined a macro {ourhosts} as some hard-coded list of all internal hosts. How does this ruleset look?
allow tcp : -> 1.2.3.4: allow tcp {ourhosts}:* -> : drop * : -> :
Answer: This policy doesn’t do what we want, because of the way that TCP connections work. Recall that a TCP connection is bidirectional, and involves packets going in both directions. Indeed, when a TCP connection is initiated, the initiator sends a SYN packet (i.e., the SYN bit in the TCP header is set), the responder responds with a SYN|ACK packet (i.e., both the SYN and ACK bits are set in the TCP header), and the initiator sends an ACK packet; finally, both are able to send data in either direction, and these data packets have their ACK bit set.
The problem is now evident: outbound connections aren’t actually going to work. If some inside host tries to open a TCP connection to port 80 on an external machine (say), then the initial SYN packet is going to get through, because it is allowed by rule 2. However, the SYN|ACK packet coming back does not match rule 1 (because it isn’t destined to port 25) and does not match rule 2 (because the source IP address is that of the external web server, not an inside host), so it will be dropped, and the connection attempt will time out and fail. Evidently, inbound packets associated with an outbound connection should be allowed, but inbound packets associated with an inbound connection need to be restricted. We need some way to distinguish the two kinds of inbound packets.
The trick is to use a feature of TCP: the very first packet does not have its ACK bit set, but all other packets do. Moreover, the recipient will discard any TCP packet with its ACK bit set, if the packet is not associated to an existing TCP connection. Therefore, the solution is to use a ruleset like this:
allow tcp : -> 1.2.3.4: allow tcp {ourhosts}:* -> : allow tcp : -> {ourhosts}:* (if ACK bit set) drop * : -> :
Rules 1 and 2 allow inbound connections to port 25 on machine 1.2.3.4; rules 2 and 3 allow outbound connections to any port.
Why does this work? Suppose that the attacker discovers a vulnerability in our finger service (TCP port 79), and tries to open an inbound TCP connection to a finger server on some internal machine. He will have to send a SYN packet to the internal machine, but because this packet does not have its ACK bit set, it will not be allowed by the policy and will be dropped before it is ever seen by the internal finger server program. If he tries to send a packet with its ACK bit set (say, a SYN|ACK packet) to port 79 on the internal machine, this will be permitted by the firewall, but all TCP stacks currently drop any packet that has its ACK bit set but is not part of an existing connection, so such packets will also be harmless. In this way, we can specify policies restricting inbound connections arbitrarily.
However, there is a subtle security hole lurking in this ruleset. The problem is related to IP spoofing. Recall that there is nothing in the IP protocol that prevents an attacker from sending a packet with an incorrect ( spoofed ) source address; indeed, most routers don’t ever look at the source address, so such a packet will be correctly routed to the destination. Suppose that 1.2.3.7 is one of our internal hosts. Imagine if an attacker sends a spoofed TCP SYN packet, with its source address set to 1.2.3.7, the destination address
Figure 3: A reference monitor controls access by subjects to objects.
optimized for this special task. The notion of a chokepoint is crucial, because it is what makes it possible to enforce the access control policy, and we see the same thing come up elsewhere in access control.
In general, the mechanism that enforces an access control policy often takes the form of a reference monitor. The purpose of a reference monitor is to examine every request to access any controlled resource (an object) and determine whether that request should be allowed. See Figure 3. There are three security properties that any reference monitor should have:
We can recognize a firewall as merely an instance of a reference monitor. How are these three properties achieved?
don’t have to trust (because their access to our internal network is limited by the packet filter). If it works out like this, then we know that the packet filter cannot be bypassed. Of course, in some cases we discover that it doesn’t work out we hoped. For instance, maybe a user hooks up an unsecured wireless access point to his internal machine. Then anyone who drives by with a wireless-enabled laptop effectively gains access to the internal network (“gets painted red”), bypassing the packet filter. This illustrates that, to use a firewall safely, we’d better be sure that we’ve covered all the links between the internal network and the external world with firewalls. This set of links is sometimes known as the security perimeter.
The notion of a reference monitor recurs over and over again, and the three requirements for a secure reference monitor are worth memorizing.
Firewalls also embody another useful principle:
Firewalls have been tremendously widely used. They are one of the best success stories of technology transfer from the research to practice; the first paper was published at a research conference in 1990, and
application’s traffic and real web traffic. The fact that insiders are trusted has as a consequence that all applications that insiders execute will be trusted, too, and when such applications are acting in a more or less malicious way, the effectiveness of the firewall can be limited (even though the application developers probably do not think of themselves as malicious). The end result is that, over time, more and more traffic goes over port 25 and port 80, firewalls are gaining less and less visibility into the traffic that traverses them, and as a result firewalls are becoming less and less effective.