firewalls and nat - inet.tu-berlin.de · firewalls and nat. 2 firewalls isolates organization’s...

Post on 19-May-2019

233 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Firewalls and NAT

2

Firewalls

isolates organization’s internal net from larger Internet, allowing some packets to pass, blocking others.

firewall

Internetprivately administered

222.22/16

By conventional definition, a firewall is a partition madeof fireproof material designed to prevent the spreadof fire from one part of a building to another.

3

Firewalls: Goals All traffic from outside to inside and vice-versa

passes through the firewallOnly authorized traffic, as defined by local

security policy, will be allowed to pass Firewall itself is immune to penetration

4

Firewalls: Taxonomy1. Traditional packet

filters Filters often combined

with router, creating a firewall

2. Stateful filters3. Application gateways

Major firewall vendors:CheckpointCisco PIX

FirewallFirewall == system that filters TCP/IP UDP/IP

packets according to rulesEither software on user machine or network router

Rules

6

Firewall

Rules

router

(Global IP addresses)

7

Traditional packet filters

Source IP address Destination IP address Source port Destination port TCP flag bits

SYN bit set: datagram for connection initiation

ACK bit set: part of established connection

TCP or UDP or ICMP Firewalls often configured to

block all UDP Direction

Is datagram leaving or entering internal network?

Router interface Decisions can be different

for different interfaces

Analyzes each datagram going through it; makes dropdecision based on:

8

Filtering rules - examples

Policy Firewall Setting

No outside Web access. Drop all outgoing packets to any IP address, port 80

Outside connections to public Web server only.

Drop all incoming TCP SYN packets to any IP except 130.207.244.203, port 80

Prevent Web-radios from eating up the available bandwidth.

Drop all incoming UDP packets - except DNS and router broadcasts.

Prevent your network from being used for a Smuft DoS attack.

Drop all ICMP packets going to a “broadcast” address (e.g. 130.207.255.255).

Prevent your network from being tracerouted

Drop all outgoing ICMP unreachables

9

Access control lists

actionsourceaddress

destaddress

protosource

portdestport

flagbit

allow 222.22/16outside of222.22/16

TCP > 1023 80 any

allowoutside of222.22/16

222.22/16 TCP 80 > 1023 ACK

allow 222.22/16outside of222.22/16

UDP > 1023 53 ---

allowoutside of222.22/16

222.22/16 UDP 53 > 1023 ----

deny all all all all all all

Apply rules from top to bottom:

10

Access control lists (2.) Each router/firewall interface can have its own

ACLMost firewall vendors provide both command-line

and graphical configuration interface

11

Traditional packet filters Advantages

One screening router can protect entire network Can be efficient if filtering rules are kept simpleWidely available. Almost any router, even Linux boxes

Disadvantages Can be penetrated Cannot enforce some policies. For example, permit

certain users. Rules can get complicated and difficult to test

12

Network or host firewall

Network firewall protected

networkInternet

Network firewall:

host withfirewall

Internet

Host firewall:

13

Example: Iptables – chain types

Linuxhost w/iptables

protectednetwork

Internet

Linuxhost w/iptables

protectednetwork

Internet

Linuxhost w/iptables

protectednetwork

Internet

INPUT chain(to iptables host)

OUTPUT chain(from iptables host)

FORWARDchain

14

Iptables: Example command

iptables –A INPUT –i eth0 –s 232.16.4.0/24 –j ACCEPT

Sets a rule Accepts packets that enter from interface eth0 with

source address in 232.16.4/24

Kernel applies rules in order First matching rule determines action for packet

Append: -A Adds rule to bottom of existing rules

15

Stateful filters Stateless filters: Any packet with ACK=1 and

source port 80 gets through Attack with malformed packets: send ACK=1 segments

Stateful filter: Adds more intelligence to decision-making process Stateful = remember past packets Needs very dynamic state table

16

Stateful filters: Example

sourceaddress

destaddress

sourceport

destport

222.22.1.7 37.96.87.123 12699 80

