Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Burgess M.Principles of network and system administration.2004.pdf
Скачиваний:
181
Добавлен:
23.08.2013
Размер:
5.65 Mб
Скачать

12.10. ORDERED ACCESS CONTROL AND POLICY CONFLICTS

483

separate operations, different orderings lead to different results. If authentication data are applied only after encryption, then they can be altered by a middle-man, leading to authentication spoofing (see section 12.4.5). Similarly, if encryption is applied after authentication, then the destination host can reroute data under false pretences.

The policy manager searches for the first network object that matches from the top of the list, and continues down through all the policy rules in turn, generating rule lists from the policy rules until all instances of that network object are added to the rule list. Therefore, rules appearing first can prevent subsequent rules from being enforced. For example, assume you create the following two policy rules:

Policy Rule 1:

src= host1 dest=host2 serv=all IP action=Permit and IPSec

Policy Rule 2:

src=network1 dest=network2 serv=all IP action=Permit

where host1 is assumed to be on network1 and host2 is on network2. Policy Rule 1 is a more specific rule; therefore, it should appear first in the Policy Rule table so that traffic from host1 to host2 is routed through an IPSec tunnel. If Policy Rule 2 appeared first, it would take precedence and non-tunneled IP traffic would be permitted from host1 to host2.

12.10 Ordered access control and policy conflicts

Access control lists are the basis of access control in most computer security systems. They are irreplaceable, and yet they have a basic flaw: they are order dependent.

Principle 65 (Conflicting rules). In any situation where conflicting rules can arise, the result will be sensitive to the order in which the rules are evaluated.

Example 19 (Ordering in list-based policies). List-based policy decisions are sensitive to ordering issues. Lists usually satisfy a ‘first match wins’ rule, or an ‘evaluate all rules in order’ rule.

If the ordering of two rules is reversed, valuable protection can be lost. An example of this was mentioned in section 12.4.5 for signing and encryption. Encryption is often a problem here, because it hides rules that might be evaluated, preventing any ‘corrective measures’ that might have been applied to eliminate conflicts. Consider three examples of IPSec security polices [124], where inconsistencies can lead to unfortunate and incorrect behavior.

Example 20 (IPSec 1). Consider a scenario between two domains (figure 12.2), one of which has a firewall and one of which has a gateway supporting IPSec security policies. The users of H1 are concerned about the privacy of data, so they arrange for the traffic to be encrypted.

484

CHAPTER 12. SECURITY IMPLEMENTATION

FW1

SG2

H1

H2

Figure 12.2: IPSec configuration 1.

Using IPSec policy rules, an encrypted tunnel is built between H1 and the secure gateway SG2 in order to protect the traffic. However, the IPSec policy rules on the firewall are set by a different authority, and they can be specified so that encrypted packets can be denied access. If the firewall FW1 has such a rule, either intentionally or unintentionally, then all packets will be dropped and communication will be mysteriously impossible.

Example 21 (IPSec 2). Suppose that H1 is still trying to encrypt traffic to SG2, with the same tunnel rule. Suppose the firewall FW1 now has the rules:

Allow: source=H1, destination=H2

Deny: all others

However, since the encryption tunnel changes the destination to be SG2 in the outer encapsulation header, the firewall will mistakenly drop all traffic from H1 to H2 that should be allowed. Even though the traffic has the correct source and destination addresses, the overlapping rules cause problems.

In the following example, encryption plays a role in fixing a strong ordering of rules that can lead to unfortunate mis-communications.

Example 22. (IPSec 3). Consider two separate sites (figure 12.3), each with their own IPSec gateways (SG1 and SG2). Suppose that the administrator from department D1 who is in charge of SG1 decides that all traffic from D1 to site O2 should be encrypted by a tunnel from SG1 to SG3. In a different building, another administrator who controls SG2 decides that traffic from site O1 to site O2 should be encrypted through a tunnel from SG2 to SG4.

What happens now, when someone in department D1 attempts to send a message to someone in department D2? The traffic between the sites is now governed by two

 

ENC tunnel 1

SG1

SG3

D1

 

 

D2

 

ENC tunnel 2

SG4

 

SG2

 

 

 

 

 

O1

 

 

O2

 

 

 

Figure 12.3: IPSec configuration 2.

12.11. IP FILTERING FOR FIREWALLS

485

policies that do not agree, and either tunnel could be chosen. Part of the journey is unencrypted, either in the first organization, or in the second.

