Firewalls. Objectives and Deliverable Understand the concept of firewalls and the three major...

53
Firewalls Firewalls

Transcript of Firewalls. Objectives and Deliverable Understand the concept of firewalls and the three major...

FirewallsFirewalls

Objectives and Objectives and DeliverableDeliverable

Understand the concept of firewalls Understand the concept of firewalls and the three major categories: and the three major categories: packet filters (stateless vs. stateful) packet filters (stateless vs. stateful) and application level proxyand application level proxy

Can apply them to detect different Can apply them to detect different attacksattacks

Be able to write the stateless packet Be able to write the stateless packet filter rulesfilter rules

What is a Firewall?What is a Firewall?

A A choke pointchoke point of control and monitoring of control and monitoring Interconnects networks with differing trustInterconnects networks with differing trust Imposes restrictions on network servicesImposes restrictions on network services

only authorized traffic is allowed only authorized traffic is allowed Auditing and controlling accessAuditing and controlling access

can implement alarms for abnormal behaviorcan implement alarms for abnormal behavior Itself immune to penetrationItself immune to penetration Provides Provides perimeter defenceperimeter defence

Classification of FirewallClassification of FirewallCharacterized by protocol level it Characterized by protocol level it

controls incontrols in Packet filteringPacket filtering Circuit gatewaysCircuit gateways Application gatewaysApplication gateways

Firewalls – Packet FiltersFirewalls – Packet Filters

Firewalls – Packet FiltersFirewalls – Packet Filters Simplest of components Simplest of components Uses transport-layer information onlyUses transport-layer information only

IP Source Address, Destination AddressIP Source Address, Destination Address Protocol/Next Header (TCP, UDP, ICMP, etc)Protocol/Next Header (TCP, UDP, ICMP, etc) TCP or UDP source & destination portsTCP or UDP source & destination ports TCP Flags (SYN, ACK, FIN, RST, PSH, etc)TCP Flags (SYN, ACK, FIN, RST, PSH, etc) ICMP message typeICMP message type

ExamplesExamples DNS uses port 53DNS uses port 53

No incoming port 53 packets except known trusted No incoming port 53 packets except known trusted serversservers

Usage of Packet FiltersUsage of Packet Filters Filtering with incoming or outgoing Filtering with incoming or outgoing

interfacesinterfaces E.g., Ingress filtering of spoofed IP E.g., Ingress filtering of spoofed IP

addressesaddresses Egress filteringEgress filtering

Permits or denies certain servicesPermits or denies certain services Requires intimate knowledge of TCP and Requires intimate knowledge of TCP and

UDP port utilization on a number of UDP port utilization on a number of operating systemsoperating systems

How to Configure a How to Configure a Packet FilterPacket Filter

Start with a security policyStart with a security policy Specify allowable packets in terms of Specify allowable packets in terms of

logical expressions on packet fieldslogical expressions on packet fields Rewrite expressions in syntax Rewrite expressions in syntax

supported by your vendorsupported by your vendor General rules - least privilegeGeneral rules - least privilege

All that is not expressly permitted is All that is not expressly permitted is prohibitedprohibited

If you do not need it, eliminate itIf you do not need it, eliminate it

Every ruleset is followed by an Every ruleset is followed by an implicit rule reading like this.implicit rule reading like this.

Example 1: Example 1:

Suppose we want to allow inbound Suppose we want to allow inbound mail (SMTP, port 25) but only to our mail (SMTP, port 25) but only to our

gateway machine. Also suppose gateway machine. Also suppose that traffic from some particular that traffic from some particular

site SPIGOT is to be blocked.site SPIGOT is to be blocked.

Solution 1: Solution 1:

Example 2: Example 2:

Now suppose that we want to Now suppose that we want to implement the policy “any inside implement the policy “any inside

host can send mail to the outside”.host can send mail to the outside”.

Solution 2: Solution 2:

