CSC 382 Computer Security Firewalls CSC 382 Computer

  • Slides: 35
Download presentation
CSC 382: Computer Security Firewalls CSC 382: Computer Security 1

CSC 382: Computer Security Firewalls CSC 382: Computer Security 1

Firewalls 1. 2. 3. 4. 5. 6. 7. What is a firewall? Types of

Firewalls 1. 2. 3. 4. 5. 6. 7. What is a firewall? Types of Firewalls Packet Filtering Proxying Firewall Architectures Bastion Hosts Tunneling and VPNs CSC 382: Computer Security 2

What is a Firewall? A software or hardware component that restricts network communication between

What is a Firewall? A software or hardware component that restricts network communication between two computers or networks. In buildings, a firewall is a fireproof wall that restricts the spread of a fire. Network firewall prevents threats from spreading from one network to another. CSC 382: Computer Security 3

Internet Firewalls Many organizations/individuals deploy a firewall to restrict access to their network from

Internet Firewalls Many organizations/individuals deploy a firewall to restrict access to their network from Internet. CSC 382: Computer Security 4

What is a Firewall? (2) A mechanism to enforce security policy – Choke point

What is a Firewall? (2) A mechanism to enforce security policy – Choke point that traffic has to flow through. – ACLs on a host/network level. Policy Decisions: – What traffic should be allowed into network? • Integrity: protect integrity of internal systems. • Availability: protection from DOS attacks. – What traffic should be allowed out? • Confidentiality: protection from data leakage. CSC 382: Computer Security 5

