Should SSL be terminated at a load balancer?
When hosting a cluster of web application servers it’s common to have a reverse proxy (HAProxy, Nginx, F5, etc.) in between the cluster and the public internet to load balance traffic among app servers. In order to perform deep packet inspection, SSL must be terminated at the load balancer (or earlier), but traffic between the load balancer and the app servers would be unencrypted. Wouldn't early termination of SSL leave the app servers vulnerable to packet sniffing or ARP poisoning? Should SSL be offloaded? If so, how can it be done without compromising the integrity of the data being served? My main concern is for a web application where message layer encryption isn't an option.
It seems to me the question is “do you trust your own datacenter”. In other words, it seems like you’re trying to finely draw the line where the untrusted networks lie, and the trust begins.
In my opinion, SSL/TLS trust should terminate at the SSL offloading device since the department that manages that device often also manages the networking and infrastructure. There is a certain amount of contractual trust there. There is no point of encrypting data at a downstream server since the same people who are supporting the network usually have access to this as well. (with the possible exception in multi-tenant environments, or unique business requirements that require deeper segmentation).
A second reason SSL should terminate at the load balancer is because it offers a centralized place to correct SSL attacks such as CRIME or BEAST. If SSL is terminated at a variety of web servers, running on different OS’s you’re more likely to run into problems due to the additional complexity . Keep it simple, and you’ll have fewer problems in the long run.
That being said
- Yes, terminate at the load balancer and SSL offload there. Keep it simple.
- The Citrix Netscaler load balancer (for example) can deny insecure access to a URL. This policy logic, combined with the features of TLS should ensure your data remains confidential and tamper-free (given that I properly understand your requirement of integrity)
It’s possible (and common) to
- Outsource the load balancer (Amazon, Microsoft, etc)
- Use a 3rd party CDN (Akamai, Amazon, Microsoft, etc)
- Or use a 3rd party proxy to prevent DoS attacks
… where traffic from that 3rd party would be sent to your servers over network links you don’t manage. Therefore may not trust those unencrypted links. In that case you should re-encrypt the data, or at the very least have all of that data travel through a point-point VPN.
Microsoft does offer such a VPN product and allows for secure outsourcing of the perimeter.
Yes, I would argue that TLS should be offloaded. I have done everything that I mention below specifically with the Citrix Netscaler, but I believe F5 should be able to do the same things.
First, you always need to make sure that you reencrypt on the other side of the load balancer, but the device decrypting TLS should be able to inspect what’s going on from a security perspective. The integrity of the data should not be compromised by this approach.
Many people have said to me that reencrypting on the back end makes it just as computationally expensive, but that is not true. The expense with TLS is the building and closing of the connection, which the TLS offloader handles. On the backend you have a more persistent connection to the servers, and therefore the required resources are much lower.
Additionally, if you don’t have TLS offloading then even a small DDoS attack via TLS would completely annihilate your servers. I am very familiar with this situation and TLS offloading is an incredible help from a computational perspective, and also allows you to block attacks further up the chain. For extremely large DDoS attacks, you could even split your mitigation strategy between your TLS offloader and your servers.
To inspect the data which goes within a SSL connection, then either of these must be true:
- The tunnel ends on the machine which does the inspection, e.g. your “load balancer”.
- The inspection system knows a copy of the server’s private key, and the SSL connection does not use ephemeral Diffie-Hellman (i.e. the server does not allow the cipher suites which contain “DHE” in their name).
If you follow the first option, then data will travel unencrypted between the inspection system (the load balancer) and the clusters, unless you reencrypt it with some other SSL tunnel: main SSL connection is between client browser and the load balancer, and the load balancer maintains a SSL link (or some other encryption technology, e.g. a VPN with IPsec) between itself and each of the cluster nodes.
The second option is somewhat lighter, since the packet inspector just decrypts the data but does not have to reencrypt it. However, this implies that all cluster nodes are able to do the full SSL with the client, i.e. know a copy of the server private key. Also, not supporting DHE means that you will not get the nifty feature of Perfect Forward Secrecy (this is not fatal, but PFS looks real good in security audits so it is a fine thing to have).
Either way, the node which performs deep packet inspection must have some privilege access into the SSL tunnel, which makes it rather critical for security.
I would advocate terminating SSL at the load balancer (be that on your network, or at a CDN provider or whatever). It means the LB can inspect the traffic and can do a better job of load balancing. It also means your load balancer is responsible for dealing with slow clients, broken SSL implementations and general Internet flakiness. It’s likely your load balancer is better resourced to do this than your back end servers. It also means that the SSL certs that the world sees are all on the load balancer (which hopefully makes them easier to manage).
The alternative here is to simply load balance the TCP connections from clients to your back end servers. As the LB can’t inspect what’s going on this way, it can’t spread the load evenly across the back end servers, and the back end servers have to deal with all the Internet flakiness. I’d only use this method if you don’t trust your load balancer, CDN provider or whatever.
Whether or not you re-encrypt from the load balancer to your back end servers is a matter of personal choice and circumstance. If you’re dealing with credit cards or financial transactions then you’re probably regulated by government(s) and so will have to re-encrypt. You probably should also re-encrypt if the traffic between load balancer and back end servers is travelling over untrusted networks. If you’re just hosting your company’s website then you might be able to avoid the additional overhead of the re-encryption, if you don’t really care about the security aspects of it.
Re-encryption doesn’t add as much load as you might think though. Usually, the load balancer will be able to maintain persistent connections back to the servers, so the SSL cost will be quite low for that ‘hop’ on the network.
The last thing to think about is the application on the back end servers. If all the traffic that arrives there is HTTP, then it can’t make decisions based on the protocol the client was using. It can’t then say “you’re trying to access the logon page over HTTP, so I’ll redirect you to the HTTPS version of the page”, for example. You can have the load balancer add an HTTP header to say “this came from HTTPS”, but that header would need special handling in the application. Depending on your situation, it may just be easier to re-encrypt and let the application work in its ‘default’ way rather than needing a site-specific modification.
In summary, I’d say: terminate at the load balancer and re-encrypt to your back end servers. If you do this and notice some problem, then you can make adjustments if you need to.
You can choose to encrypt internal traffic with a lower-key certificate. And it’s also advised to position your load balancer as near as possible to your servers to prevent sniffing or man-in-middle attacks. SSL termination can be done at the Load Balancer to offload CPU intensive jobs away from web servers. If the LB brand you have chosen can do certain functions such as inspecting for malformed protocol connections, detect DDoS behaviour, etc..
Our Awesome Free Tools
- Check your IP Address precisely
- Online JSON Formatter with Syntax Highlight
- Online CSS Minifier Compressor
- Online MD5 Hash Generator
- Online SHA-1, SHA-256, SHA-512 Generator
- Online Base64 Encoder/Decoder
- Online CRC-32 Calculator
- Online Triple DES Encryptor/Decryptor
- Best World Clocks