If the administrator in D1 does not add a selector for traffic specifically to D2 (via SG4) that allows it to pass via SG2, then it could take the upper tunnel and be unencrypted within the second organization (between SG3 and SG4). If the communication is between an employee of organization O1 and the organization itself, this might be a breach of security.

On the other hand, if the rules are adjusted so as to direct traffic to the lower tunnel for all traffic destined for site O2, then there would be two overlapping rules to SG4 (from SG1 and SG2) and the traffic could pass by either one of two routes.

Suppose someone in department D1 now wishes to send data to a host outside of department D2. If the traffic takes the upper tunnel 1, there is no problem. However, if the traffic chooses the lower tunnel in the diagram, via a new tunnel between SG1 and SG2, then some strange effects can occur. With this configuration, traffic is encapsulated with a secure header from SG1 and then encapsulated by a new header from SG2 to send to SG4. When SG4 decrypts and removes the packaging, it finds that the destination is SG3, SG4 sends the traffic back to SG3 unencrypted, which finally delivers the packet to its actual destination.

SG1: (dest=H2)_SG4, send SG2

SG2: ((dest=H2)_SG4)_SG4, send SG4

SG4: (dest=H2), send SG3

SG3: send destination

Although the intention was to encrypt all the traffic, the traffic ends up passing from SG4 to SG3 unencrypted.

The problem over overlapping rules can thus lead to security problems, unless a careful site-wide management assures the‘ consistency of policy throughout. The alternative to using multiple encapsulation rules is use point-to-point encryption, but this has its own problems. All points along a route must be trusted to deny access to eavesdroppers. This is not enforceable.

12.11 IP filtering for firewalls

Filtering of TCP/IP data can be accomplished in numerous ways, both at routers and at the host level. Filters can exact access control on datagrams, where the attributes are, amongst other things,

Source port

Destination port (service type)

Source IP address

Destination IP address

TCP protocol attributes (SYN/ACK).

486

CHAPTER 12. SECURITY IMPLEMENTATION

A firewall blocks access at the network level. For instance, Cisco IOS rules:

ip access-group 100 in

access-list 100

permit

tcp

any host 128.39.74.16 eq http

access-list

100

permit

tcp

any host 128.39.74.16 eq smtp

access-list

100

deny

ip

any any

Modern versions of operating systems can filter IP packets in the kernel too, giving hosts effectively a host-based firewall. For instance, Linux and FreeBSD have IP tables, formerly known as ‘IP chains’:

iptables -N newchain

# new ACL/chain

iptables -A newchain -p tcp -s 0/0 smtp -j ACCEPT

#

-s source address

iptables -A newchain -p tcp -s 0/0 www -j ACCEPT

 

 

iptables -A newchain -j DENY

#

all else

The CIDR notation 0/0 is the same as 0.0.0.0 255.255.255.255, or any. A default policy for any packets that are not ACCEPTed is set as follows:

iptables -P INPUT DROP iptables -P OUTPUT DROP

Windows 2000 has corresponding ‘IPSec filters’ and the local security policy has an IP filter list.

12.12 Firewalls

A firewall is a network configuration which isolates some machines from the rest of the network. It is a gate-keeper which limits access to and from a network. Our human bodies are relatively immune to attack by bacteria and viruses because we have a barrier: skin. The skin contains layers of various fatty acids in which bacteria and viruses cannot normally survive. If we lose the skin from a part of the body, wounds become quickly infected; indeed, prior to antibiotics, many people died from infected wounds. A firewall is like a skin for a local area network.

The idea is this: if we could make a barrier between our local network and the Internet which is impenetrable, then we would be safe from network attacks. But if there is an impenetrable barrier so that no one can get into the network, then no one can get out either. Why pay for a firewall when we could just pull out the network cable? Think of the body again: we have to put food and air into our bodies and we have to let stuff out, so we need a hole in the skin (preferably several). We do not usually die of the food we eat because the body has filters which screen out and break down dangerous organisms (stomach acid and layers of mucus etc.). These then hand us the ‘input’ by proxy. We do the same thing with computer networks. A firewall is not an impenetrable barrier: it has holes in it with passport checks. We demand that only network data with appropriate credentials should be allowed to pass.

12.12.1A firewall concept

A firewall is a concept. It is not a thing; there is no single firewall solution. The name ‘firewall’ is a collective description for a variety of methods which restrict

12.12. FIREWALLS

487