This solution allows calls to come This solution allows calls to come from any port on an inside machine, from any port on an inside machine, and will direct them to port 25 on and will direct them to port 25 on

the outside. Simple enough…the outside. Simple enough…

So why is it wrong?So why is it wrong?

Our defined restriction is based solely Our defined restriction is based solely on the outside host’s port number, on the outside host’s port number, which we have no way of controlling.which we have no way of controlling.

Now an enemy can access any internal Now an enemy can access any internal machines and port by originating his machines and port by originating his call from port 25 on the outside call from port 25 on the outside machine.machine.

What can be a better solution ?What can be a better solution ?

The ACK signifies that the packet is The ACK signifies that the packet is part of an ongoing conversationpart of an ongoing conversation

Packets without the ACK are Packets without the ACK are connection establishment messages, connection establishment messages, which we are only permitting from which we are only permitting from internal hostsinternal hosts

Security & Performance of Security & Performance of Packet FiltersPacket Filters

Tiny fragment attacksTiny fragment attacks Split TCP header info over several tiny Split TCP header info over several tiny

packetspackets Either discard or reassemble before checkEither discard or reassemble before check

Degradation depends on number of rules Degradation depends on number of rules applied at any pointapplied at any point

Order rules so that most common traffic Order rules so that most common traffic is dealt with firstis dealt with first

Correctness is more important than Correctness is more important than speedspeed

Port NumberingPort Numbering TCP connectionTCP connection

Server port is number less than 1024 Server port is number less than 1024 Client port is number between 1024 and 16383Client port is number between 1024 and 16383

Permanent assignmentPermanent assignment Ports <1024 assigned permanently Ports <1024 assigned permanently

20,21 for FTP 23 for Telnet20,21 for FTP 23 for Telnet 25 for server SMTP 80 for HTTP25 for server SMTP 80 for HTTP

Variable useVariable use Ports >1024 must be available for client to make Ports >1024 must be available for client to make

any connectionany connection This presents a limitation for stateless packet This presents a limitation for stateless packet

filteringfiltering If If client wants to use port 2048, firewall must allow client wants to use port 2048, firewall must allow

incoming incoming traffic on this porttraffic on this port Better: stateful filtering knows outgoing requestsBetter: stateful filtering knows outgoing requests

Firewalls – Stateful Packet Firewalls – Stateful Packet FiltersFilters

Traditional packet filters do not Traditional packet filters do not examine transport layer contextexamine transport layer context ie matching return packets with outgoing ie matching return packets with outgoing

flowflow Stateful packet filters address this needStateful packet filters address this need They examine each IP packet in contextThey examine each IP packet in context

Keep track of client-server sessionsKeep track of client-server sessions Check each packet validly belongs to oneCheck each packet validly belongs to one

Hence are better able to detect bogus Hence are better able to detect bogus packets out of context packets out of context

Stateful FilteringStateful Filtering

Firewall OutlinesFirewall Outlines Packet filteringPacket filtering Application gatewaysApplication gateways Circuit gatewaysCircuit gateways

Firewall GatewaysFirewall Gateways Firewall runs set of proxy programsFirewall runs set of proxy programs

Proxies filter incoming, outgoing packetsProxies filter incoming, outgoing packets All incoming traffic directed to firewall All incoming traffic directed to firewall All outgoing traffic appears to come from All outgoing traffic appears to come from

firewallfirewall Policy embedded in proxy programsPolicy embedded in proxy programs Two kinds of proxiesTwo kinds of proxies

Application-level gateways/proxiesApplication-level gateways/proxies Tailored to http, ftp, smtp, etc.Tailored to http, ftp, smtp, etc.

Circuit-level gateways/proxiesCircuit-level gateways/proxies Working on TCP levelWorking on TCP level

Firewalls - Firewalls - Application Application Level Gateway (or Proxy)Level Gateway (or Proxy)

