Firewalls at the network edge: what each kind can see

8 min 4 sections 4 practice questions 8 sources citedISC2 objective 4.1

The edge of a network is where it meets networks run by somebody else, above all the internet. A firewall stands at that edge and decides which traffic may pass in and out. Firewalls differ in how much of each message they read. No background is assumed. A security professional needs this to choose the kind of firewall a risk calls for, and to write rules that fail safe.

By the end of this unit you will be able to:

  • Tell apart seven kinds of firewall by what each one reads
  • Explain why the order of firewall rules matters and what implicit deny means
  • Explain ingress and egress filtering, and how each stops forged source addresses
  • Tell apart peering and transit, and explain why routes learned from other networks are filtered

The reply that nobody had asked for

An illustrative example

A firm of surveyors protects its office with an old filtering router. To let staff browse the web, the installer wrote one rule: allow any packet from the internet that comes from port 443, the port secure websites reply from.

One night a stranger sets a computer to send from port 443 and connects to the firm's file server. Every packet matches the rule, so the router lets every packet in. No one in the office had asked that computer for anything.

What would the router have needed to know to tell a real reply from this one?

A firewall is a guard that reads more or less of each message

A firewall is a device or program placed between two networks that passes or blocks traffic according to a set of rules. It protects the network on one side, called the inside, from the network on the other.

The back of a red hardware firewall box. Below its lid, a metal panel holds a console connector and three network sockets marked External, Trusted and Optional.

A hardware firewall is a box placed between two networks, with a separate socket for the outside network and for the inside network it protects.

  1. 1Outside network socket. Marked External: the cable to the network on the other side, such as the internet.
  2. 2Inside network socket. Marked Trusted: the cable to the network the firewall protects.

Photograph: Watchguard Firebox 1000 back by Jakez, CC BY-SA 3.0. Cropped and resized.

Three guards at a gate

The first guard looks only at the address on each envelope. The second also keeps a list of who went out, and admits only letters that answer one of them. The third opens each envelope and reads the letter. Each guard catches more than the one before and takes longer over each letter.

What a can decide depends on what it reads. At it reads the source and destination IP addresses. At it reads the protocol and the port numbers, which say which service is being asked for. At it reads the content: the web page requested, the file sent, the command given.

Reading more allows finer rules. It also costs more work for each , and content cannot be read at all unless the firewall it first.

Seven kinds of firewall

Firewalls by what they read
KindReadsOSI layerLimit
Static packet filterThe header of each packet, one at a time3 and 4Cannot tell a real reply from a forged one
Stateful inspectionHeaders, checked against a table of the connections in progress3 and 4Does not read content
Dynamic packet filterHeaders, and opens a temporary rule for each reply3 and 4Does not read content
Circuit-level gatewayThe setting up of each connection, which it then relays5Passes the content through unread
Application-level proxyThe whole message of one application protocol7Slower, and needs a proxy for each protocol
Next-generation firewallHeaders, connection state and application content together3 to 7Must decrypt traffic to inspect it
Web application firewallWeb requests sent to one website7Protects web applications and nothing else

A static packet filter, also called a stateless firewall, judges every packet alone. A stateful inspection firewall records each connection that a device inside begins, in a state table. A packet from outside is admitted only when it matches a connection in that table. At the surveyors' office a stateful firewall would have found no entry for the stranger's computer and dropped its packets.

A dynamic packet filter opens a temporary rule that admits only the reply to each packet sent out, and drops the rule when its time runs out. Some makers use the name for stateful inspection itself.

A circuit-level gateway relays connections between inside and outside without examining what they carry. SOCKS is a common example: the client connects to a SOCKS server, which checks the source and destination and then relays the connection. An application-level proxy stands in for both ends. The client connects to the proxy and the proxy makes a second, separate connection to the server. It reads every command, can ask each user to sign in, and hides inside addresses from the outside.

A next-generation firewall (NGFW) combines stateful inspection with knowledge of applications. It can tell which application is in use whatever port it runs on, decrypt and inspect encrypted traffic, and block known attacks.

A web application firewall (WAF) sits in front of a web server and inspects the requests sent to it. It looks for attacks hidden inside ordinary web traffic, such as SQL injection, where database commands are typed into a form on a web page.

Rules are read in order, and the last rule is deny

A firewall holds its rules as an ordered list, the ruleset. Each rule names a source, a destination, a service and an action: allow or deny. For each new connection the firewall reads the list from the top and applies the first rule that matches. Later rules are not consulted.

A small ruleset, read from the top
OrderFromToServiceAction
1Office networkInternetSecure web ( 443)Allow
2InternetPublic web serverSecure web (TCP 443)Allow
3Visitors' networkOffice networkAnyDeny
4AnyAnyAnyDeny

Order decides the outcome. If a broad rule sits above a narrow one, the narrow rule is never reached. Specific rules therefore go above general ones.

The last line of the table is implicit deny, also called deny by default: whatever no rule has expressly permitted is blocked. A firewall built the other way round, allowing everything except what is listed, fails the first time something new appears.

First match wins. Specific above general. Everything not expressly allowed is denied.

Rulesets grow. Each rule should have an owner and a reason, changes should pass through , and rules that nothing uses are removed at regular reviews.

The network edge: ingress, egress and peering

