Handling TLS Negotiation for Name Based Virtual Hosting Using SNI
Total Page:16
File Type:pdf, Size:1020Kb
Handling TLS negotiation for name based virtual hosting using SNI Kalpana dwivedi,Assistant professor,ABESEC Abstract Virtualization or virtual hosting is an approach to host multiple domains on single server or pool of servers. This helps to share the resources among services hosted by different domain. This also allows to use same IP address by all domains hosted on same server and therefore avoiding the need of having separate IP for all domains. multiple web applications are hosted on single server using virtual hosting concept. It becomes less expensive as compare to having dedicated server to host individual web applications. Virtual hosting can either be achieved by IP based hosting or name-based hosting. name based hosting saves the IP addresses. in name-based hosting the client is require presenting the hostname. name based hosting saves cost but brings a challenge when hosted domain are to be accessed using HTTPS protocol. HTTPS is an extension to HTTP and used for secure communication over network. when a web resources is accessed over HTTPS, handshaking takes places between server and client using SSL (also called as TLS) protocol, it means communication protocol HTTP is encrypted with TLS (Transport Layer Security) previously known as SSL (Secure Socket Layer) and therefore also been referred as HTTP over SSL or HTTP over TLS. Objective behind evolution of HTTPS was to ascertain the authenticity of the server client is connecting to, ensure the privacy and integrity of the data transmitted over network. encryption of communication could be either unidirectional or bidirectional. When making TLS/SSL connection client request the server the certificate. server send the digital certificate to client. client examines and compares the name(s) available in the certificate with the name it is trying to connect to. If match is not found, then user may be warned of discrepancy in connection which could have occurred probably due to man in the middle attack. However, some applications allow user to ignore the warning and proceed with the connection but JVM in server to server communication does not allow to proceed with connection until TLS handshaking is successful. As we saw that match of the name in certificate with the name client is trying to connect to is required for successful TLS connection. server domain name is registered in the certificate and certificate used to be installed on server. when requested, server presents the certificate installed. likewise, other servers would have their own certificates installed in their setup. Assigning a separate IP address for each site increases the cost of hosting, since requests for IP addresses must be justified to the regional internet registry and IPv4 addresses are now exhausted and therefore situation gets complicated when, through virtual hosting, more than one server are hosted on same IP or group of IPs sharing the infrastructure. In this situation when certificate is requested server could not identify which certificate to be returned to client. This issue does not arise when communication happens over HTTP because from HTTP header, server can extract the hostname client is trying to access. The TLS handshake happens before the server sees any HTTP headers. Therefore, it is not possible for the server to use the information in the HTTP host header to decide which certificate to present and as such only names covered by the same certificate can be served from the same IP address. Server Name Indication or SNI fixes this issue. SNI addresses this issue by having client to send the virtual hostname during TLS negotiation. This enables the server to choose appropriate certificate and return to client. Security implications with SNI Though SNI addresses the issue by resolving hostname during TLS handshaking yet there are some security implications associated with it. Desired hostname supplied to server during handshaking is not encrypted and therefore an eavesdropper can see the server been requested. To address the concern of hostname been exposed to eavesdropper an upgrade to SNI called ESNI (Encrypted SNI) was rolled out in mid of 2018. However, ESNI will be out scope from current work. SNI issue with Netty a high-performance NIO framework Netty is an NIO framework IO operation over computer network or file system. There are some key components in Netty which work in conjugation with each other to carry the IO activities. There components are • Bootstrap • EventLoopGroup • EventLoop • SocketChannel • ChannelInitializer • ChannelPipeline • ChannelHandler Following figure illustrate how these components internally work to achieve their intended task. In order to produce the SNI issue while making TLS negotiation following code snippet using Netty libraries was used. This resulted in SSL handshaking failure. Investigation approach to fix the issue We can see in the log trace that TLS handshaking between client and server failed. After detailed analysis and deep troubleshooting, it was discovered that handshaking failed due to SNI issue. We took following steps to fix the issue. • Downloaded CERT chain from server and imported into client’s certificate key store. • Removed VM option Djsse.enableSNIExtension=false from JVM run time arguments so that it ignore the handshaking failure occurred due to SNI. • Compared the CIPHER supported by server and client and found that intersection of both the list have several ciphers. • Further investigation and analysis suggested that higher TLS version such as TLS1.2 comes with stringent security measures and some time it doesn’t work well with servers where SNI is enabled. To make it work, TLS1.2 downgraded to TLS1.1 and then to TLS1.0 . But this too didn’t fix the issue. Most of the TLS handshaking issue are usually gets resolved by either of above step but this issue continued to persist. We had then broadened the investigation scope to libraries been used in communication. Netty libraries uses NIO (Non-blocking IO) framework. How Netty and NIO works has already been briefed in previous section and detailed discussion is out of the scope of this work. Further analysis revealed that while preparing SSL context, host and port are not been supplied. We discussed with Netty technology forum and explained them the API interface. After discussion, Netty forum realized the shortcoming in API which was resulting in TLS communication failure and after due consultation they introduced an overloaded version which accepts the host and port. New API appeared like below. In highlighted section, host and port are been supplied while preparing SSL handler which was missing in previous code version of Netty. This helped to resolve the issue. Conclusion SNI helped to resolve the problem of server identification for HTTPS request when multiple web applications are hosted on same IP or pool of IPs but accessible their own domain name. This also helped the server to resolve the ambiguity of which certificate to be returned to client during TLS handshaking. Higher version of TLS like TLS1.2 comes with wide range of cipher support and stringent security measures which sometimes doesn’t work well if SNI is enabled on server. Removing SNIEnabled JVM argument during JVM start up, SNI issue can be solved but Netty/NIO continued to pose the error even after disabling the SNI feature in JVM. SNI issue finally got fixed only after induction of an overloaded version of API responsible to prepare SSL handler which started accepting host and port to be supplied during SSL handshaking. Though host name used to be supplied in HTTP header during HTTP/HTTPS communication but since TLS handshaking happens well before any TCP/IP packets are exchanged between client and server, therefore absence of host during handshaking puts the server in dilemma and created ambiguity of which CERT to be returned to client. Future work Though SNI resolved the issue of identification of host for which CERT is to be supplied but it created a security breach in communication. Host is supplied as unencrypted plain text to server and therefore any intruders through man in the middle attach can trap the communication and change the host without letting server know server that original host sent by legitimate client is changed. And if this happens, SSL handshaking failure will continue to happen even if everything is in place in accordance with what is expected. Future work will address this concern referring ESNI (Extended SNI) .