222.22.93.2 199.1.205.23 37654 80

222.22.65.143 203.77.240.43 48712 80

Rule table indicates check of stateful table:See if there is a connection entry in stateful table

• Log each TCP conn initiated through firewall: SYN segment• Timeout entries without activity after, e.g., 60 seconds

Stateful filters can remember outgoing UDP segments

17

Stateful example: Example (2.)

actionsource

addressdest

addressproto

sourceport

destport

flagbit

check conn

allow 222.22/16outside of222.22/16

TCP > 1023 80 any

allowoutside of222.22/16

222.22/16 TCP 80 > 1023 ACK x

allow 222.22/16outside of222.22/16

UDP > 1023 53 ---

allowoutside of222.22/16

222.22/16 UDP 53 > 1023 ---- x

deny all all all all all all

1) Pkt arrives from outside: src=37.96.87.123, src port=80,dst=222.22.1.7, dst port=12699, SYN=0, ACK=1

2) Check filter table ➜ check stateful table

3) Connection is in connection table ➜ let packet through

18

Application gateways (aka proxy servers)

host-to-gatewayftp session

gateway-to-remote host ftp session

applicationgateway

App gateway between user (inside) and server (outside)

User and server talk through proxy

Allows fine grained/ sophisticated control

Hinders protocol attacks E.g.: ftp server may not

allow files >= size X

19

Mail servers and proxy Web servers Local mail server is application gateway

Virus detection and removal

So is Web proxy cache E.g.: virus detection and removal

20

Proxy gateways Advantages

Can log all connections, activity in connections Can provide caching Can do intelligent filtering based on “content” Simplifies service control

• Can perform user level authentication• Simplifies firewall rules

Disadvantages Not all services have proxied versions Need different proxy server for each service Requires modification of client Performance Hinders end-to-end encryption

21

Demilitarized Zone (DMZ)

Used for: Gateways and public services Advantage: Hacked server – limited damage

Webserver

FTPserver

DNSserver

applicationgateway

Internet

Demilitarized zone

Internalnetwork

firewall

22

IP traceback

Why? Attackers can spoof source IP address Benefits:

Determine attacker Determine zombie machine participating in DDoS

attack

Alternative: Use ingress filtering

Problem: How do we determine where malicious packet came from ?

23

Methods for finding source Manual using current IP routing

Link testing: how?• Start from victim and test upstream links• Recursively repeat until source is located• Assume attack remains active until trace complete

Link testing: problem• Handle ISPs• Located zombie…

Logging

Automatic using marking algorithms

24

Logging Key routers log packets (useful for forensics) Use data mining to find path Pros

Post mortem – works after attack stops

Cons High resource demand:

need to store and process tons of data

25

Marking algorithmsMark packets with router addresses

Deterministically or probabilistically

Trace attack using marked packets Strengths

Independent of ISP management Little network overhead, traffic Trace distributed attacks, attacks post-mortem

26

Marking: Assumptions

Most routers remain uncompromised

Attacker sends many packets

Route from attacker to victim remains relatively stable

R6 R7 R8

A4 A5A1 A2 A3

R9 R10

R12

V

27

Marking: Summary Can determine attack path with a relatively small

number of attack packets Need to include addresses, counter in IP

datagram (e.g., via fragment fields) E.g.: “Practical Network Support for IP Traceback”

by Savage et al. Status:

Lots of RFCs But still not ?yet? deployed…

Network address translation (NAT)Also known as

Network masquerading IP masquerading

Re-writes source and/or destination address as they pass through NAT gateway

Why IPv4 address shortage Standard feature Some believe it enhances privacy, security, …

Presenter
Presentation Notes
Form wikipedia

29

Simple NAT

NAT

(Private IP addresses)

(Public IP addresses)

Main Internet

(Public IP addresses)

30

Multiple NAT

ISPNAT

(Private IP addresses)

(Public IP addresses)

Main Internet

ISP network

HomeNAT

Home network

10.0.0.12

192.168.2.12

192.168.2.99