Application-Level Application-Level FilteringFiltering

Has full access to protocol Has full access to protocol user requests service from proxy user requests service from proxy proxy validates request as legal proxy validates request as legal then actions request and returns result to then actions request and returns result to

user user Need separate proxies for each service Need separate proxies for each service

E.g., SMTP (E-Mail)E.g., SMTP (E-Mail) NNTP (Net news)NNTP (Net news) DNS (Domain Name System)DNS (Domain Name System) NTP (Network Time Protocol)NTP (Network Time Protocol) custom services generally not supportedcustom services generally not supported

App-level Firewall App-level Firewall ArchitectureArchitecture

Daemon spawns proxy when communication detectedDaemon spawns proxy when communication detected

Network Connection

Telnet daemon

SMTP daemon

FTP daemon

Telnet

proxy

FTP proxy SMTP

proxy

Enforce policy for specific Enforce policy for specific protocolsprotocols

E.g., Virus scanning for SMTPE.g., Virus scanning for SMTP Need to understand MIME, encoding, Zip archivesNeed to understand MIME, encoding, Zip archives

Where to Deploy App-level Where to Deploy App-level FirewallFirewall

Bastion Host: highly secure host system Bastion Host: highly secure host system Potentially exposed to "hostile" elements Potentially exposed to "hostile" elements Hence is secured to withstand this Hence is secured to withstand this

Disable all non-required services; keep it Disable all non-required services; keep it simplesimple

Runs circuit / application level gateways Runs circuit / application level gateways Install/modify services you wantInstall/modify services you want

Or provides externally accessible Or provides externally accessible services services

Screened Host Screened Host ArchitectureArchitecture

Screened Subnet Using Two Screened Subnet Using Two RoutersRouters

Firewalls Aren’t Perfect?Firewalls Aren’t Perfect? Useless against attacks from the Useless against attacks from the

insideinside Evildoer exists on insideEvildoer exists on inside Malicious code is executed on an internal Malicious code is executed on an internal

machinemachine Organizations with greater insider Organizations with greater insider

threatthreat Banks and MilitaryBanks and Military

Cannot protect against transfer of all Cannot protect against transfer of all virus infected programs or filesvirus infected programs or files because of huge range of O/S & file typesbecause of huge range of O/S & file types

QuizQuiz In this question, we explore some applications In this question, we explore some applications

and limitations of a packet filtering firewall. For and limitations of a packet filtering firewall. For each of the question, briefly explain 1) can each of the question, briefly explain 1) can stateless firewall be configured to defend against stateless firewall be configured to defend against the attack and how? the attack and how?

2) if not, what about stateful firewall ? 2) if not, what about stateful firewall ?

3) if neither can, what about application-level 3) if neither can, what about application-level proxy?proxy?

Can the firewall prevent a SYN flood attack from the Can the firewall prevent a SYN flood attack from the external network?external network?

Can the firewall prevent a Smurf attack from the Can the firewall prevent a Smurf attack from the external network? Basically, the Smurf attack uses the external network? Basically, the Smurf attack uses the broadcast IP address of the subnet.broadcast IP address of the subnet.

Can the firewall block P2P applications, e.g., Can the firewall block P2P applications, e.g., BitTorrent?BitTorrent?

Backup SlidesBackup Slides

Firewalls - Firewalls - Circuit Level Circuit Level GatewayGateway

Relays two TCP connectionsRelays two TCP connections Imposes security by limiting which Imposes security by limiting which

such connections are allowedsuch connections are allowed Once created usually relays traffic Once created usually relays traffic

without examining contentswithout examining contents Typically used when trust internal Typically used when trust internal

users by allowing general outbound users by allowing general outbound connectionsconnections

SOCKS commonly used for thisSOCKS commonly used for this

Firewall OutlinesFirewall Outlines Packet filteringPacket filtering Application gatewaysApplication gateways Circuit gatewaysCircuit gateways