access to a network. They all involve placing restrictions on the way in which network packets are routed. A firewall might be a computer which is programmed to act like a router, or it might be a dedicated router or a combination of routers and software systems. The idea with a firewall is to keep important data behind a barrier which has some kind of passport-control and can examine and restrict network packets, allowing only ‘harmless’ packets to pass.

All traffic from inside to outside or vice versa must pass through the firewall.

Only authorized traffic is allowed to pass.

Potentially risky network services (like mail) are rendered safer using intermediary systems.

The firewall itself should be immune to attack.

A firewall cannot help with the following:

Badly configured hosts or mis-configured networks.

Data-based attacks (where the attack involves sending some harmful information, like the code word which makes you take your own life, or an E-mail which bolts a Trojan horse).

There are two firewall philosophies: block everything unless we make an explicit exception and pass everything unless we make a specific exception. The first of these is clearly the most secure or at least the more paranoid of the two.

Here are a few concepts which get bandied around in firewall-speak:

Screening router or ‘choke’: A router which can be programmed to filter or reject packets directed at certain IP ports.

Bastion host: A computer, specially modified to be secure but available.

Dual-homed host: A computer with two net-cards, which can be used to link an isolated network to a larger network.

Application gateway: A filter, usually run on a bastion host, which has the ability to reject or forward packets at a high level (i.e. at the application level).

Screened subnet/DMZ: An isolated subnet, between the Internet and the private network. Also called a DMZ (de-militarized zone). A DMZ is the bit between a screening router and the firewall, bastion host. This is a good place for external WWW services.

The firewall philosophy builds on the idea that it is easier to secure one host (the bastion host) than it is to secure hundreds or thousands of hosts on a local network. One focuses on a single machine and ensures that it is the only one effectively coupled directly to the network. One forces all network traffic to stop at the bastion host, so if someone tries to attack the system by sending some kind of IP attack there can be little damage to the rest of the network because the private network will never see the attack. This is of course a simplification. It is important

488

CHAPTER 12. SECURITY IMPLEMENTATION

to realize that installing a firewall does not give absolute protection and it does not remove the importance of configuring and securing the hosts on the inside of the firewall.

It should also be noted that a firewall is usually a single point of failure for a network. It is vulnerable to Denial of Service attacks.

12.12.2Firewall proxies

Of course we do not want all traffic to stop; some services like E-mail and maybe HTTP should be able to pass through. To allow this, one uses a so-called ‘proxy’ service or a ‘gateway’.5 A common solution is to give the bastion host two network interfaces (one is then connected to the unsafe part of the network and the other is connected to the safe part), though the same effect can be obtained with a single interface. A service is said to be proxied if the bastion host forwards the packets from the unsafe network to the safe one. It only does this for packets which meet the requirements of the security policy. For instance, you might decide that the services you require to cross the firewall are inbound/outbound telnet, inbound/outbound SMTP (mail), DNS, HTTP and FTP but no others.

Principle 66 (Community borders). Proxying is about protecting against breaches to the fundamental principle of communities. A firewall proxy provides us with a buffer against violations of our own community rights from outside, and also provides others with a buffer against what we choose to do in our own home.

Proxying requires some special software, often at the level of the kernel where the validity of connections can be established. For instance, packets with forged addresses can be blocked. Data arriving at ports where there was no registered connection can be discarded. Connections can be discarded if they do not relate to a known user-account.

12.12.3Example: dual-homed bastion host

A simple firewall configuration is shown in figure 12.4.

In this example we have effectively two routers, a DMZ and a protected network. The first packet-filtering router will route packets between the Internet and one of three hosts. FTP is routed directly to a special FTP server. The same applies to HTTP packets. These services are dealt with by separate hosts, so that (if something should go wrong and the machines are broken into) it is no worse than having to restore these single hosts from backup. None of the servers in the DMZ have normal user accounts, so there would be no help to crackers trying to crack password files there, if they managed to break in. The bastion host gets all packets which are not for the other services. The bastion host forwards okay-looking packets to the internal router which is really just a further packet filter (a backup in case of failure of the bastion host). The internal router accepts only packets passing between the safe network and the bastion host, all others are rejected.

5This should not be confused with a WWW caching proxy, which is a kind of cache for frequently used HTML pages.

12.12. FIREWALLS

489

external Internet

external

ftphost httphost

router

DMZ

BASTION

HOST

 

 

 

 

dnshost

 

smtphost

host

host

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

internal network

Figure 12.4: A simple firewall with a dual-homed bastion host.

The bastion host proxies all of the appropriate protocols including FTP and HTTP between the safe network and the DMZ.

12.12.4Example: two routers

