# Truncating TLS Connections to Violate Beliefs in Web Applications Ben Smyth, Alfredo Pironti ## Abstract We identify logical web application flaws which can be exploited by TLS truncation attacks to desynchronize the user- and server-perspective of an application’s state. It follows immediately that servers may make false assumptions about users, hence, the flaw constitutes a security vulnerability. Moreover, in the context of authentication systems, we exploit the vulnerability to launch the following practical attacks: we exploit the Helios electronic voting system to cast votes on behalf of honest voters, take full control of Microsoft Live accounts, and gain temporary access to Google accounts. *Update (October 18, 2014).* This technical report revisits our earlier work (2013) and shows that Google remain vulnerable to the attacks that we disclosed. **Keywords.** Attack, authentication, exploit, Google, Helios, logical flaw, Microsoft, sign-out, single sign-on, TLS truncation, web applications. # Introduction Web applications are distributed, concurrent algorithms that are executed over public communication networks such as the Internet. Since the communication medium is public, there is a possibility of interference by a powerful adversary and this has made the design of secure web applications difficult (Vlsaggio and Blasio 2010). Nevertheless, the burden is somewhat reduced by HTTPS. HTTPS (Rescorla 2000) uses HTTP (Fielding et al. 1999) over TLS (Dierks and Rescorla 2008) to ensure *confidentiality* and *integrity* of a communication session, in particular, integrity ensures that all messages are received as sent. HTTPS is typically used by web applications to protect client-server communication. However, TLS alone is generally insufficient to protect sensitive operations (such as protecting authentication credentials, for example), since the security of such operations is also dependent upon the application logic and TLS provides no protection against logical application flaws. Moreover, TLS only ensures messages are received as sent for a *single* connection and, crucially, does not guarantee the ordering of messages in *multiple* connections; this is particularly pertinent to web applications, due to the use of parallel computation, whereby each simultaneous communication uses a different TLS connection (for example, browsers maintain multiple persistent connections to load content in parallel, thereby reducing latency). Accordingly, web application logic must protect sensitive operations in the presence of parallel computation. In this report, we highlight logical application flaws which permit desynchronisation between the application’s state, as perceived by the user and the server, by truncating selected TLS connections. Furthermore, we exploit the desynchronisation to attack real systems. ## Application state In web applications, the user is typically notified of the server’s state using some feedback mechanism (Nielsen and Molich 1990; Norman 1998). Feedback can be *positive*, when the user is notified of successful state changes, or *negative*, when the user is notified on errors. The absence of feedback can cause confusion – for instance, if a user attempts to save a file and no feedback is provided, then the user does not know if her file was saved or not – and violates basic design principles (Ko and Zhang 2011). By comparison, we focus on incorrect feedback: web applications that generate (positive) user feedback *before* the server has committed to a state change. ## Truncating TLS connections TLS security guarantees are defined with respect to the following termination modes: *graceful* connection closure (that is, at the end of a successful connection) and *fatal* closure (that is, at the end of an unsuccessful connection, for example, after receiving a corrupt message). In the event of graceful closure, TLS ensures that *all* messages are received as sent, by comparison, in the event of fatal closure, TLS ensures that a *prefix* of all messages are received as sent. At a lower level of abstraction, TLS is permitted to split messages into *fragments*, and TLS guarantees ordered delivery of all fragments on graceful closure and a prefix of all fragments on fatal closure. Historically, graceful and fatal closure modes were not supported in SSL (TLS’s predecessor) until version 3.0 (Freier, Karlton, and Kocher 2011). Today, TLS termination modes are not distinguished by many applications, indeed, major browsers (including Internet Explorer, Firefox, Chrome and Safari) and HTTP servers do not always distinguish between graceful and fatal closure. As a consequence, the TLS specification notes *“failure to properly close a connection no longer requires that a session not be resumed \[...\] to conform with widespread implementation practice"* (Dierks and Rescorla 2008, sec. 7.2.1). Unfortunately, ignoring the termination mode can result in TLS truncation attacks (Berbecaru and Lioy 2007). Let us illustrate such a truncation attack with a simple example (Delignat-Lavaud, Pironti, and Smyth 2013). Suppose a user initiates a wire transfer to *Charlie’s Angels* using the following HTTP request:
For your safety, we have logged you out.
... 3. GET: