Helpful first: How one request crosses the network
By the end you can
- Match a packet to the first rule that fits its five values, and let the last rule deny the rest
- Let a reply through a state row, and drop a stranger that matches no row and no allow rule
- Explain how an intrusion detection system (IDS) that alerts on a copy differs from an intrusion prevention system (IPS) that can drop the packet
A rule matches five values
A firewall stands between two networks. It looks at each packet and decides if the packet can go through. On this bench the firewall sits next to the internet router. The update server is on the inside at 192.0.2.10. The internet is on the outside. This bench gives the server a public address, so the firewall does not translate addresses.
The firewall reads five values in each packet. We call these five values the 5-tuple.
- the source address
- the destination address
- the source port
- the destination port
- the protocol, for example the Transmission Control Protocol (TCP)
A rule names the values that it matches and the direction of the packet. A rule can use "any" for a value.
The first match decides, and the last rule says no
The firewall reads its rules from the top of the list. The first rule that matches the packet decides the result. The firewall does not read the rules below it. Many firewalls work this way, but some use a different order. This bench uses the first match.
If no other rule matches, the last rule decides. That rule is the default deny. It blocks all traffic that no rule above it allows. The National Institute of Standards and Technology (NIST) calls this deny by default. Its guide SP 800-41 Rev. 1 (September 2009) tells organizations to block all traffic that the firewall policy does not permit.
A firewall can block a packet in two ways. When it drops the packet, it sends nothing back. The sender waits and sends the packet again. When it rejects the packet, it sends back a TCP reset or an Internet Control Message Protocol (ICMP) error. The sender learns at once that the connection failed.
The state table lets the answer back in
The update server sends a SYN from port 50514 to the update mirror at 203.0.113.80 on port 443. A SYN is the first TCP packet of a connection. It asks to open the connection. Rule 1 allows this packet. The firewall then writes a row in its state table. The row holds the 5-tuple of this connection and its state, Initiated.
The mirror sends a SYN-ACK back. A SYN-ACK accepts the connection. No rule allows inbound traffic to port 50514. But the packet matches the row in the state table, so the firewall lets it through. Return traffic that matches a state row does not need its own rule.
The update server then sends an ACK, which confirms the SYN-ACK. After this handshake, the row changes to Established. The firewall can often read the server name in the ClientHello, the first message of Transport Layer Security (TLS). It cannot read the encrypted records after the handshake. The row ends when the connection closes, or after a long time with no traffic.
PUT IT IN ORDER
The update server opens a connection to the mirror. Put the steps in order.
- Rule 1 allows it and the firewall writes a row
- The server sends a SYN from port 50514
- The mirror sends a SYN-ACK that matches the row
- The server sends an ACK and the row becomes Established
Show the answer
- The server sends a SYN from port 50514
- Rule 1 allows it and the firewall writes a row
- The mirror sends a SYN-ACK that matches the row
- The server sends an ACK and the row becomes Established
Rule 1 allows the SYN. The reply matches the row, so it needs no inbound rule. The row becomes Established after the ACK.
A stranger finds no row
An outside host at 198.51.100.20 sends a SYN to port 443. Rule 2 allows new inbound connections to port 80 and port 443 on the server. The firewall writes a new row, and the server can answer. An allow rule opens only the ports that it names.
The same host then sends a SYN to the server on port 22. No rule allows port 22, and no state row matches. The default deny drops the packet. The server never sees it.
Next, the host sends a packet with the ACK flag and no SYN before it. It looks like return traffic. A stateful firewall checks its table first. No row matches this conversation, so the firewall drops the packet.
WORKED EXAMPLE
Nyx sorts three inbound packets
- The table. Nyx starts with one row:
192.port 50514 and0. 2. 10 203.port 443, Established. Rule 2 allows new inbound connections to ports 80 and 443 on the server.0. 113. 80 - Packet A. Data from
203.port 443 to0. 113. 80 192.port 50514. It matches the row, so it passes with no inbound rule.0. 2. 10 - Packet B. Data from
203.port 443 to0. 113. 80 192.port 50600. No row names port 50600, and no rule allows inbound traffic to it. The default deny drops it.0. 2. 10 - Packet C. A SYN from
198.to51. 100. 20 192.port 443. It is a new connection, so rule 2 allows it and the firewall writes a second row.0. 2. 10
Result: Two packets pass and one is dropped. The same sender, 203., gets one packet through and one dropped, because only A has a row. The table now holds two rows.
A rule in the wrong place never runs
Rule 3 blocks a known bad host, 198.51.100.66. But rule 3 sits below rule 2. A SYN from the bad host to port 443 matches rule 2 first, so the firewall allows it. Rule 3 never runs.
Move the block rule above the allow rule, and the firewall drops the packet. On a first-match firewall, the position of a rule decides, not its action.
Watch a copy, or stand in the path
An intrusion detection system (IDS) watches a copy of the traffic. A mirror port on the switch or a network tap gives it that copy. The IDS compares the traffic to signatures and sends an alert. A signature is a pattern that matches a known threat. The real packet does not go through the IDS, so the IDS cannot reliably stop it.
An intrusion prevention system (IPS) sits inline. Each packet must go through it. The IPS can drop a packet that matches a signature before the packet gets to the server. An IPS often sits next to the firewall, or it is part of the firewall.
An IDS or IPS cannot read the contents of TLS traffic that it cannot decrypt. It can read the addresses, the ports, and often the server name. It can read a plain Hypertext Transfer Protocol (HTTP) request in full.
IDS on a mirror port
- Sees a copy of the traffic
- Sends an alert when a signature matches
- Cannot reliably stop the real packet
IPS inline
- Each packet goes through it
- Can drop a packet that matches a signature
- A false positive stops the connection of a real user
SPOT THE PROBLEM
These notes are from the same bench. Flag every line that claims something that the device cannot see.
Show the answers
- firewall note claims it read the path inside TLS The path sits inside the encrypted records. This firewall cannot read it.
- firewall note says the reply was allowed because port 443 is open inbound The reply matched a state row. It did not need an inbound allow rule.
A false positive or a failure has a cost
No IDS or IPS is fully accurate. A false positive is a harmless packet that the system marks as an attack. When an IDS makes this mistake, an analyst gets a wrong alert. When an IPS makes this mistake, a real user loses the connection. A false negative is an attack that the system misses. In most cases, fewer false positives mean more false negatives.
An inline device can fail, or it can get too much traffic. If it fails open, traffic continues with no inspection. If it fails closed, traffic stops. Fail open keeps the service available. Fail closed keeps the check in place, but the service stops.
SORT IT OUT
The inline IPS at Station North has stopped inspecting. Which failure mode does each line describe?
Show the answers
- Fail open. Fail open keeps the service available. The check is skipped.
- Fail closed. Fail closed stops traffic when the inline device cannot inspect it.
- Fail open. With no inspection, the IPS cannot drop a packet that matches a signature.
- Fail closed. Fail closed keeps the check in place. The cost is that the service stops.
One way out for web traffic
A firewall can also force all web traffic through one point. One rule allows only a web proxy to send traffic to port 80 and port 443 on the internet. A second rule blocks the same traffic from all other devices.
The next lesson follows that traffic into the proxy.
CHECK YOUR JUDGMENT
Priya asks what it costs if the inline IPS fails closed, and Vera asks what it costs if it fails open. What do you tell them?
CASE FILE · CASE 1 · ENTRY 4 OF 18
Answer the closing question correctly to add this entry to your case file.
Inline means it can stop you
Replies reach the Station North update server because they match state rows, and an inline IPS there can stop an attack or stop the service.
Next episode: The firewall forces all web traffic through one point. Next, you follow it into the proxy.
Review sheet: exam notes and quick reference
Threat A person, process, or event that might cause a loss to an asset.
HTTP The application protocol that names methods, paths, headers, and bodies for web requests.
TLS A protocol that encrypts and integrity-protects an application conversation and checks a certificate for a name.
Port A number on a host that distinguishes one listening service from another.
Alert A notification that a rule or model wants a human to look at one or more records.
False positive An alert that did not represent the harmful event the detector was meant to catch.
Firewall A device or program that sits between networks and allows or blocks traffic according to an ordered set of rules.
Proxy A server that makes connections on behalf of others. A forward proxy stands in for inside clients going out, and a reverse proxy stands in front of servers taking calls from outside.
TCP The protocol that gives two machines a reliable, ordered stream of bytes. It opens each connection with a three-packet handshake and confirms every byte received.