A second example, in which there is no dual-homed host, is shown in figure 12.5. In this configuration we use two routers to allow increased protection. An exterior router connects the site to the Internet, or the untrusted ‘outside’ network. The interior router protects the internal network from the bastion host and from the DMZ. Although the bastion host does not physically separate the exterior and interior networks, it still separates them through proxy software, by forcing

packets to be routed through the bastion host’s proxy services.

In order to illustrate router filtering tables more explicitly, let us assume that we have a WWW server and FTP server in the DMZ, and an SMTP server on the

external Internet

external

BASTION

router

HOST ftphost httphost

DMZ

internal router

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

dnshost

 

smtphost

host

host

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

internal network

Figure 12.5: Firewall with no dual-homed host, but two routers.

490

CHAPTER 12. SECURITY IMPLEMENTATION

internal network. The DNS service is split. Data pertaining to the outside network are kept in an authoritative server on the bastion host itself. DNS data about the internal network are not visible to the outside world; they are kept on the internal network, on a separate internal DNS server. Local machines are clients of the internal DNS server, so that DNS data are maximally protected.

The router filtering tables are shown and explained in tables 12.1 and 12.2 (see also ref. [61] for an excellent discussion of filtering and firewalls in general). They are designed to route traffic through the proxy servers on the bastion host, and direct special services (SMTP, HTTP etc.) only to the hosts which need to receive them. The bastion host, as usual, has a stripped down operating system, to remove as many potential exploits from the reach of potential intruders. The filter rules distinguish between traffic which is incoming and traffic which is outgoing. Note that TCP and UDP traffic differs here. Whereas TCP traffic generally involves fixed port addresses on servers and random ports (with port numbers greater than 1023, actually usually much higher than this) on clients, we have to be careful about filtering possible traffic based on port numbers. In practice, 1023 is probably far too low a port number to set here, but it is difficult to make generic rules for random port numbers, so we use this number as a mnemonic. Some spoofing attempts are prevented by requiring the ACK bit to be set on TCP connection requests. The ACK bit is not set on SYN packets which initiate connections, only on replies, so requiring the ACK bit to be set is a way of saying that these rules require traffic to be part of an already established dialogue between legitimate ports. This prevents a remote attacker from using a well-known port externally to attempt to bypass the filter rules to attack a server living at a port number over 1023.6 The corresponding outgoing rule can be considered a service to other sites, which stifles local spoofing attempts.

12.12.5A warning

The foregoing configurations are just examples. In practice we might not have all the hardware we need to separate things as cleanly as shown here. Although there is a public domain firewall toolkit [115], most firewall software is commercial in nature because it needs to live in the kernel and make use of code which is proprietary.

Firewall management is a complex issue. We cannot set up a firewall and then forget about it. Firewalls need constant maintenance and they are susceptible to bugs just like any other software. It is best to build up a firewall system slowly, understanding each step. A good place to start is with packet-filtering routers to eliminate the most offensive or least secure service requests from outside your local network. These include NFS (RPC), IRC, ping, finger etc.

Today, many consider firewalls to be an outdated idea, one that is no substitute for host-based security. Network services are evolving so quickly that it is difficult for any ‘patch it up’ technology to keep up. What is needed is fundamentally secure services. For instance, many services today are implemented via the World

6Attackers are devious. We should not imagine that, simply because a filtering rule was intended for, say, SMTP traffic, it could not be manipulated for some other purpose.

12.12. FIREWALLS

 

 

 

 

 

491

 

 

 

 

 

 

 

 

 

 

 

 

Rule

I/O

Src

Dest

Proto

Src

Dest

ACK

Action

 

 

 

 

addr

addr

 

port

port

set

 

 

 

 

 

 

 

 

 

 

 

 

 

 

spoof

in

intern

any

any

any

any

any

deny

 

 

 

 

 

 

 

 

 

 

 

 

 

ssh1

in

bastion

intern

TCP

22

> 1023

yes

permit

 

 

ssh2

in

bastion

intern

TCP

> 1023

22

any

permit

 

 

ssh3

out

intern

bastion

TCP

> 1023

22

any

permit

 

 

ssh4

out

intern

bastion

TCP

22

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

 

 

 

 

ftp1

out

intern

bastion

TCP

> 1023

21

any

permit

 

 

ftp2

in

bastion

intern

TCP

21

> 1023

yes

permit

 

 

ftp3

in

bastion

intern

TCP

20

> 1023

any

permit

 

 

ftp4

out

intern

bastion