An edge network is the part of a network that connects to networks owned by others. Ingress filtering checks traffic coming in at the edge. Egress filtering checks traffic going out. Egress filtering stops stolen data leaving, stops malicious software reporting to its controller and stops the organisation's own machines being used to attack others.

Spoofing means forging the source address of a packet. Two rules at the edge defeat most of it. Inbound, drop any packet from outside that claims an inside address or a private address. Outbound, drop any packet whose source address is not one of the organisation's own. Internet providers apply the same check to their customers.

A flood of traffic from many machines at once, a distributed denial of service, can fill the link before the firewall is reached. Providers can filter such a flood upstream, a service often called scrubbing.

The internet is thousands of separately run networks. Each is an autonomous system, and they tell one another which addresses they can deliver to using the Border Gateway Protocol (BGP).

Transit
A provider carries its customer's traffic to and from the whole internet.
Peering
Two networks hand each other the traffic meant for their own customers, directly, and carry nothing further for each other.
Internet exchange point
A shared site where many networks connect in order to peer.

BGP believes what neighbouring networks announce. In prefix hijacking a network announces address ranges that belong to someone else and draws their traffic to itself. A route leak passes routes on beyond where they were meant to go. The defence is to filter the routes accepted from each neighbour, and to check announcements against signed records of who holds which addresses.

A question, worked through

A charity's edge firewall is a stateful inspection firewall. It allows connections from the internet to the charity's donations website on TCP port 443 and denies everything else inbound. Logs from the website show repeated attempts to insert database commands through the donation form. The IT manager asks the security adviser what to add.

Which control BEST addresses these attempts?

  1. A web application firewall in front of the donations site
  2. A static packet filter on the router outside the firewall
  3. An egress rule blocking outbound traffic from the web server
  4. A circuit-level gateway to relay connections to the site
Decide on your answer, then open the reasoning
  1. The question asks for a control against attacks that arrive inside permitted web requests. The attack is in the content, at layer 7.
  2. Rule out b: a static packet filter reads less than the stateful firewall already in place. The requests would pass it for the same reason.
  3. Rule out d: a circuit-level gateway relays the connection and does not read what it carries.
  4. Between a and c: the egress rule is sound practice and would limit what a taken-over server could send out. It does not stop the injected commands reaching the form.
  5. A web application firewall reads each web request and can block the injection itself, so a is the best answer.

Answer: A. A web application firewall in front of the donations site

Choosing between good answers

A firewall must tell a genuine reply from an unrequested packet
choose stateful inspection. A static packet filter cannot do it.
An attack is carried inside permitted web traffic
choose the control that reads layer 7: a web application firewall for a website, a proxy or next-generation firewall for traffic in general.
A question asks what a firewall should do with traffic no rule mentions
the answer is deny. Implicit deny is the safe default.
Stolen data is leaving, or inside machines are attacking others
look at egress filtering. Ingress rules do not see it.
Traffic for an organisation's addresses is arriving at another network
think prefix hijacking, and choose route filtering between the networks.

Try it

Read the edge firewall's rules from the top and find the first one that matches the laptop's request.

Loading the preview.

Check your understanding

4 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.

These questions are drafts that no named reviewer has approved yet.

Question 1 of 4

Match each kind of firewall to what it reads when deciding whether to pass traffic.

Choose the match for each entry. Every match has to be right.

What to remember

  • A static packet filter reads headers one packet at a time. A stateful firewall also remembers which connections are in progress.
  • A circuit-level gateway relays connections at layer 5. An application-level proxy reads the content at layer 7.
  • A next-generation firewall adds application awareness and attack blocking. A web application firewall protects one web application.
  • Rules are read from the top, the first match is applied, and anything not expressly allowed is denied.
  • Ingress filtering checks traffic coming in at the edge. Egress filtering checks traffic going out, and both drop forged source addresses.
  • Transit carries a customer's traffic to the whole internet. Peering exchanges traffic between two networks' own customers.

Say it from memory

  1. At the edge of a network, what are ingress and egress filtering, and how do peering and transit differ?

    Ingress filtering checks traffic entering at the edge. Egress filtering checks traffic leaving, which stops forged source addresses and stolen data. Transit is a provider carrying a customer's traffic to the whole internet. Peering is two networks exchanging their own customers' traffic directly, often at an internet exchange point. Routes from other networks are filtered because BGP believes what it is told.

    Read this part again

  2. What does a firewall read at layers 3, 4 and 7, and what is the cost of reading more?

    At layer 3 it reads the source and destination IP addresses. At layer 4 it reads the protocol and the port numbers. At layer 7 it reads the content, such as the page requested or the command given. Reading more allows finer rules but costs more work for each packet, and encrypted content cannot be read unless decrypted first.

    Read this part again

  3. How does a stateful inspection firewall differ from a static packet filter, and how does an application-level proxy differ from a circuit-level gateway?

    A static packet filter judges every packet alone. A stateful inspection firewall admits a packet from outside only when it matches a connection in its state table. A circuit-level gateway, such as SOCKS, relays connections without examining what they carry. An application-level proxy makes a second, separate connection to the server and reads every command.

    Read this part again

  4. In what order does a firewall read its ruleset, and what is implicit deny?

    It reads the list from the top and applies the first rule that matches; later rules are not consulted. Specific rules therefore go above general ones. Implicit deny, also called deny by default, blocks whatever no rule has expressly permitted.

    Read this part again

Sources