Helpful first: How one request crosses the network · How a stateful firewall decides
By the end you can
- Send office web traffic through one proxy, and keep a firewall rule that blocks direct connections
- Read a full Hypertext Transfer Protocol (HTTP) Uniform Resource Locator (URL), and a CONNECT line that names only the host and the port
- Explain how a CONNECT tunnel differs from two TLS sessions that use a certificate from an internal certificate authority (CA)
Many devices, one way out
A forward proxy collects web traffic from many devices. Each device sends its web requests to the proxy. The proxy then makes a new connection to the website. On this bench the proxy is at 10.6.0.8, port 8080. All web traffic leaves the station from one point.
The firewall has three interfaces. One goes to the office network, one goes to the proxy zone, and one goes to the internet router. Rule 2 lets only the proxy send web traffic to the internet. Rule 3 rejects direct connections from office devices to port 80 and port 443. Office devices cannot go around the proxy.
How a device finds the proxy
A device must know the address of the proxy. An administrator can type the address into the device settings. A proxy auto-configuration (PAC) file can also give the address. The PAC file is a short script. For each Uniform Resource Locator (URL), it tells the browser to use the proxy or to go direct.
Some devices try to find the PAC file when they have no PAC address. This method is Web Proxy Auto-Discovery (WPAD). WPAD asks the Dynamic Host Configuration Protocol (DHCP) or the Domain Name System (DNS) for the location of the file. WPAD is an Internet-Draft from 1999 that expired. If a WPAD query leaks to a public DNS server, an attacker who registers that name can answer it. The attacker can then send web traffic through a proxy that the attacker controls.
A proxy can also work when the device has no proxy address. The firewall or the router sends web packets to the proxy. The device does not know about the proxy. We call this an interception proxy, or a transparent proxy.
For plain HTTP, the proxy reads the whole URL
For a plain Hypertext Transfer Protocol (HTTP) URL, the laptop sends the full URL to the proxy. The request line starts with GET http:/.
The proxy can read the host, the path, and the headers. It checks its policy. Then it opens a second connection and sends the request with only the path, /. It adds a Via header that names the proxy.
For HTTPS, CONNECT opens a tunnel
For an HTTPS URL, the laptop sends a CONNECT request. The request names only a host and a port, for example docs.. The proxy can read that host and that port. It cannot read the path, because the path is not in the CONNECT request.
The proxy can ask the laptop to sign in first. It sends status 407 with a Proxy- header. The laptop sends the request again with a Proxy- header. Basic sign-in sends the password in clear text, so the hop to the proxy needs protection.
The proxy checks the host and the port. The HTTP standard tells proxies to limit CONNECT to known ports (RFC 9110, June 2022). This bench allows CONNECT only to port 443. Without that limit, an attacker can use the proxy to send spam email or to reach ports that are not for the web.
Quick check
Dax's desktop sends CONNECT docs.example.com:443 to the proxy. What can the proxy read from that request?
Inside the tunnel, the proxy copies bytes
If the proxy allows the tunnel, it opens a Transmission Control Protocol (TCP) connection to the website. Then it sends a 2xx status, for example 200. After that, the proxy copies bytes in both directions. The laptop does TLS with the website through the tunnel. The bytes of the ClientHello, the first TLS message, go through the proxy, so the proxy can often read the server name. It cannot read the encrypted records.
The PROXY protocol is a different thing: a Layer 4 header that passes the original client address to a backend server.
To read the page, the proxy needs two TLS sessions
A content filter needs to read the path and the page. To do this, the proxy must end the TLS session from the laptop. It shows the laptop a certificate for the website. The station's internal certificate authority (CA) signed that certificate. On this bench, that CA is the Station Inspection CA.
The laptop accepts that certificate only because the station installed its internal CA on the laptop. A device that does not trust the internal CA shows a certificate error. The proxy also makes a second TLS session to the real website. Now there are two TLS sessions, and the proxy can read the request in the middle. For the steps of a TLS handshake, go back to the lesson on how one request crosses the network.
The proxy now does the certificate check for the laptop. The laptop cannot see the real certificate of the website. If the proxy accepts a bad certificate, the laptop does not know. The Cybersecurity and Infrastructure Security Agency (CISA) gave advice on this in March 2017. It tells organizations to check that the proxy rejects bad certificates and passes each error to the laptop.
Some apps pin the key of their server. A pinned app accepts only the keys that it expects. Unless the app makes an exception for the internal CA, it rejects the certificate from the proxy. Such an app fails behind TLS interception. One fix is to put its host on the decrypt-bypass list. The list can also hold bank and health sites, because a proxy that ends TLS can read all of their traffic, including passwords.
CONNECT tunnel
- The proxy sees the host and the port
- The ClientHello often shows the server name
- The path stays inside TLS
TLS interception
- The proxy ends the session from the laptop
- The station CA signs the certificate the laptop sees
- The proxy opens Session 2 to the website
PUT IT IN ORDER
The proxy decrypts an HTTPS page. Put the steps in order.
- The laptop sends its ClientHello, and the proxy answers it
- The proxy reads the request and sends it to the website
- The proxy sends 200 to the laptop
- The laptop sends CONNECT with the host and the port
Show the answer
- The laptop sends CONNECT with the host and the port
- The proxy sends 200 to the laptop
- The laptop sends its ClientHello, and the proxy answers it
- The proxy reads the request and sends it to the website
CONNECT names the host and the port. The proxy answers the ClientHello itself, so it can read the request before it sends the request to the website.
Some sites stay sealed, and some never open
An organization can choose, for example, not to decrypt health sites or bank sites. A decrypt-bypass list names these sites or categories. For a site on the list, the proxy opens a plain tunnel. It logs the host and the port, but it does not read the request. Exempt does not mean hidden.
The proxy looks up the host in a category list or a reputation list. On this bench, if the verdict is malware, the proxy does not open a connection to the site. If the proxy decrypts the session, it can send a block page. If the proxy does not decrypt it, it can only refuse the tunnel or close the connection. A list can block only what it names.
WORKED EXAMPLE
Nyx reads three CONNECT lines
- The first line.
CONNECT downloads.. The port is 443, and the host is not on the decrypt-bypass list. The proxy answers 200, then ends TLS itself with a Station Inspection CA certificate, so it can read the request.example. com:443 - The second line.
CONNECT mail.. This bench allows CONNECT only to port 443, so the proxy refuses the tunnel. It never opens a connection to port 25.example. com:25 - The third line.
CONNECT health.. The host is on the decrypt-bypass list. The proxy opens a plain tunnel and logs the host and the port. It does not read the request.example. com:443
Result: Two tunnels open and one is refused. The proxy reads the request in one of the two tunnels, and the exempt host stays sealed.
The website sees the station
When the proxy makes a connection, the website sees the address of the station. It does not see the laptop. A login inside TLS still tells the website who the user is.
The firewall changes the source address of the proxy to the public address 203.0.113.2. This change is network address translation (NAT).
SPOT THE PROBLEM
These notes are from 03:12. Flag every line that claims something that its log cannot show.
Show the answers
- proxy log shows the command to the antenna controller A proxy logs only the traffic that reaches it. That command did not go through the proxy.
- website log shows the private address of an office desktop The source address that the website sees is the public address of the station, not the private address of the office desktop.
- proxy log reads the path on a health site that stays sealed This host is exempt from TLS interception. The proxy logs the host and the port but does not read the request inside the tunnel.
Proxies face two ways
A forward proxy works for the devices on the inside. A reverse proxy faces the other way. It stands in front of the origin, the server that holds the page. The reverse proxy ends the connection from the client and opens a new connection from its own address. The origin log records the client it accepted. That client is the proxy.
A Forwarded or X-Forwarded-For header can carry the address of the device. Each proxy adds its entry at the end, so trust only the entries that your own proxies added. A client can fake any Forwarded or X-Forwarded-For entry that your own proxy did not add.
CHECK YOUR JUDGMENT
Dax's app rejects the station certificate, and his shortcut around the proxy fails at once. Which fix do you keep?
CASE FILE · CASE 1 · ENTRY 5 OF 18
Answer the closing question correctly to add this entry to your case file.
Web traffic must use the proxy
Station web traffic leaves through the proxy, which reads an HTTPS page only when it ends TLS with a certificate that the device trusts.
Next episode: The proxy logged every web host it saw at 03:12. The command to the antenna is not on that list.
Review sheet: exam notes and quick reference
DNS The lookup system that maps a name people type to an address a computer can contact.
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.
Session State linking multiple requests; an authenticated session associates later requests with a previously authenticated identity until it expires or is revoked.
Log A record emitted by a system that something happened, which may later be used as evidence.
Certificate A signed document that binds a public key to a name, such as a server hostname, and states who issued it and for how long it is valid.
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.
DHCP The protocol that hands a device its IP address and network settings for a limited time, called a lease, when it joins a network.