TCP

> 1023

20

yes

permit

 

 

 

 

 

 

 

 

 

 

 

 

 

smtp1

out

intern

bastion

TCP

> 1023

25

any

permit

 

 

smtp2

in

bastion

smtphost

TCP

25

> 1023

any

permit

 

 

smtp3

out

smtphost

bastion

TCP

25

> 1023

yes

permit

 

 

smtpX

in

bastion

intern

TCP

25

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

 

 

 

 

http1

out

intern

bastion

TCP

> 1023

80

any

permit

 

 

http2

in

bastion

intern

TCP

80

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

 

 

 

 

dns1

out

dnshost

bastion

UDP

53

53

N/A

permit

 

 

dns2

in

bastion

dnshost

UDP

53

53

N/A

permit

 

 

dns3

out

dnshost

bastion

TCP

> 1023

53

any

permit

 

 

dns4

in

bastion

dnshost

TCP

53

> 1023

yes

permit

 

 

dns5

in

bastion

dnshost

TCP

> 1023

53

any

permit

 

 

dns6

out

dnshost

bastion

TCP

53

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

 

 

 

 

default1

out

any

any

any

any

any

any

deny

 

 

default1

in

any

any

any

any

any

any

deny

 

 

 

 

 

 

 

 

 

 

 

 

Table 12.1: Internal router filter table. Incoming ssh traffic is allowed from the bastion host ssh proxy to the internal hosts, but not to the DMZ. Outgoing traffic is channeled through the bastion host proxy, which avoids the origin IP address being seen by outsiders. FTP, HTTP and SMTP traffic is allowed between the respective server-hosts and the bastion hosts proxies. Note how WWW and FTP servers are special ‘sacrificial lamb’ hosts in the DMZ, with data backed up on internal hosts. Note that FTP uses two channels, a transmission channel and a control channel on ports 20 and 21. An SMTP mail hub is used. DNS MX records should be set to point to the bastion host proxy. DNS filters are slightly complex, since the DNS services uses both UDP for lookup and TCP for bulk transfer and forwarding.

492

 

 

CHAPTER 12. SECURITY IMPLEMENTATION

 

 

 

 

 

 

 

 

 

Rule

I/O

Src

Dest

Proto

Src

Dest

ACK

Action

 

 

addr

addr

 

port

port

set

 

 

 

 

 

 

 

 

 

 

spoof1

in

intern

any

any

any

any

any

deny

spoof2

in

outside

any

any

any

any

any

deny

 

 

 

 

 

 

 

 

 

ssh1

in

any

bastion

TCP

22

> 1023

yes

permit

ssh2

in

any

bastion

TCP

> 1023

22

any

permit

ssh3

out

bastion

any

TCP

> 1023

22

any

permit

ssh4

out

bastion

any

TCP

22

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

ftp1

out

bastion

any

TCP

> 1023

21

any

permit

ftp2

in

any

bastion

TCP

21

> 1023

yes

permit

ftp3

in

any

bastion

TCP

20

> 1023

any

permit

ftp4

out

bastion

any

TCP

> 1023

20

yes

permit

 

 

 

 

 

 

 

 

 

smtp1

out

bastion

any

TCP

> 1023

25

any

permit

smtp2

in

any

bastion

TCP

25

> 1023

yes

permit

smtp3

in

any

bastion

TCP

> 1023

25

any

permit

smtp4

out

bastion

any

TCP

25

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

http1

out

bastion

any

TCP

> 1023

80

any

permit

http2

in

any

bastion

TCP

80

> 1023

yes

permit

http3

in

any

httphost

TCP

> 1023

80

any

permit

http4

out

httphost

any

TCP

80

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

dns1

out

bastion

any

UDP

53

53

N/A

permit

dns2

in

any

bastion

UDP

53

any

N/A

permit

dns3

in

any

bastion

UDP

any

53

N/A

permit

dns4

out

bastion

any

UDP

53

any

N/A

permit

dns5

out

bastion

any

TCP

53

> 1023

any

permit

dns6

in

any

bastion

TCP

53

> 1023

yes

permit

dns7

in

any

bastion

TCP

> 1023

53

any

permit

dns8

out

bastion

any

TCP

53

> 1023

yes

permit

 

 

 

 

 

 

 

 

 

default1

out

any

any

any

any

any

any

deny

default1

in

any

any

any

any

any

any

deny

 

 

 

 

 

 

 

 

 

Table 12.2: External router filter table. External connections are forced to go through the bastion host proxies.