Combination of above is dynamic Combination of above is dynamic packet filterpacket filter

Dynamic Packet FiltersDynamic Packet Filters

Most commonMost common Provide good administrators Provide good administrators

protection and full transparencyprotection and full transparency Network given full control over Network given full control over

traffictraffic Captures semantics of a connectionCaptures semantics of a connection

1.2.3.4

Intended connection from 1.2.3.4 to 5.6.7.8

5.6.7.81.2.3.45.6.7.8

Firewall

Redialing on a dynamic packet filter. The dashed arrow shows the intended connection; the solid arrows show the actual connections, to and from the relay in the firewall box. The Firewall impersonates each endpoint to the other.

1.2.3.45.6.7.810.11.12.135.6.7.8

ApplicationProxy

Firewall

Intended connection from 1.2.3.4 to 5.6.7.8

A dynamic packet filter with an application proxy. Note the change in source address

Figure 9.2: A firewall router with multiple internal networks.

Filter Rule: Open access to Net 2 means source address from Net 3

• Why not spoof address from Net 3?

Network TopologyNetwork Topology

Address-SpoofingAddress-Spoofing

Detection is virtually impossible Detection is virtually impossible unless source-address filtering and unless source-address filtering and logging are donelogging are done

One should not trust hosts outside of One should not trust hosts outside of one’s administrative controlone’s administrative control

External Interface External Interface RulesetRuleset

Allow outgoing calls, permit incoming Allow outgoing calls, permit incoming calls only for mail and only to gateway GWcalls only for mail and only to gateway GW

Note: Specify GW as destination host instead of Net 1 to prevent open access to Net 1

Net 1 Router Interface Net 1 Router Interface RulesetRuleset

Gateway machine speaks directly only to Gateway machine speaks directly only to other machines running trusted mail other machines running trusted mail server softwareserver software

Relay machines used to call out to GW Relay machines used to call out to GW to pick up waiting mailto pick up waiting mail

Note: Spoofing is avoided with the specification of GW

How Many Routers Do We How Many Routers Do We Need?Need?

If routers only support outgoing filtering, we If routers only support outgoing filtering, we need two:need two: One to use ruleset that protects against One to use ruleset that protects against

compromised gatewayscompromised gateways One to use ruleset that guards against address One to use ruleset that guards against address

forgery and restricts access to gateway machineforgery and restricts access to gateway machine An input filter on one port is exactly An input filter on one port is exactly

equivalent to an output filter on the other portequivalent to an output filter on the other port If you trust the network provider, you can go If you trust the network provider, you can go

without input filterswithout input filters Filtering can be done on the output side of the Filtering can be done on the output side of the

routerrouter

Routing FiltersRouting Filters

All nodes are somehow reachable from the All nodes are somehow reachable from the InternetInternet

Routers need to be able to control what Routers need to be able to control what routes they advertise over various routes they advertise over various interfacesinterfaces

Clients who employ IP source routing make Clients who employ IP source routing make it possible to reach ‘unreachable’ hostsit possible to reach ‘unreachable’ hosts Enables address-spoofingEnables address-spoofing Block source routing at borders, not at Block source routing at borders, not at

backbonebackbone

Routing Filters (cont)Routing Filters (cont)

Packet filters obviate the need for route Packet filters obviate the need for route filtersfilters

Route filtering becomes difficult or Route filtering becomes difficult or impossible in the presence of complex impossible in the presence of complex technologiestechnologies

Route squatting – using unofficial IP Route squatting – using unofficial IP addresses inside firewalls that belong to addresses inside firewalls that belong to someone elsesomeone else

Difficult to choose non-addressed address Difficult to choose non-addressed address spacespace

Firewall OutlinesFirewall Outlines Packet filteringPacket filtering Application gatewaysApplication gateways Circuit gatewaysCircuit gateways

Combination of above is dynamic Combination of above is dynamic packet filterpacket filter