Types of Firewalls Packet Filters – Access control based on layer 3+4 (IP +

Types of Firewalls Packet Filters – Access control based on layer 3+4 (IP + TCP/UDP) headers, such as source and dest address and port. Circuit-level Gateways – TCP (layer 4) gateway – Relay computer copies byte stream from client to server and vice versa. Application Gateways – Application protocol gateway. CSC 382: Computer Security 6

Packet Filtering Forward or drop packets based on TCP/IP header information, most often: –

Packet Filtering Forward or drop packets based on TCP/IP header information, most often: – – – IP source and destination addresses Protocol (ICMP, TCP, or UDP) TCP/UDP source and destination ports TCP Flags, especially SYN and ACK ICMP message type Dual-homed hosts also make decisions based on: – Network interface the packet arrived on. – Network interface the packet will depart on. CSC 382: Computer Security 7

Filter Actions Pass – Forward acceptable packet on to destination. Drop – Drop unacceptable

Filter Actions Pass – Forward acceptable packet on to destination. Drop – Drop unacceptable packets. Log – Record action taken on packet. – Use syslog to internal loghost. CSC 382: Computer Security 8

Where to Packet Filter? Gateway Router – Filtering at interface between networks allows control

Where to Packet Filter? Gateway Router – Filtering at interface between networks allows control via a choke point. – Can filter spoofed IP addresses. Host – Filter packets on each individual computer. – How to manage thousands of packet filters? CSC 382: Computer Security 9

Ingress/Egress Filtering Block spoofed IP addresses Ingress Filtering Drop packets arriving on external interface

Ingress/Egress Filtering Block spoofed IP addresses Ingress Filtering Drop packets arriving on external interface whose source IP addresses claims to be from internal network. Egress Filtering Drop packets arriving on internal interface whose source IP address is not from internal network. CSC 382: Computer Security 10

Creating a Packet Filter 1. Create a security policy for a service. ex: allow

Creating a Packet Filter 1. Create a security policy for a service. ex: allow only outgoing telnet service 2. Specify security policy in terms of which types of packets are allowed/forbidden. 3. Write packet filter in terms of vendor’s filtering language. CSC 382: Computer Security 11

Example: outgoing telnet • TCP-based service • Outbound packets – Destination port is 23

Example: outgoing telnet • TCP-based service • Outbound packets – Destination port is 23 – Source port is random port >1023 – Outgoing connection established by first packet with no ACK flag set. – Following packets will have ACK flag set. • Incoming packets – Source port is 23, as server runs on port 23. – Dest port is high port used for outbound packets. – All incoming packets will have ACK flag set. CSC 382: Computer Security 12

Example: outgoing telnet 1. Rule allows outgoing telnet packets. 2. Rule allows response packets

Example: outgoing telnet 1. Rule allows outgoing telnet packets. 2. Rule allows response packets back in. 3. Rule denies all else, following Principle of Fail. Safe Defaults. Dir Src Dest Proto S. Port D. Port ACK? Action Out Int Any TCP >1023 23 Either Accept In Any Int TCP 23 >1023 Yes Accept Any Any Either Deny Either Any CSC 382: Computer Security 13

Example: outgoing telnet Fedora Linux /etc/sysconfig/iptables -A RH-Firewall-1 -INPUT -m state --state NEW m

Example: outgoing telnet Fedora Linux /etc/sysconfig/iptables -A RH-Firewall-1 -INPUT -m state --state NEW m tcp -p tcp --dport 23 -j ACCEPT -A RH-Firewall-1 -INPUT -m state --state ESTABLISHED, RELATED –m tcp –d tcp – sport 23 -j ACCEPT -A RH-Firewall-1 -INPUT -j REJECT CSC 382: Computer Security 14

Limitations/Problems • Must know details of TCP/UDP port usage of protocol to create filters.

Limitations/Problems • Must know details of TCP/UDP port usage of protocol to create filters. • Applications only identified by port number – What if external host is running a different TCP protocol on port 23? • Order of rules important – Difficulties when adding a new service filter to an existing ruleset. CSC 382: Computer Security 15

Example: SMTP Policy: Allow incoming and outgoing SMTP, deny all other services. Dir In

Example: SMTP Policy: Allow incoming and outgoing SMTP, deny all other services. Dir In Src Ext Dest Int Proto S. Port TCP Any D. Port ACK? Action 25 Either Accept Out Int Ext TCP Any >1023 Either Accept Out Int Ext TCP Any 25 Either Accept In Ext Int TCP Any >1023 Either Accept Any Any Either Deny Either Any CSC 382: Computer Security 16

Example: SMTP • • Rules 1+2 allow outgoing SMTP. Rules 3+4 allow incoming SMTP.

Example: SMTP • • Rules 1+2 allow outgoing SMTP. Rules 3+4 allow incoming SMTP. Rule 5 denies all other protocols. Problem: – What about external user attacking an internal X server on port 23? – Rules 2 + 4 allows all connections where both ends use ports >1023 CSC 382: Computer Security 17

Example: SMTP Solution: Revise rules to consider source port and ACK flag. Dir In

Example: SMTP Solution: Revise rules to consider source port and ACK flag. Dir In Src Ext Dest Int Proto S. Port TCP >1023 D. Port ACK? Action 25 Either Accept Out Int Ext TCP 25 >1023 Yes Accept Out Int Ext TCP >1023 25 Either Accept In Ext Int TCP 25 >1023 Yes Accept Any Any Either Deny Either Any CSC 382: Computer Security 18

Stateful Packet Filters • Saves packet data to keep state, in order to reconstruct

Stateful Packet Filters • Saves packet data to keep state, in order to reconstruct connection at IP level – Even though UDP has no ACK flag, can construct connection by remembering outgoing packet for UDP 53 (DNS) and know that a response should come from that port to the source port of original packet. • Can examine packets at application layer – Examine FTP packet stream for PASV/PORT commands to find return port for ftp data stream. CSC 382: Computer Security 19

Packet Filtering Summary Advantages: – One packet filter can protect an entire network –

Packet Filtering Summary Advantages: – One packet filter can protect an entire network – Efficient (requires little CPU) – Supported by most routers Disadvantages: – Difficult to configure correctly • Must consider rule set in its entirety – Difficult to test completely – Performance penalty for complex rulesets • Stateful packet filtering much more expensive – Enforces ACLs at layer 3 + 4, without knowing any application details CSC 382: Computer Security 20

Proxy Servers Proxy host relays Transport/App connections – Client makes connection to proxy. –

Proxy Servers Proxy host relays Transport/App connections – Client makes connection to proxy. – Proxy forwards connection to server. Proxy provides: – Access Control • Proxies specified src + dest ports / IP addrs. – Logging – Anonymity CSC 382: Computer Security 21

Example: SOCKS v 5 • Socks Server • Socks Client Library – Clients must

Example: SOCKS v 5 • Socks Server • Socks Client Library – Clients must be linked against library. – Library offers replacements for UNIX network socket system calls. • User Authentication Protocols – Cleartext username/password. – GSS-API authentication. CSC 382: Computer Security 22

Circuit Gateways Advantages: – User-level authentication possible. – Efficient logging, as proxy deals with

Circuit Gateways Advantages: – User-level authentication possible. – Efficient logging, as proxy deals with circuit connections instead of individual packets. Disadvantages: – Clients have to be recompiled or reconfigured to use proxy service. – Some services can’t be proxied. – Cannot protect you from all protocol weaknesses. CSC 382: Computer Security 23

Single Host Firewall Simplest type of firewall—one host acts as a gateway between internal

Single Host Firewall Simplest type of firewall—one host acts as a gateway between internal and external networks. CSC 382: Computer Security 24

Types of Single Host Firewall Screening Router – – Organizations already have a router

Types of Single Host Firewall Screening Router – – Organizations already have a router Most routers have packet filtering capabilities Advantages: cheap, simple Disadvantages: can only do packet filtering Dual-homed Host – Server with two NICs – Advantages • Configurable: packet filter, circuit proxy, app proxy – Disadvantages • Lower performance than router CSC 382: Computer Security 25

Screened Subnet Isolates internal network from external networks by means of a perimeter network,

Screened Subnet Isolates internal network from external networks by means of a perimeter network, called a DMZ. CSC 382: Computer Security 26

Screened Subnet Bastion hosts isolated from internal network – Compromise of a bastion host

Screened Subnet Bastion hosts isolated from internal network – Compromise of a bastion host doesn’t directly compromise internal network. – Bastion hosts also can’t sniff internal traffic, since they’re on a different subnet. No single point of failure – Attacker must compromise both exterior and interior routers to gain access to internal net. Advantages: greater security Disadvantages: higher cost and complexity CSC 382: Computer Security 27

Screened Subnet External Access – Filtered: via interior + exterior routers – Proxied: use

Screened Subnet External Access – Filtered: via interior + exterior routers – Proxied: use a bastion host as a proxy server Bastion Hosts – Proxy server – External web/ftp servers – External DNS server – E-mail gateway CSC 382: Computer Security 28

Screened Subnet Exterior Router – Simple filtering rules • Ingress/Egress Filtering • DOS prevention

Screened Subnet Exterior Router – Simple filtering rules • Ingress/Egress Filtering • DOS prevention • Simple ACLs – May be controlled by ISP Interior Router – Complex filtering rules. – Must protect internal network from bastion hosts as well as external network. Recommendation: use different hardware/software for interior and exterior routers. CSC 382: Computer Security 29

Tunneling: Encapsulation of one network protocol in another protocol – Carrier Protocol: protocol used

Tunneling: Encapsulation of one network protocol in another protocol – Carrier Protocol: protocol used by network through which the information is travelling – Encapsulating Protocol: protocol (GRE, IPsec, L 2 TP) that is wrapped around original data – Passenger Protocol: protocol that carries original data CSC 382: Computer Security 30

ssh Tunneling SSH can tunnel TCP connections – Carrier Protocol: IP – Encapsulating Protocol:

ssh Tunneling SSH can tunnel TCP connections – Carrier Protocol: IP – Encapsulating Protocol: ssh – Passenger Protocol: TCP on a specific port POP-3 forwarding ssh -L 110: pop 3 host: 110 -l user pop 3 host – Uses ssh to login to pop 3 host as user – Creates tunnel from port 110 (leftmost port #) on localhost to port 110 (rightmost post #)of pop 3 host – User configures mail client to use localhost as POP 3 server, then proceeds as normal CSC 382: Computer Security 31

Virtual Private Network (VPN) • Two or more computers or networks connected by a

Virtual Private Network (VPN) • Two or more computers or networks connected by a private tunnel through a public network (typically the Internet. ) • Requirements: – Confidentiality: encryption – Integrity: MACs, sequencing, timestamps • Firewall Interactions – Tunnels can bypass firewall – Firewall is convenient place to add VPN features CSC 382: Computer Security 32

Firewall Limitations Cannot protect from internal attacks – May be able to limit access

Firewall Limitations Cannot protect from internal attacks – May be able to limit access with internal firewalls to a segment of your network. Cannot protect you from user error – Users will still run trojan horses that make it past your AV scanner. Firewall mechanism may not precisely enforce your security policy. CSC 382: Computer Security 33

Key Points • Almost everything is spoofable. • Denial of service attacks are easy.

Key Points • Almost everything is spoofable. • Denial of service attacks are easy. • Port scanning – Stealth – OS Fingerprinting • Firewalls – Packet filtering – Proxying – DMZ CSC 382: Computer Security 34

References 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Steven Bellovin,

References 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Steven Bellovin, “Security Problems in the TCP/IP Protocol Suite”, Computer Communication Review, Vol. 19, No. 2, pp. 32 -48, April 1989. Matt Bishop, Introduction to Computer Security, Addison-Wesley, 2005. William Cheswick, Steven Bellovin, and Avriel Rubin, Firewalls and Internet Security, 2 nd edition, 2003. Fyodor, “The Art of Port Scanning, ” http: //www. insecure. org/nmap_doc. html Fyodor, NMAP man page, http: //www. insecure. org/nmap/data/nmap_manpage. html Fyodor, “Remote OS detection via TCP/IP Stack Finger. Printing, ” Phrack 54, http: //www. insecure. org/nmap-fingerprinting-article. html Simson Garfinkel, Gene Spafford, and Alan Schwartz, Practical UNIX and Internet Security, 3 rd edition, O’Reilly & Associates, 2003. Johnny Long, Google Hacking for Penetration Testers, Snygress, 2004. Stuart Mc. Clure, Joel Scambray, George Kurtz, Hacking Exposed, 3 rd edition, Mc. Graw-Hill, 2001. Ed Skoudis, Counter Hack, Prentice Hall, 2002. Elizabeth Zwicky, Brent Chapman, Simon Cooper, Building Internet Firewalls, 2 nd edition, O’Reilly & Associates, 2000. CSC 382: Computer Security 35