1/76
Looks like no tags are added yet.
What is a firewall?
A security measure that prevents unauthorized electronic access to a networked system by filtering traffic between a private network and a public network
Firewall analogy
Like a firewall in building construction: it isolates one network or compartment from another
Physical setup of a boundary firewall
A machine that all wires from outside and inside connect to so ALL traffic passes through it and gets allow or deny decisions
What can a firewall NOT protect against?
Insider threats (malicious employee or USB key) and anything already inside the network - it only controls traffic crossing the boundary
Zero trust architecture
Trust nobody: every access must be authenticated and explicitly permitted even inside the network (contrast: a firewall trusts internal traffic)
Firewall policy
A set of rules (rows) the firewall compares each packet against to allow or deny it
Fields a firewall rule can match on
Type/protocol (TCP or UDP) - source address - destination address - destination port - action (permit or deny)
Firewall rule order
First matching rule wins - rules are checked top to bottom - if nothing matches the default action applies (or a catch-all rule at the bottom)
Allowlist firewall
Deny-by-default: only explicitly permitted traffic gets through - use for highly sensitive systems
Blocklist firewall
Allow-by-default: everything is permitted unless explicitly denied - use when you only want to stop nuisances
How to choose allowlist vs blocklist?
Depends on which list is shorter and how sensitive the assets are: sensitive = allowlist and nuisance control = blocklist
Rule: TCP from * to 192.168.1.* port 22 Permit
Allows SSH connections from anywhere (including the internet) to internal machines - e.g. remote access to your office PC from home
Port 22 / Port 80 / UDP port 69
22 = SSH - 80 = HTTP (web browsing) - 69 = TFTP (UDP)
Rule: TCP from 192.168.1.* to * port 80 Permit
Internal machines can browse the web (outbound HTTP)
Rule: TCP from * to 192.168.1.18 port 80 Permit
Anyone can reach the internal web server at 192.168.1.18 on port 80 (inbound)
Rule: UDP from * to 192.168.1.* any port Deny
Blocks all other UDP into the network - rule 2 (port 69) is matched first so that traffic still gets through
DMZ
Demilitarized zone: a semi-exposed segment holding public-facing servers (email and web and app) between the internet and the internal network
Home Wi-Fi router firewall
Home routers (from your ISP) run a firewall by default - you can view it and add your own rules (e.g. to allow a home server)
Three types of firewall
Packet filter (stateless) - stateful filter - application layer firewall (proxy)
Stateless firewall
Has no memory: treats each packet in isolation using only the rule table and forgets it once it has been handled
Stateless firewall advantage
Fast and simple so very common in the wild
Stateless firewall limitation
Has to be fairly restrictive to stop attacks - cannot tell whether a packet belongs to a real connection
Stateless rules for the TCP handshake example
Allow outbound SYN to port 80 - allow inbound SYN-ACK from port 80 - drop inbound SYN (stops outsiders initiating connections)
TCP three-way handshake
SYN (client) then SYN-ACK (server) then ACK (client)
Stateful firewall
Tracks every active connection in a state table and can tell if a packet starts a new connection or is part of an existing one or is invalid
What does a firewall state table store?
IP addresses and ports and sequence numbers for each active connection (plus the connection state e.g. established)
How a stateful firewall stops an attacker's fake SYN-ACK
The inbound packet matches no row in the state table (no connection was started from inside) so it is dropped
What can stateful firewalls allow inbound?
Only TCP packets that are replies to a connection initiated from inside the trusted network
Stateful vs stateless: trade-offs
Stateful is more powerful and stops inserted or out-of-order packets - but needs memory and costs more and is harder to configure and debug
Why are firewall rule sets hard to debug?
Rules accrue over time into a tangled puzzle - sometimes best to start fresh and cut down the number of rules
Application layer firewall
Works like a proxy: simulates the application and inspects the PAYLOAD as well as headers so it can block or modify content
Which firewalls look at the payload?
Only application layer firewalls - stateless and stateful ones just read IP and TCP headers
Application layer firewall examples
Block web traffic with certain words (censorship) - remove macros from Word files in email - stop credit card numbers leaving a database - scan attachments for malware
Sanitization
An application firewall edits a packet to remove sensitive data (e.g. replace personal info with generic text) instead of dropping it
Why can only the application layer scan email attachments?
The network layer does not know what an attachment is - only the application layer understands the content
Port scan
Attacker contacts many ports on a target (one source IP and many destination ports) to find listening services - the first step in mapping a network before attacking
How to deal with port scans
They happen constantly on the internet: block the source IP and drop traffic to ports you are not running anything on
Personal firewall
Software firewall on the device itself (e.g. Windows Defender) - basic protection for home and mobile devices
Rootkit weakness of personal firewalls
Rootkit-type software runs at the lowest privilege level and can disable the firewall or virus scanner - even benign programs (e.g. anti-cheat) can act like one
Firewall pros
Prevent straightforward attacks and information leakage - if you can think of how an attacker would act you can write a rule for it
Firewall cons
Can be circumvented - can block legitimate traffic - cost rises as effectiveness rises (overhead and configuration) - false sense of security
Firewall bottom line
You have to have one but do not count on it for much
Defense in depth
Many layers of defenses (e.g. firewall + IDS) because no single one is enough
Why does NAT exist?
IPv4 address exhaustion: only 2^32 (about 4.3 billion) addresses but far more devices than that
IPv4 address size
32 bits = 4 x 8 bits (e.g. 192.168.2.6)
IPv6 vs NAT
IPv6 is the long-term fix - NAT was the stopgap that let many internal IPs share one external IP
What is NAT?
The border router or firewall maps between its own external IP and the internal private IPs so many machines share one routable address
Private vs routable IPs
Only external (public) IPs are routable on the internet - private ranges (192.168.x.x and 172.16-31.x.x and 10.x.x.x) get dropped if they try to cross it
Why does your laptop IP differ from what whatismyip shows?
Your laptop has a private internal IP (e.g. 172.20.145.155 on uni WiFi) - websites only see the NAT router's external IP
Same internal IP on two networks
Fine: private addresses only need to be unique within their own network (e.g. a company PC and a home PC can both be 192.168.4.2)
NAT outbound step
Router keeps the destination - rewrites the SOURCE IP and port to its own external IP and a new port - and records the mapping in a table
NAT inbound step to a server
Router rewrites the DESTINATION to the internal host registered for that port (e.g. port 80 goes to 192.168.4.2)
Port forwarding
Router rule saying traffic arriving on port X is for internal machine Y - needed so outsiders can reach a server behind NAT - two machines cannot share the same forwarded port
NAT reply path
Router looks up the port in its table - swaps the stored internal address and port back in - and forwards the reply to the right machine
NAT header rule of thumb
Leaving a network: change the FROM - arriving at a network: change the TO
NAT worked example from slides
Home PC 192.168.4.2 port 5338 sends to 173.162.146.61 port 80 - home router rewrites source to 192.41.131.255 port 7648 - company router then rewrites the destination to 192.168.4.2 port 80
Risk of setting up NAT/port forwarding for IoT cameras
Letting yourself view the camera remotely also exposes it to attackers - cheap devices keep default passwords
Shodan
A search engine that keeps scanning the internet for exposed insecure devices (webcams etc) with default passwords
IDS
Intrusion Detection System: detects an incident already in progress - firewalls prevent while an IDS detects
Why do we need an IDS if we have a firewall?
Some traffic must be let in and humans are the weakest link (phishing and attachments and insider threats) so not everything can be anticipated
Network operations center
Room where staff monitor alarms and network activity for weird behaviour - you need sensible alarms rather than hundreds of screens
True positive
Attack happens and the alarm sounds (good)
False positive
No attack but the alarm sounds (a false alarm)
False negative
Attack happens but no alarm sounds (a missed attack)
True negative
No attack and no alarm (good)
Can an IDS have zero false positives and zero false negatives?
No - the nature of alarms means you cannot eliminate both so tuning trades one off against the other
Rule-based (signature) IDS
Uses signatures of known attacks to detect matching actions
Rule-based IDS pros and cons
Pro: high accuracy and low false positives - Cons: admin must anticipate attacks - attackers can test against common signatures - cannot detect new attack types (so more false negatives)
Statistical (anomaly) IDS
Dynamically builds a model of normal behaviour and flags anything that does not match
Statistical IDS pros and cons
Pros: no need to anticipate attacks and can detect new attacks - Cons: needs warm-up time and has higher false positives and lower accuracy
Base-rate fallacy
Even a 99% accurate IDS gives mostly false alarms when real attacks are rare because benign traffic hugely outnumbers malicious traffic
Base-rate fallacy numbers from slides
1000100 log entries: 100 malicious (99 detected and 1 missed) and 1000000 benign (10000 false positives) - so 10099 alarms and about 99% are false
Target 2013 breach
IDS correctly flagged the attack but there were too many alarms to investigate - and insurers can refuse cover if you knew about an attack and did nothing
Alarm fatigue
Too many (mostly false) alarms make staff stop looking - a noisy IDS can be a liability
Attacker abusing an IDS
Attacker deliberately triggers floods of false positives to bury the real attack or wear out analysts
Firewall vs IDS in one line
Firewall prevents known-bad traffic - IDS detects incidents in progress
How to practise NAT for the exam
Draw the packet headers (FROM and TO and ports) at each hop for both the request and the reply - it is a common exam question