Lecture 7 CMP4103 Computer Network Security - Firewalls
Lecture 7 CMP4103 Computer Network Security - Firewalls
Lecture 7 CMP4103 Computer Network Security - Firewalls
Network Security
Due on February 3, 2011
Jordi Nin
1
Firewalls Viruses PPS
2 - Network Security
Jordi Nin
nin@ac.upc.edu
Contents
Contents
Definition
Possible Attacks
Preliminary Definitions
Types of Firewall
Contents
Desktop PC
Internet
Switch or Hub
Firewall
NetWare Server
The firewall takes care of passing packets that pass its filtering rules
between the internal network and the Internet, and vice versa. The two
”homes” refer to the two networks that the firewall is part of - one
interface connected to the outside network, and the other connected to
the inside network
Jordi Nin 2 - Network Security and Protection
Firewalls Viruses PPS Introduction Topologies Rules Proxy
Desktop PC
Public Network Internal Network
Internet
Switch or Hub Switch or Hub
Firewall
DMZ Zone
Netware Server
Public Webserver Public Mailserver
Desktop PC
Internal Network 2
Internet
Switch or Hub
Firewall 1 Firewall 2
ppp dialup
Internal
Network 1
DMZ Zone
Desktop PC • Advantages:
Internal Network 2
DMZ IP
Internet
Switch or Hub masquerade is
Firewall possible, only one
Internal public IP address
Network 1
is needed
Switch or Hub Netware Server
• Drawbacks: one
extra net card →
DMZ Zone
additional
Public Webserver Public Mailserver
complexity
Contents
Filtering Rules
Wildcards
Example
• 145.34.5.6 0.0.0.0 → host 145.34.5.6
• 145.34.5.6 255.255.255.255 → ANY
• 145.34.5.6 0.0.0.255 → 145.34.5.0/24
Firewall
Example
Internal hosts only access to WWW service and nothing else
• Rule set 1:
• iprule 1 permit -p TCP -i eth1 -o eth0 -dport 80
• iprule 2 deny -i eth1 -o eth0
• iprule 3 permit
Firewall
Example
Internal hosts only access to WWW service and nothing else
• Rule set 1:
• iprule 1 permit -p TCP -i eth1 -o eth0 -dport 80
• iprule 2 deny -i eth1 -o eth0
• iprule 3 permit
• Rule set 2:
• iprule 1 permit -p TCP -i eth0 -o eth1 -sport 80
• iprule 2 deny -i eth0 -o eth1
• iprule 3 permit
Rule Order
Rules are only checked until a packet matches!
Rule set 2
• iprule 1 permit -p IP
• iprule 2 deny -p ICMP
Rule Order
Rules are only checked until a packet matches!
Rule set 2
• iprule 1 permit -p IP
• iprule 2 deny -p ICMP
The first rule set rejects all the ICMP packets while they are
accepted with the second set (IP includes ICMP)
Jordi Nin 2 - Network Security and Protection
Firewalls Viruses PPS Introduction Topologies Rules Proxy
Types of NAT
NAT is out of the scope of this subject... just a small reminder
Address classification
• Inside local address: internal IP address in the internal
network
• Inside global address: internal IP address in the Internet
• Outside local address: external IP address in the internal
network
• Outside global address: external IP address in the Internet
Types of NAT
NAT is out of the scope of this subject... just a small reminder
Types of NAT
NAT is out of the scope of this subject... just a small reminder
• dynamic NAT: a set of global addresses are dynamically
assigned. An Internal host has a different IP each time it
accesses to the Internet
Creation of a global address set:
ip nat pool name start-@ end-@
Access-list to identify the addresses to be translated:
access-list id permit network wildcard
Mapping of dynamic NAT:
ip nat inside source list id pool name
Definition of the internal / external interfaces:
ip nat inside network-interface
ip nat outside network-interface
Jordi Nin 2 - Network Security and Protection
Types of NAT
NAT is out of the scope of this subject... just a small reminder
• PAT: All internal hosts share the same internal global IP,
ports are modified to avoid collisions
Access-list to identify the addresses to be translated:
access-list id permit network wildcard
Mapping of dynamic NAT:
ip nat inside source list id interface name
overload
Definition of the internal / external interfaces:
ip nat inside network-interface
ip nat outside network-interface
Contents
Description
a proxy server is a server that acts as an intermediary for requests from
clients seeking resources from other servers
General procedure
1 A client connects to the proxy server, requesting a service (a file or
web page) available from a different server
2 The proxy server evaluates the request according to its filtering rules
3 If the request is validated by the filter, the proxy provides the
resource by connecting to the relevant server and requesting the
service on behalf of the client
Possible Applications
Contents
Historical evolution
Economic cost
Why?
• Inactivity time due to the infection
• Cost of the cleaning time
• Cost of the counter measures (Antivirus)
Virus
A virus is a code fragment that copies itself into a larger
program, modifying that program and depending on it. A virus
executes only when its host program begins to run. The virus
then replicates itself, infecting other programs as it reproduces
Worm
A worm is an independent program that reproduces by copying
itself from one computer to another, usually over a network.
Unlike a virus, a worm keeps its independence; it usually
doesn’t modify other programs
Trojan horses
A Trojan horse is a code fragment that hides inside a program
and performs a disguised function
Example
• A Trap door is a mechanism built into a system by its
designer. Its function is to give the designer a way to
sneak back into the system, circumventing normal system
protection
• A Masquerade is a generic name for a program that
tricks an unsuspecting user into giving away privileges.
• A Spoof is a technique used for misdirection and
concealment (to hide). For instance, a communication
that the sender wishes to transmit anonymously is tagged
with a false return address
Jordi Nin 2 - Network Security and Protection
Malware Categories
Contents
Viruses Schema
A virus has two components:
• Replication: The survival of a virus is based in its ability to
reproduce
Viruses Schema
A virus has two components:
• Replication: The survival of a virus is based in its ability to
reproduce ... So how do I make a program reproduce? ...
Viruses Schema
A virus has two components:
• Replication: The survival of a virus is based in its ability to
reproduce ... So how do I make a program reproduce? ...
Easy, the simplest common viruses infect .com (DOS executables)
files. This file format always have code starting at address 0x100,
so the virus attaches itself to the end of the file and replace the
instruction at 0x100 with a jump to its start address. Thus, the
viral code would execute whenever the file is run; then it looks for
other, uninfected, .com files and infect them
Viruses Schema
A virus has two components:
• Replication: The survival of a virus is based in its ability to
reproduce ... So how do I make a program reproduce? ...
Easy, the simplest common viruses infect .com (DOS executables)
files. This file format always have code starting at address 0x100,
so the virus attaches itself to the end of the file and replace the
instruction at 0x100 with a jump to its start address. Thus, the
viral code would execute whenever the file is run; then it looks for
other, uninfected, .com files and infect them
• Payload: It is usually activated just after the replication step or by
a trigger, such as a date, and it performs a set of bad things like:
Viruses Schema
A virus has two components:
• Replication: The survival of a virus is based in its ability to
reproduce ... So how do I make a program reproduce? ...
Easy, the simplest common viruses infect .com (DOS executables)
files. This file format always have code starting at address 0x100,
so the virus attaches itself to the end of the file and replace the
instruction at 0x100 with a jump to its start address. Thus, the
viral code would execute whenever the file is run; then it looks for
other, uninfected, .com files and infect them
• Payload: It is usually activated just after the replication step or by
a trigger, such as a date, and it performs a set of bad things like:
• Make changes to the machines protection state
• Make changes to user data (e.g. trash the disk)
• Lock the network (e.g. start replicating at maximum speed)
• Steal resources for some not allowed tasks (e.g. use the CPU
for DES keysearch)
Jordi Nin 2 - Network Security and Protection
Firewalls Viruses PPS Introduction Logic Antivirus
Viruses Schema
Graphical Description
buffer
jmp
com file com file virus
length length
original
jmp v1
jmp
length
Contents
General Description
Signature problem!
Signature problem!
Zero Day problem: It occurs when a user finds a new virus before
the publisher discovers it and can issue an updated signature.
Mutation examples
• a dummy mutation:
Mutation examples
• a dummy mutation:
• using a NOT gate (inverter), v = NOT (v ) → 0010110
becomes 1101001, we have to add the code to undo the
NOT just as the first virus instruction
Mutation examples
• a dummy mutation:
• using a NOT gate (inverter), v = NOT (v ) → 0010110
becomes 1101001, we have to add the code to undo the
NOT just as the first virus instruction
• not so dummy but still simple mutation:
Mutation examples
• a dummy mutation:
• using a NOT gate (inverter), v = NOT (v ) → 0010110
becomes 1101001, we have to add the code to undo the
NOT just as the first virus instruction
• not so dummy but still simple mutation:
• generate a random variable and use a XOR gate
key db 1 dup(01101001) and XOR(v , key ) → v �
Mutation examples
• a dummy mutation:
• using a NOT gate (inverter), v = NOT (v ) → 0010110
becomes 1101001, we have to add the code to undo the
NOT just as the first virus instruction
• not so dummy but still simple mutation:
• generate a random variable and use a XOR gate
key db 1 dup(01101001) and XOR(v , key ) → v �
Heuristic Search
Heuristic scanning looks for certain instructions or commands
within a program that are not found in typical applications. As
a result, a heuristic engine is able to detect potentially
malicious functionality in new (unexamined) malicious
functionality such as the replication mechanism of a virus
Heuristic Search
Heuristic scanning looks for certain instructions or commands
within a program that are not found in typical applications. As
a result, a heuristic engine is able to detect potentially
malicious functionality in new (unexamined) malicious
functionality such as the replication mechanism of a virus
Classification of HS methods
• weight-based systems rate every functionality that is
detected with a certain weight according to the degree of
danger it may pose. If the sum of those weights reaches a
certain threshold, an alarm is triggered (Quite old system)
• rule-based systems extract certain rules from a file and
this rules are compared against a set of rules for malicious
code. If there matches a rule, an alarm is triggered
Virtual Sandbox
to determine what actions a program performs, most heuristic
scanners uses a sandboxed virtual machine
Virtual Sandbox
to determine what actions a program performs, most heuristic
scanners uses a sandboxed virtual machine
↓
when a user starts a program, the scanner launches it inside
the virtual machine. If no virus-like behavior is observed, the
program is allowed to start normally; if yes, the user is asked
whether the file is to be cleaned, deleted or quarantined
↓
modern scanners can detect new viruses for without signature
Virtual Sandbox
to determine what actions a program performs, most heuristic
scanners uses a sandboxed virtual machine
↓
when a user starts a program, the scanner launches it inside
the virtual machine. If no virus-like behavior is observed, the
program is allowed to start normally; if yes, the user is asked
whether the file is to be cleaned, deleted or quarantined
↓
modern scanners can detect new viruses for without signature
problem: heuristic scanning is computationally intensive
reducing computers performance
1 variable/memory emulator
2 parser
3 flow analyzer
4 analyzer
5 disassembler/emulator
6 weight-based system and/or rule based system
1 variable/memory emulator
2 parser
3 flow analyzer
4 analyzer
5 disassembler/emulator
6 weight-based system and/or rule based system
1 variable/memory emulator
2 parser
3 flow analyzer
4 analyzer
5 disassembler/emulator
6 weight-based system and/or rule based system
1 variable/memory emulator
2 parser
3 flow analyzer
4 analyzer
5 disassembler/emulator
6 weight-based system and/or rule based system
Main loop:
1 Extract one instruction
1 variable/memory emulator
2 parser
3 flow analyzer
4 analyzer
5 disassembler/emulator
6 weight-based system and/or rule based system
Alternative to Antivirus
Hot News
Contents
Contents
IPSec is the most commonly used network layer security control. IPsec is
a framework of open standards for ensuring private communications over
IP networks. Depending on its implementation, it can provide any
combination of the following types of protection:
IPSec is the most commonly used network layer security control. IPsec is
a framework of open standards for ensuring private communications over
IP networks. Depending on its implementation, it can provide any
combination of the following types of protection:
VPN Advantages
Contents
Gateway-to-Gateway Architecture
IPsec-based VPNs are often used to provide secure network
communications between two networks by deploying a VPN gateway onto
each network and establishing a VPN connection between them.
This is the easiest VPN model to implement, in terms of user and host
management
Host-to-Gateway Architecture
IPsec connections are created as needed for each individual VPN user.
The user is typically asked by the VPN gateway to authenticate before
the connection can be established
Host-to-Host Architecture
This is the least commonly used VPN architecture. It is typically used for
special purpose needs, such as system administrators performing remote
management of a single server.
This model is the only one that provides protection for data throughout
its transit. This can be a problem, because packet firewalls, IDS, and
other devices cannot be placed to inspect the decrypted data, which
effectively circumvents certain layers of security
Model Comparison
Contents
IPSec Components
Main protocols
• Authentication Header (AH). It provides integrity for
packets headers
• Encapsulating Security Payload (ESP). It provides
authentication and encryption services
• Internet Key Exchange (IKE). It negotiates, creates
and manges security associations (AS)
AH Modes
The recipient can then regenerate the hash using the shared
key and confirm that the two hashes match, providing integrity
protection for the packet
Jordi Nin 2 - Network Security and Protection
NAT Problems
AH Header
Next Header Payload Length Reserved
Security Parameters Index
Sequence Number
Authentication Information
• Next Header. It contains the IP protocol number for the next packet payload.
In tunnel mode, the payload is an IP packet, so the Next Header value is set to
4 for IP-in-IP. In transport mode, the payload is usually a transport-layer
protocol, often TCP (6) or UDP (17)
• Payload Length. This field contains the length of the payload in 4-byte
increments, minus 2
• Reserved. This value is reserved for future use, so it should be set to 0
• Security Parameters Index (SPI). Each endpoint has an arbitrarily chosen SPI
value, which acts as a unique identifier for the connection. The recipient uses
the SPI value, along with the destination IP address and (optionally) the IPsec
protocol type to determine which Security Association (SA) is being used
• Sequence Number. Each packet is assigned a sequential sequence number, and
only packets within a sliding window of sequence numbers are accepted. This
provides protection against replay attacks
• Authentication Information. This field contains the MAC output
Jordi Nin 2 - Network Security and Protection
Firewalls Viruses PPS Introduction VPN Achitectures IPSec Examples
How AH works
Example
How AH works
Example
AH header for the first four packets in an AH session between A and B
• SPI. A uses the hex value cdb59934 for the SPI in its packets, while host B
uses the hex value a6b32c00 for the SPI in its packets. An AH connection is
composed of two one-way connections, each with its own SPI
• SequenceNumber. Both hosts initially set the sequence number to 1, and both
incremented the number to 2 for their second packets
• Authentication Information. The authentication (integrity protection)
information, a keyed hash based on the bytes in the packet, is different in each
packet. It should be different even if only one byte in a hashed section changes
Jordi Nin 2 - Network Security and Protection
Firewalls Viruses PPS Introduction VPN Achitectures IPSec Examples
ESP Modes
• Tunnel mode: It creates a new IP header for each packet. The new IP header
lists the endpoints of the ESP tunnel as the source and destination of the
packet.
It can encrypt and/or protect the integrity of both the data and the original IP
header. Encrypting the data protects it from being accessed or modified by
unauthorized parties; encrypting the IP header conceals the nature of the
communications, such as the actual source or destination of the packet. If
authentication is being used for integrity protection, each packet will have an
ESP Authentication section after the ESP trailer
ESP Modes
• Transport mode: it uses the original IP header instead of creating a new one.
It can only encrypt and/or protect the integrity of packet payloads and certain
ESP components, but not IP headers. As with AH, ESP transport mode is
generally only used in host-to-host architectures. Also, transport mode is
incompatible with NAT
Encryption Process
The third part of the packet is the ESP trailer, which contains
• Padding. An ESP packet may optionally contain padding, which is additional
bytes of data that make the packet larger and are discarded by the packets
recipient. Because ESP uses block ciphers for encryption, padding may be
needed so that the encrypted data is an integral multiple of the block size
• Padding Length. This number indicates how many bytes long the padding is
• Next Header. In tunnel mode, the payload is an IP packet, so the Next Header
value is set to 4 for IP-in-IP. In transport mode, the payload is usually a
transport-layer protocol, often TCP (6) or UDP (17)
Example
Example
ESP header for the first four packets in an AH session between
A and B
The SPI and Sequence Number fields work the same way in
ESP that they do in AH.
Contents