156.148.70.32

31

NAT traversal: Relay

NAT

Main Internet

Local network

NAT

Local network

10.0.0.12192.168.2.99

Relay S

host A

host B

12

Presenter
Presentation Notes
Relaying is the simplest way to traverse a NAT and probably the only solution when both host A and host B are behind a NAT/Firewall. This solution assumes that hosts can initiate a connection (UDP or TCP) to a public relay server. Some system admin can disable all outgoing traffic except HTTP to port 80 and in some cases hosts are only allowed to browse the web connecting to a HTTP proxy. Host A establishes a TCP connection to relay S 2. Host B establishes a TCP connection to relay S Now A and B can exchange traffic because relay S can bounce data back and forth. This solution is robust and fully functional but has the big disadvantage of involving S. In case of large data transfer between A and B the server S has a large workload.

32

NAT traversal: Connection reversal

NAT

Main Internet

Local network

1.1.1.4

192.168.2.99

rendezvous S

host A

host B

12

3

Presenter
Presentation Notes
Connection reversal works if at least one of the hosts is reachable in the public address space. For instance, if host B wants to get a connection with host A behind the NAT/Firewall. Host A connects to server S. Now S can send messages to host A Host B connects to server S. host B asks server S to forward a message to host A “please connect to me 1.1.1.4” Host A connects to host B.

33

TURN protocol Protocol for UDP/TCP relaying behind NAT Data is bounced to a public TURN server No hole punching TURN works even behind symmetric NAT

Hole punchingTechnique to allow traffic from/to a host behind a

firewall/NAT without collaboration of the NAT itselfUDP: simpleTCP:

Berkeley sockets allows TCP socket to initiate an outgoing or listen for an incoming connections but not both

Solution: bind multiple sockets to same local endpoint

35

STUN (RFC 3489) Defines operations and message formats to

understand type of NAT Discovers presence and type of NAT and firewalls

between them and Internet Allows applications to determine their public NAT

IP address

Presenter
Presentation Notes
A support to hole punching is given by the STUN protocol. STUN is “a lightweight protocol that allows applications to discover the presence and types of Network Address Translators and firewalls between them and the public Internet. It also provides the ability for applications to determine the public IP addresses allocated to them by the NAT. STUN works with many existing NATs, and does not require any special behavior from them. As a result, it allows a wide variety of applications to work through existing NAT infrastructure.” From http://www.networksorcery.com/enp/protocol/stun.htm

36

STUNT Simple Traversal of UDP Through NATs and TCP

too (STUNT) Extends STUN to include TCP functionality

Presenter
Presentation Notes
From http://nutss.gforge.cis.cornell.edu/stunt.php

NAT traversal: Cooperating NATSOCKS

Client server protocol Enables client (behind firewall) to use server

(in public Internet) Relays trafficWidely adopted

• E.g.: Mozilla can use SOCKS

40

NAT traversal: UPnP Defines:

Internet Gateway Device (IGD) protocol Enables:

Learning of ones public (external) IP address Enumeration of existing port mappings Adding and removing port mappings Assigning lease times to mappings Applications to automatically configure NAT routing

Presenter
Presentation Notes
“Microsoft has a broad strategy of having devices when they are brought into a LAN, they can be queried as to their functionality and services. Ultimately, they expect such items as thermostats and clocks to be network capable. Having devices and services cooperate with PC's is the goal of the UPnP organization, which is lead by Microsoft.  Universal Plug and Play is a set of protocols and API's that allow the devices to interoperate” […] a firewall is such a device on the network. Manufacturers are beginning to offer firewalls that offer UPnP capability. One of the solutions to the NAT problem described above is called NAT Traversal. This allows for applications to programmatically control functions within a UPnP capable Firewall.  Microsoft has included API's for UPnP and for NAT Traversal in Windows XP.”   (From http://www.knoxscape.com/Upnp/NAT.htm) The protocol is called Internet Gateway Device and is available in [1] [1] http://www.upnp.org/standardizeddcps/igd.asp

top related