Firewalls - Firewalls - Circuit Level Circuit Level GatewayGateway

Figure 9.7: A typical SOCKS connection through interface A, and rogue connection through the external interface, B.

Dual Homed Host Dual Homed Host ArchitectureArchitecture

Asymmetric RoutesAsymmetric Routes

Both sides of the firewall know Both sides of the firewall know nothing of one another’s topologynothing of one another’s topology

Solutions:Solutions: Maintain full knowledge of the topologyMaintain full knowledge of the topology

Not feasible, too much state to keepNot feasible, too much state to keep Multiple firewalls share state Multiple firewalls share state

informationinformation Volume of messages may be prohibitive, Volume of messages may be prohibitive,

code complexitycode complexity

Are Dynamic Packet Are Dynamic Packet Filters Safe?Filters Safe?

Comparable to that of circuit gateways, Comparable to that of circuit gateways, as long as the implementation strategy as long as the implementation strategy is simpleis simple

If administrative interfaces use physical If administrative interfaces use physical network ports as the highest-level network ports as the highest-level constructconstruct Legal connections are generally defined in Legal connections are generally defined in

terms of the physical topologyterms of the physical topology Not if evildoers exist on the insideNot if evildoers exist on the inside

Circuit or application gateways demand Circuit or application gateways demand user authentication for outbound traffic and user authentication for outbound traffic and are therefore more resistant to this threatare therefore more resistant to this threat

Distributed FirewallsDistributed Firewalls A central management node sets the security A central management node sets the security

policy enforced by individual hostspolicy enforced by individual hosts Combination of high-level policy specification Combination of high-level policy specification

with file distribution mechanismwith file distribution mechanism Advantages:Advantages:

Lack of central point of failureLack of central point of failure Ability to protect machines outside topologically Ability to protect machines outside topologically

isolated spaceisolated space Great for laptopsGreat for laptops

Disadvantage:Disadvantage: Harder to allow in certain services, whereas it’s Harder to allow in certain services, whereas it’s

easy to blockeasy to block

Distributed Firewalls Distributed Firewalls DrawbackDrawback

Allowing in certain services works if Allowing in certain services works if and only if you’re sure the address and only if you’re sure the address can’t be spoofedcan’t be spoofed Requires anti-spoofing protectionRequires anti-spoofing protection Must maintain ability to roam safelyMust maintain ability to roam safely

Solution: IPsecSolution: IPsec A machine is trusted if and only if it can A machine is trusted if and only if it can

perform proper cryptographic perform proper cryptographic authenticationauthentication

Where to Filter?Where to Filter?

Balance between risk and costsBalance between risk and costs Always a higher layer that is hard to Always a higher layer that is hard to

filterfilter HumansHumans

Dynamic Packet Filter Dynamic Packet Filter ImplementationImplementation

Dynamically update packet filter’s Dynamically update packet filter’s rulesetruleset Changes may not be benign due to orderingChanges may not be benign due to ordering

Redialing method offers greater Redialing method offers greater assurance of securityassurance of security No special-case code necessaryNo special-case code necessary FTP handled with user-level daemonFTP handled with user-level daemon UDP handled just as TCP except for tear UDP handled just as TCP except for tear

downdown ICMP handled with pseudoconnections and ICMP handled with pseudoconnections and

synthesized packetssynthesized packets

Per-Interface Tables Per-Interface Tables Consulted by Dynamic Consulted by Dynamic

Packet FilterPacket Filter Active Connection TableActive Connection Table

Socket structure decides whether data is Socket structure decides whether data is copied to outside socket or sent to copied to outside socket or sent to application proxyapplication proxy

Ordinary Filter TableOrdinary Filter Table Specifies which packets may pass in Specifies which packets may pass in

stateless mannerstateless manner Dynamic TableDynamic Table

Forces creation of local socket structuresForces creation of local socket structures