A hardware device or a software or both, that protects a private network from outside intrusions. It examines every passing packet against a set of rules.
Linux security hardening includes host-based firewall configuration within a wider host baseline.
Firewall Policy
Default Stance
The stance dictates what a firewall does when no rule matches. The default stance blocks everything unless explicitly allowed.
Security Policy
A firewall’s security policy specifies:
- Which hosts send or receive which kinds of traffic.
- Which communication links require authentication or encryption.
- Which users are authorized to use which services through the firewall.
- Which communication protocols and content types are allowed.
- Which times of day users may browse the web.
- Which categories of website users may visit.
Network Interfaces and Zones
Interfaces
- External interface
Connects to an untrusted network, typically the Internet. - Trusted interface
Connects to the internal network, requiring maximum protection. - Optional interface
Connects to a DMZ or another semi-trusted zone, hosting public web, mail, FTP, or DNS servers.
Demilitarized Zone
A demilitarized zone (DMZ) is a separate network segment behind the optional firewall interface. It hosts public servers such as web and mail. It remains isolated from the internal network.
Traffic Inspection
Stateless Packet Filtering
Packet filtering inspects a packet header. It filters on IP address, port, protocol, or type of service. It treats incoming and outgoing packets separately. Operates at the network and transport layers.
Cannot detect stateless attacks such as denial of service, since it judges every packet independently.
Stateful Inspection
A stateless packet filter judges each packet independently. It has no memory of the protocol context.
A stateful firewall tracks the state of each connection. It permits inbound traffic only when it matches an established, legitimate outbound request. Unsolicited probes and forged replies are dropped.
Circuit Relay
Circuit relay filters using information outside the packet header, such as the user or time of day. It tracks connection state dynamically.
Combining packet filtering with circuit relay is more effective than either alone.
Security Proxy
A security proxy intercepts each packet, strips its wrapping, inspects and processes the content, then re-wraps and forwards it. It detects forbidden content that packet filtering and circuit relay cannot see.
Works at application layer. Conceals details of internal servers from the public Internet. Blocks entire categories of attack rather than individual packets.
Adds processing delay to every packet.
A lower layer makes less information available to the filter. It also adds less processing overhead per packet.
Proxy Advantages
- Harder to hack
Blocks entire categories of common attacks and conceals internal servers from the public Internet. - Bandwidth use
Prevents unwanted or inappropriate traffic from entering the network. - Lower liability
Prevents an attacker from using the network as a launch point for further attacks. - Easier management
Administrators apply tools and defaults broadly instead of desktop by desktop.
Specialized Controls
VPN
Also known as Virtual Private Networks. Gives 2 hosts an encrypted channel over a public network. It uses a protocol such as IPsec, L2TP, or PPTP.
Encrypts traffic end to end. Encryption overhead trades bandwidth and processing power for confidentiality. This overhead can noticeably reduce throughput on a high-speed connection.
A VPN server needs to be dedicated to the task. A server shared with other services cannot sustain the added processing load.
Web Application Firewall
A web application firewall (WAF) inspects Layer 7 traffic in depth. It mitigates application-specific attacks such as SQL injection and cross-site scripting. A traditional or next-generation firewall that works on lower-layer traffic does not specialize in these.
URL Filtering
Web pages are filtered against a database controlled by a third party. The administrator can add sites or exceptions. Filtering can depend on the user, the user group, the time of day, and similar attributes.
Firewall Deployment
Software and Hardware Firewalls
- Server-based firewall
Runs on a general-purpose server. The OS is less secure and not real-time. The deployment pays for unnecessary features, needs parts from several vendors, and needs frequent patches. Low initial cost, high total cost of ownership. - Hardware appliance
A dedicated box with a hardened OS from a single vendor, often without a hard disk. Firmware updates are harder to apply. Higher initial cost, significantly lower total cost of ownership.
Appliances beat software through ASICs (application specific integrated circuits), which hard-code functions such as packet classification, rule enforcement, NAT, and encryption into chips.
- On a CPU-centered design, every packet crosses the system bus, which becomes the bottleneck.
- An intelligent ASIC sends the first packet of a flow to the CPU for classification and policy lookup.
- The policy is cached in the ASIC. The remaining packets of the flow are cut through, bypassing the CPU.