HEIST: HTTP Encrypted Information can be
Stolen through TCP-windows

Mathy Vanhoef and Tom Van GoethemiMinds-DistriNetmathy.vanhoef@cs.kuleuven.be - tom.vangoethem@cs.kuleuven.beOver the last few years, a worryingly number of attacks against SSL/TLS and other securechannels have been discovered. Fortunately, at least from a defenders perspective, these
attacks require an adversary capable of observing or manipulating network traffic. This prevented a wide and easy exploitation of these vulnerabilities. In contrast, we introduce HEIST,a set of techniques that allows us to carry out attacks against SSL/TLS purely in the browser.
More generally, and surprisingly, with HEIST it becomes possible to exploit certain flaws in
network protocols without having to sniff actual traffic.
HEIST abuses weaknesses and subtleties in the browser, and the underlying HTTP, SSL/TLS,
and TCP layers. In particular, we discover a side-channel attack that leaks the exact sizeof any cross-origin response. This side-channel abuses the way responses are sent at the
TCP level. Combined with the fact that SSL/TLS lacks length-hiding capabilities, HEIST candirectly infer the length of the plaintext message. Concretely, this means that compressionbased attacks such as CRIME and BREACH can now be performed purely in the browser, by
any malicious website or script, without requiring a man-in-the-middle position. Moreover,
we also show that our length-exposing attacks can be used to obtain sensitive informationfrom unwitting victims by abusing services on popular websites.
Finally, we explore the reach and feasibility of exploiting HEIST. We show that attacks can be
performed on virtually every web service, even when HTTP/2 is used. In fact, HTTP/2 allows
for more damaging attack techniques, further increasing the impact of HEIST. In short, HEIST
is a set of novel attack techniques that brings network-level attacks to the browser, posing an
imminent threat to our online security and privacy.

1

Introduction

With initiatives like Let’s Encrypt, and CloudFlare’s Universal SSL, we are (finally) reaching a stage where most of our online web traffic is encrypted. Unfortunately, we are not

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 2 of 27

quite there yet. Over the last few years, there has been a trend where every few months
a serious vulnerability on SSL/TLS is discovered. Although this poses an immediate andsignificant threat to our online security, there have been few reports where these vulnerabilities are in fact widely exploited (attacks by government agencies being the exceptionhere). Most of the large service providers are relatively fast at minimizing the threat,either by applying the right defenses or applying sufficient preventive measures (unfortunately, exceptions apply here as well). Another limiting aspect that prevents wide
exploitation, is that in the typical threat model, the adversary should be able to observeor alter the network traffic between the client and the server. Probably, this will not holdback certain state-sponsored agencies or the occasional attacker that manages to get on
the same wireless network as the victim. However, if these attacks would no longer require network access, all bets are off. For example, if the only requirement would to be
to make the victim run malicious JavaScript, anyone with malicious intents can performthe attack, regardless of geographic location. With HEIST, we introduce a multi-purpose
set of attack vectors that show this has in fact become reality: physical network access is
no longer a requirement to exploit network-based web attacks.
We show that by combining weaknesses and unexpected behavior in the interaction of
mechanisms at various layers, including the browser, HTTP, SSL/TLS and TCP, it is possible to uncover the length of any (cross-origin) response in the browser. More concretely,
this means that because SSL/TLS does not hide the length of the clear-text message (aweakness that has been well-known to the security community since 1996 [15]) adversaries can directly infer the length of the response before encryption. One of the most wellknown, and still highly prevalent attacks that exploits this weakness, is BREACH [10].
With HEIST, we show that BREACH can now be performed by any malicious website,
without requiring network observation capabilities. Moreover, we extend the reach oflength-exposing attacks, and propose attacks that can extract sensitive information about
the victim by exploiting various endpoints.
We evaluate the practicality of HEIST and introduce techniques that can be used to significantly improve its performance. By analysing the consequences of switching to thenew, “improved” version of HTTP (HTTP/2), we find that even more attack scenarios canbe exploited. Finally, motivated by the pervasiveness and severe consequences of HEIST,
we discuss possible defense mechanisms, both on the side of the client as well as on theserver.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

2

page 3 of 27

HEIST attack

In this section, we first give a brief introduction to the different mechanisms that contribute to HEIST, and show this can be exploited. Next we show how the basic attack
can be further extended to become universally applicable. Finally, we explain the consequences of upgrading to HTTP/2, and introduce attacks that are specific to that protocol.

2.1

The foundations of HEISTOne of the most recent evolutions in the architecture of browsers came with the introduction of Service Workers [13]. The main goal of this set of new APIs is to provide developers with a more flexible way to influence the way requests and responses are handled.
With regards to the network layer, the most important interface to look at, is the Fetch
API [12]. In terms of functionality, this API has a lot of similarity with XMLHttpRequest
as both APIs allow the web developer to make arbitrary requests. The main differenceis that the Fetch API is built as a starting point for other APIs, such as the Cache API.
This means that it should be possible to fetch() any resource, including authenticatedcross-origin ones. Because of the Same-Origin Policy principle it is obviously not possible
to simply read out the response of a cross-origin request.
Another difference between the two APIs, is that the Fetch API works with Promises
instead of Events. This means that when a request is fetched, a Promise object isimmediately returned. The Promise object can then either resolve or fail, dependingon the outcome of the fetch() process. An interesting feature of the resolution ofthis Promise, is that it happens as soon as the first byte of the Response is received.
Concretely, this means that after the initial TCP handshake and SSL/TLS negotiation, thebrowser sends out the GET or POST request to the server, and waits for a response. As
soon as the first byte of the response enters the browser, the web page is notified (bymeans of resolving the Promise), and can start working with the Response that is still
streaming in. Basically, this works as follows:

fetch('https://example.com/foo').then(function(response) {// first byte of `response` received!
});

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 4 of 27

Figure 1: A typical TCP flow for an HTTP request with corresponding response

At first sight, this behavior does not introduce any vulnerability, and in fact improves
the browser performance as the browser can start processing the response even before
it has been completely downloaded. However, when we take a closer look at the TCP
internals [1] and introduce another browser API, things start looking a lot more gloomy.
Let’s first zoom in on what happens at the TCP level for a typical HTTP request. Afterthe three-way handshake, the client sends a TCP packet containing the request, which
typically consists of only a few hundred bytes. As soon as this TCP packet reaches theserver, the web server generates a response and sends it back to the client. When this
response grows larger than the “maximum segment size” (MSS) the server’s kernel will
split up the response in multiple segments. These segments will then be sent according
to the TCP Slow Start algorithm. In practice, this means that an initial number of TCP
segments (predefined by the initial congestion window (initcwnd) setting, which istypically set to 10) are sent [6]. For each acknowledged packet, the next congestion
window is then increased to allow for a higher bandwidth.
Looking back at what this means for the Promise returned by fetch(), we can see thatin fact the time the Promise resolves coincides with the receipt of the initial congestionHEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 5 of 27

fetch('https://example.com/foo').then(function(response) {// first byte of `response` received!
T1 = performance.now();});
setInterval(function() {var entries = performance.getEntries();
var lastEntry = entries[entries.length - 1];
if (lastEntry.name == 'https://example.com/foo') {T2minT1 = lastEntry.responseEnd - T1;}}, 1)
Figure 2: An example of how to obtain T2 − T1window1 (see Figure 1). This means that if we know when the resource has been completely downloaded, we can in fact find out if the response fits in a single TCP window, or
required multiple. For this, we can resort to the Resource Timing API [14], whose purpose
is exactly that: providing developers with performance metrics that show when a request
was initiated, and when it was complete. Using performance.getEntries() we canget the PerformanceResourceTiming of the corresponding request, and discover thetime the response was completely downloaded by looking at the responseEnd attribute.
An example of how this would look like in JavaScript code, is provided at Figure 2.
We can make arbitrary requests to any website (at T0 ), discover when the first byte (andTCP window) was received (T1 ), and find when the response was fully received (T2 ).
By looking at the time interval between the time the first byte was received, and when
the response was completely downloaded, we can find out whether the response took
up a single window or required multiple. Figure 3 shows a timeline of an HTTP request
and its corresponding response, where the response fits in a single window. The same isshown in Figure 5, but for a request that required two windows. When looking at both
timelines, it is clear that when only a single window is used, T2 − T1 is very small; inpractice this is in the range of 1ms. In case a second TCP window is required, T2 − T1
is increased with an additional round-trip. In practice the value for T2 − T1 of a “twowindow” response is significantly higher than for a “single window” response.
1

This is because the network congestion is several orders of magnitude smaller than the round-trip time

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 6 of 27

Figure 3: Timeline of an HTTP request whose response fits in the initial TCP congestion
window

Figure 4: Timeline of an HTTP request whose response requires two TCP windows

In summary, we can discover whether a response is smaller or larger than the initialcongestion window. For most installations, which use the default initcwnd value of 10
and Maximum Segment Size (MSS) of 1460, this boils down to finding out whether a
response is smaller or larger than approximately 14kB. While this could perhaps be used
to find out if a user is logged on at a certain website (small error message when notlogged in, large response when logged in), it is not that severe. In the following sections,
we will show how we can leverage several techniques to drastically increase the impactof HEIST.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 7 of 27

Figure 5: Finding the tipping point to differentiate between one or two TCP windows.

2.2

Determining the exact size of responses

Other than knowing a rough approximation of the length of a response, typically it ismuch more useful for an attacker to know the exact size of a response. Note that withexact size, we mean the size after gzip compression, and after encryption (for stream
ciphers, the length remains the same; for block ciphers, the length is rounded up to thenext full block). A clear example that shows the severity of knowing the exact length ofa response is the BREACH attack. This attack leverages the compression rate of HTTP
responses to infer secret data on the page. For this, it needs to know the exact response
size after compression. We explore this attack in more detail in Section 3.1. In thissection, we give an indication of techniques that can be used to infer the exact size of a
response.
In a first technique, we’ll show that when a parameter of the request (either GET or POST)
is reflected in the response, we can leverage this to find the exact size. Conceptually, we
can split up the response in two parts: a part of which we try to find the exact length, andthe parameter that is reflected. The latter is completely controlled by the attacker. To findthe exact size of the unknown part, we can repeatedly choose the reflected parameter insuch a way that we try to find the largest possible size for which the response still fits in
the initial TCP window. We can then compute the size of the unknown part by subtracting
the length of the reflected parameter from the size of initial TCP windows (which is a
fixed value for each web server). After this, we simply need to subtract the overhead of
HTTP and SSL/TLS headers (the length of both are predictable). An example: we findthat when the reflected parameter is 708 bytes long, it fits in a single TCP window; for709 bytes, the total response needs 2 TCP windows. Given an initial TCP window of14600 bytes (= 10 · MSS), 528 bytes of HTTP response headers, 26 bytes of SSL/TLS
overhead; we find the size of the response as 14600 − 529 − 26 − 708 = 13337 bytes.
As we can divide the search space in 2 with every choice of reflected content length,
searching for the exact size requires a logarithmic number of steps. Looking in the range

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 8 of 27

of 14600 possible values then takes 14 requests. However, we can make two major
improvements on this algorithm. First, the browser allows for 6 parallel connections to asingle host. If we use these 6 concurrent connections, we can divide the search space in
7 with each iteration. As a result, we reduce the time required to perform the attack (onaverage, a speedup of 280%) at the cost of making more requests. To further improve
the attack, we make the observation that usually the largest part of the response is static
or predictable. This allows us to reduce the search space, often to a few hundred bytes.
This improvement is also of key importance, as we’ll explain in Section 3.1.
Although there are many instances where a parameter is reflected on the web page, there
may also be cases where this is not possible. Nevertheless, it may still be possible to resort to case-specific alternatives when there are no reflected parameters. For instance,
consider that an adversary is interested in knowing the length of an email of the victim(we explore this example in more detail in Section 3.2). For this, he wants to know thesize that is returned by the POST request to https://mail.provider.com/search,with parameters from:bank.com AND intitle:Password. Unfortunately for the attacker, the search query is not reflected in the result set. However, using an attack against
a social network website, the adversary managed to obtain the email address of the user.
The attacker then sends a large number of emails to the victim2 , each with a different
length. Now, instead of using a reflected parameter, the adversary can just include his
own emails in the result-set by modifying the search query, and use that to infer the exact
size. A search query would then become something like(from:bank.com AND intitle:Password)
OR intitle:length1203
OR intitle:length7632
This allows the adversary to apply the same technique as with the reflected parameter,
by just changing the notion of reflected content as their own email. It should be notedthat this is a case-specific technique, and similar (or different) techniques can be applied
depending on the target.

2.3

Applying HEIST to larger responses

In the previous sections, we have shown how HEIST can be applied to obtain the exact
length for responses that fit in the initial TCP window. While this may be sufficient for2

The attacker includes keywords such as “viagra”, “cialis” and “Nigerian prince” to make sure the emails
end up in the spam folder of the victim, thus raising no suspicion.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 9 of 27

certain use-cases, it is definitely not universally applicable. This section will focus on how
we can extend the reach of HEIST to being applicable on virtually any website, even withrelatively large responses. For this, we go back to the TCP Slow Start mechanism. As
mentioned before, this algorithm forces TCP to start with an initial congestion windowof a predefined size (default: 10). In order to allow for higher bandwidth, TCP Slow
Start provides a mechanism to increase this window. More precisely, for every packet
that is acknowledged, the size of the congestion window is incremented by 1.
As such, we can systematically increase the TCP congestion window by first sending abogus request to a resource of a known size. For instance, if we first request a resourcethat fits in exactly 4 TCP packets, and then request the resource of which we want toknow the size, the server will answer with up to 14 TCP packets in the initial window. To
analyse what happens exactly with the congestion window, we created a kernel modulethat intercepts TCP-related kernel functions and prints out the current state of the TCP
connection. In particular, it prints the number of unacknowledged packets (“packets inflight”) and the current congestion window (CWND).
Figure 6 shows the output of our kernel module. In this specific example, we first sendout a request (Request 1) for which we know the response size (21 TCP packets).
Upon receipt of the request from the client (just before the timestamp 195.719), theserver sends back the first part (10 TCP packets) of the response. These packets arethen acknowledged by the client, resulting in the growth of the congestion window to
20. Upon receipt of the ACKs from the client, the server sends the remaining 11 TCP
packets of Response 1. As soon as the client completely received the response, it sends
off Request 2, for which the response spans 15 TCP packets. Because the congestion
window had been increased to 20, the server will now send all 15 packets at once.
To sum up: it is possible to increase the congestion window to an arbitrary value (startingfrom the initcwnd value). In an actual attack scenario, the adversary would typicallyfirst try to find the lowest number of TCP packets that still fits the response. This can bedone in a similar way as finding the “tipping point” of the reflected parameter, meaning it
can also be done in a logarithmic number of requests. Once this number has been found,the adversary can fall back to the same methodology to determine the exact size of the
response. Interestingly, increasing the congestion window to fit a resource, comes with anadditional benefit. By using this method, the length of content that needs to be reflected
in order to find the exact size is at most 1 · MSS (1460 bytes). This is particularly usefulwhen a GET parameter is reflected in the response, as some servers restrict the maximum
allowed length of the URL.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 10 of 27

Figure 6: Analysis of the TCP congestion window

Combining all of the above techniques allows us to determine the exact size of any resource, as long as a parameter is reflected in the response (or an alternative approachis possible). In the next section, we will show that in the case of HTTP/2, we can relax
these restrictions even further.

2.4

Consequences of HTTP/2

Another recent evolution is the introduction and adoption of HTTP/2. Designed to be adrop-in replacement of the older and common HTTP/1.1 protocol, it is steadily getting
more traction [3]. For example, most major browsers now support HTTP/2, and prominent websites such as Twitter, Google, Facebook,. . . also support HTTP/2. Since we
expect that more and more websites will move to HTTP/2, we investigated how it affects
our attacks. Surprisingly, we found that not only do our attacks remain possible, we caneven increase the damaging effects of our attacks by abusing new features of HTTP/2.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

length type flags

streamId

payload3 bytes 1 byte1 byte

4 bytesvariable

page 11 of 27

Figure 7: Simplified HTTP/2 frame layout.

2.4.1

A quick introduction to HTTP/2

The goal of HTTP/2 is to provide a more efficient transportation of HTTP messages. The
semantics of HTTP messages are not modified. For example, a client still constructs traditional GET and POST messages, to which the server replies with appropriate responses.
This also means that existing websites and JavaScript code continues to work exactly as
before. In particular, the service workers and Fetch API that we currently rely on, can still
be abused in our attacks. However, on the network level, request and response messages
are now encoded and handled in a new manner. This does effect the execution of ourattacks.
First, HTTP/2 is designed so a single TCP connection can be used to send and receive
parallel requests. This means browsers no longer have to open multiple parallel TCP
connections with a server. Instead, all requests are made in a single HTTP/2 connection.
Internally HTTP/2 supports parallel requests by creating so-called streams for each request and response pair. Naturally, multiple parallel streams can be created in a single
HTTP/2 connection. The basic transmission unit in a stream is called a frame, whose format in shown in Figure 7. Each frame has a field that identifies the stream it belongs to(called the streamId field). Several types of frames exist, with the two most common
being header and data frames. Header frames encode and compress HTTP headers
using HPACK, and data frames contain the body of HTTP messages. Nearly all otherframes are used for management purposes, and we call them control frames. One common control frame is the settings frame. Endpoints (the client or server) use this toinform the other endpoint about specific HTTP/2 features (or configuration values) thatit supports.
An example GET request is shown in Figure 8. The client starts by sending a “magic”
frame to indicate that HTTP/2 will be used. Then it sends a settings frame to informthe server about the maximum number of concurrent streams it supports, the maximum
supported frame size, etc. In the same TCP packet the client includes the GET request in
the form of a headers frame. In response, the server first acknowledges the settings ofthe client by replying with an empty settings frame that has the HTTP/2 ACK bit set,

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 12 of 27

Figure 8: Packets transmitted during a HTTP/2 request as shown by Wireshark.

and then sends his own settings frame to the client. After the client acknowledged thesettings of the server, the server replies with the HTTP headers of the response, andfinally with a data frame that contains the body of the HTTP response.

2.4.2

Determining exact response sizes for HTTP/2

The attack of Section 2.2, where reflected content was used to determine the exact size ofa resource, can also be performed when HTTP/2 is used. More precisely, an attacker canstill abuse reflected content to find out at which point the first TCP window is completely
filled, and a second TCP window is required to receive the complete response. The only
difference is that HTTP/2 introduces additional overhead, which the attacker must take
into account when calculating the size of the targeted resource.
The first type of overhead is caused by control frames sent by the server. For example,
in the example HTTP/2 request of Figure 8, there are in total two settings frame sentby the server. No other control frames are present. We found that against both nginx
and Apache, the number of control frames, as well as their length, can be predicted. And
since we know how many frames are sent in total, we can also calculate the amount ofoverhead that is introduced by the 9-byte header of in every HTTP/2 frame (see Figure 7).
All that is left, is to predict the length of the headers frame sent by the server. This
frame contains the HTTP headers of the response, compressed using HPACK. The firsttime a header field (or value) is transmitted, HPACK transfers the original value of the
field, and assigns an index to this particular value. Whenever this same field or value isagain transmitted in the same HTTP/2 connection, only the assigned index is transferredinstead of the complete value. An example of this is shown in Figure 9. Here both theserver and x-powered-by header were already transferred once in a previous header
frame, meaning they can now be encoded using just a single-byte index. Interestingly,

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 13 of 27

Figure 9: Example where HPACK compresses header values to a single-byte index.

this means HPACK makes it easier to predict the length of the header frame. Indeed,
we no longer have to predict the length of all header fields and values, since HPACK
compression replaces them by a 1-byte index. This is rather surprising: while HPACK
was designed to make length-based attacks such as CRIME harder, it makes it easier topredict the length of the headers frame itself, which in turn makes our attacks easier.
For example, say we find that when the reflected parameter is 1141 bytes long, it fits in asingle TCP window. But when it’s 1142 bytes, the total response needs 2 TCP windows.
Given an initial TCP window of 14600 bytes (= 10 · MSS), we subtract 0 + 6 for the
body of the two HTTP/2 settings frames, 10 · 9 for the ten HTTP/2 frame headers,and finally 26 bytes of SSL/TLS overhead. This means the size of the targeted resourceis 14600 − 6 − 90 − 26 − 1141 = 13337 bytes.

2.4.3

Abusing reflective content in another resource

In our original attack of Section 2.2, we had to rely on reflected content in the targetedresource itself. When HTTP/2 is used, we can relax this condition by abusing reflected
content in another resource on the same website. Recall that reflective content was usedfill the TCP window until the complete response no longer fitted into the first TCP window.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 14 of 27

Figure 10: Using reflected data in a parallel HTTP/2 request to fill the first TCP window.

If we know that HTTP/2 is used, we can let the browser simultaneously request thetargeted resource, and another resource that contains reflected content. Since HTTP/2
is used, both requests are sent in parallel to the server, and the server replies to them inparallel as well. This is illustrated in Figure 10. Here both requests and responses are sent
simultaneously in the same TCP connection, and hence share the same TCP window3 .
Notice that in Figure 10, the response to the resource containing reflected data (therequest to /reflect) fills in a large part of the initial TCP congestion window. The
response to the targeted resource uses the remaining space of the window. This allows
us to abuse the /reflect resource to fill up the initial TCP congestion window, until
there is no longer sufficient space to also include the targeted resource in the window.
By using HEIST to measure when a second TCP congestion window is needed, we canagain determine the size of the targeted resource. To sum up, when HTTP/2 is used,
the only requirement to perform our attack is to find reflected content in any page of thewebsite.

3

Note that if we would initiate two requests at the same time in HTTP/1.1, the two requests would be

handled using two different TCP connections, whom each would have their own TCP windows.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows3

Attack scenarios

3.1

BREACH

page 15 of 27

We demonstrate that well-known compression-based attacks such as CRIME or BREACH(but also lesser-known ones [8]) can be executed by merely running JavaScript code in
the victim’s browser. This is possible because HEIST allows us to determine the length ofa response, without having to observe traffic at the network level. In particular we focus
on BREACH, since many websites are (still) vulnerable to this attack.
The BREACH attack abuses gzip compression of HTTP responses to recover secret tokens
in these responses. To carry out the original BREACH attack, an attacker must be able
to [10]:1. Inject chosen plaintext into the server’s response.
2. Observe network traffic to measure the size of encrypted responses.
The idea behind the attack is that if the attacker injects a prefix of the secret token, gzip
will detect this repetition, and will therefore more efficiently compresses the response.
It was demonstrated this can be used to decrypt, among other things, CSRF tokens. For
example, in a demonstration of the attack, they exploited the observation that Microsoft’s
Outlook Web Access reflects parameters of the URL in the response. So a request tohttps://site.com/owa/?ae=Item&t=IPM.Note&a=New&id=canary=<guess>would result in<span id=requestUrl>https://site.com:443/owa/forms/
basic/BasicEditMessage.aspx?ae=Item&amp;t=IPM.Note&amp;a=New&amp;id=canary=<guess></span>...
<td nowrap id="tdErrLgf"><a href="logoff.owa?
canary=d634cda866f14c73ac135ae858c0d894">
Log Off</a></td>

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 16 of 27

Here canary contains the CSRF token used by the web service. If the first character(s) ofguess match that of the CSRF canary, gzip can effectively remove the second appearanceof the substring, resulting in a shorter compressed response. In other words, if our guess
for the next character of the token is correct, the resulting compressed response is shorter.
Using HEIST it becomes much easier to meet the second requirement: we can measure
the size of the encrypted response in the browser, instead of needing a man-in-the-middle
position to observe network traffic. In other words, the BREACH attack against Microsoft
Outlook Web Access can be executed purely in the browser using (malicious) JavaScript.
The attack can also be applied against other sensitive information that is present on
web pages, such as email addresses, usernames, or other (static) personally identifying
information.
A few technical difficulties arise when attempting to perform the attack in practice4 . We
will briefly discuss the most important ones, other technicalities were already discussed
in the original BREACH paper [10].

Huffman Encoding. Gzip compression is based on the DEFLATE algorithm, which uses
a combination of LZ77 and Huffman encoding [5]. It’s the LZ77 component that searches
for duplicate substrings, and hence is the component that makes BREACH possible. For
example, LZ77 would compress the input

Secret csrf=d634cda866f14 and reflected=csrf=d634cd<padding>by replacing the second occurrence of csrf, together with the other matching charactersin the reflected input, with a reference to the first occurrence:

Secret csrf=d634cda866f14 and reflected=@(11,33)<padding>
Here @(11,33) is a reference to the 11-character string that started 33 characters before the current position. Clearly, if we correctly guess the next character, the response
will further shrink in size. The problem is that Huffman encoding could also cause theresponse to shrink in size. Recall that the goal of Huffman encoding is to more efficiently
compress common symbols (bytes). Essentially, frequent byte values are encoded using
4

Naturally we restricted ourselves to attacks against our own accounts to avoid harming innocent servers
and users.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 17 of 27

a short bitstring, while infrequent byte values are encoded using a larger bitstring. For
example, the letter e occurs a lot in English texts, and is likely represented using a short
bitstring. So if our next guess would be d634cde, the compression could be shorter simply because e is represented using a shorter bitstring after Huffman encoding (and not
because it is a correct guess). We can solve this problem by issuing two requests for eachguess. In our example we would try both d634cde| and d634cd|e. Then there are two
possibilities:
1. If the guess is incorrect, both e and | are represented using a Huffman code. Thismeans both guesses will result in compressed responses of the same length.
2. If the guess is correct, then the e in d634cde| is compressed with LZ77 using a reference, and only the character | is represented using Huffman encoding. However,in d634cd|e, both characters are compressed using a Huffman code. Therefore acorrect guess means the compressed length of d634cde| and d634cd|e differ.
To summarize, we have a correct guess if d634cde| and d634cd|e result in a different
compression length.

Maximum reference distance. In DEFLATE and gzip, the LZ77 component can insert areference to a string that occurred at most 32·1024 bytes before the current position [5].
This means that in order to execute the (original) BREACH attack, the reflected input
must be close enough to the targeted token.

Block Ciphers

The attack requires that we are able to detect a 1-byte difference in thelength of the (compressed) responses. Even when block ciphers are used, the following
technique can be used to reliably detect this difference. The idea is to first pad the
response using reflected content so that, if the response would be one byte shorter, thelast block is no longer needed. This boundary point can be detected using HEIST bysending at most log2 (16) = 4 requests, assuming the cipher operates on blocks of 16
bytes. If a guess now results in a response that is one byte shorter, the last block is nolonger needed, and hence can be detected.

3.2

Web-based length exposure

In this section, we show that next to extracting secret tokens from a web page by using CRIME or BREACH attacks, length-exposing vulnerabilities can also be exploited in

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 18 of 27

different ways. To give some insight into the potential attack scenarios, we present two
examples. In the first example, we will show how a website’s search functionality canbe abused by an attacker to steal sensitive content such a credit card information, passwords,. . . For the second example, we focus on personal health websites, and demonstrate how adversaries could apply HEIST to obtain our private health information.
For this section, there are two important things to note. First, we only present two different attack scenarios. By far this is not the definitive set of possible attack scenarios. The
type of attack that can be performed on a website is typically based on the functionality
it offers. We made a selection of attack scenarios to include based on their severity andprevalence in popular web services. A second thing to note is that the examples presented here are fictitious. The reason behind this decision is that the attacks presented
here are generally applicable and do not require a specific implementation method by
the web server. We managed to successfully perform very similar attacks against multiple of highly popular (billions of users) web services5 . The attacks reflect the generalfunctionalities provided by these services, and thus the consequences are frighteningly
close to reality.

3.2.1

Search-based information disclosure

The running example we use to illustrate this attack scenario, is based on a web-based
mail provider named SnailMail who can be reached at https://snailmail.org. Just
as any self-respecting mail provider is supposed to do, SnailMail makes sure their customers are well protected: all traffic is only sent over a secure TLS connection using
the AES-GCM ciphersuite, HTTP Strict Transport Security and HTTP Public Key Pinningare enabled, and compression (both on SSL/TLS as HTTP level) is disabled to prevent
BREACH and CRIME attacks. Of course, SnailMail also took the necessary precautions
to completely prevent web attacks, thereby making it virtually impenetrable.
Just as any other web-based mail provider, SnailMail allows users to search through theemails that they have sent or received. Technically, this done with a POST request to the/search endpoint. This endpoint will return the results for the query (provided in the qparameter) in JSON format. This JSON data contains the original query6 and metadata(sender, subject, date, first line of message, ...) for each message that matches they query.
5

Of course, we performed these attacks against our own accounts, and neither humans, animals nor
servers were harmed during our experiments.
6
This is not a requirement when either HTTP/2 is used, or the attacker uses a technique as discussed
in Section 2.2.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 19 of 27

Alice, the victim in this example, is a frequent user of SnailMail, and entrusts them withstoring her most important emails, including emails from her bank. Unfortunately, Alice’s bank is notorious for not being too concerned with their customer’s security7 . For
instance, they are known to send unmasked credit card information to their customers
over email. Due to the security precautions taken by SnailMail, Alice has not experienced any nefarious consequences because of this. However, one day Alice decides tolook for funny cat images, and ends up on a website (catpicz.com) that is under thecontrol of the attacker. While browsing the innocuous-looking website, and laughing at
the hilarious cat pictures, Alice’s credit card information is being stolen.
By looking at the length of responses for different search queries on Alice’s mailbox,
the attacker is able to reconstruct the numbers on the credit card piece by piece. Moreconcretely, the queries that the attacker makes Alice send, look as follows:(from:bank.com AND intitle:"MasterCard") AND(5100 OR 5101 OR 5102 OR ...) OR(bogus_data_that_is_reflected_to_reach_initcwnd)
The JSON responses that contain results then look as follows:{"query": "(from:bank.com AND intitle:\"MasterCard\") AND(5100 OR 5101 OR 5102 OR ...) OR(bogus_data_that_is_reflected_to_reach_initcwnd)","results": [{"sender": "info@bank.com","subject": "Your MasterCard information",...
}]}
The attacker makes sure that when the response from SnailMail contains no results, thecomplete response fits in the initial congestion window. When the attacker then sees a
response that requires two TCP windows, he knows that the correct number is part ofthe set he tried. The attacker then keeps on decreasing the search space for possible
7

Alternatively, Alice may have emailed the credit card information to a friend, or even herself.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 20 of 27

numbers until an exact match has been found. When using only a single connection, thecomplete credit card information (including CVV) can be retrieve with just 61 requests.
Given that the round-trip time between Alice and SnailMail is approximately 50ms, theattack would only take 4.6 seconds. When making use of 6 concurrent connections, theattack may take up to 138 requests, but can be executed in 1.2 seconds.

3.2.2

Revealing personal user state

When visiting a website, users are typically provided a personal view that is customized
based on the information they shared with the website. For instance, when looking at thehome page of a social network website, users are presented with a stream of updates of
their peers. In this section, we will show that by analysing the length of specific requests
to websites, it is possible for attackers to infer the information the victim shared with thewebsite. Again, we will explain this attack scenario by the means of a fictitious website.
The fictitious company (PatientWeb) now involves a personal health website that allows
users to track their health records and receive information about their disease. Again,
the website is armed to the teeth to thwart attacks on the privacy of their users. The
developers of PatientWeb are really concerned about the performance and security of
their website. As a result, they enabled HTTP/2 and made sure BREACH could not be
exploited by preventing data originating from the request to be reflected on a web page
containing sensitive information.
The adversary in this example is a malicious party who sells sensitive health information
to insurance companies. Unfortunately, the attacker does not care about the privacy
concerns of the people they sell information on. As such, the attacker will even resort
to web attacks to obtain personal information, and PatientWeb is definitely a gold minefor that. To gather information, the attacker first sets up a website where users may win
coupons for a number of grocery stores, and drives users to this website by sending spam,and sharing it on social media.
When visiting the malicious website, the attacker first verifies which websites the user islogged in to, and launches specific attacks per target. For PatientWeb, the adversary will
apply HEIST in order to determine from which condition the user suffers. In a preparatory
phase, the attacker registered a large number of accounts at PatientWeb, and selected adifferent condition for each account. At regular intervals, the size (in bytes) of the news
feed for each condition is collected.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 21 of 27

To determine from which condition someone suffers, all the attacker needs to do is determine the size of the news feed that is returned for the victim. This will coincide withthe size of a particular news feed that was collected in the preparatory phase, allowing
the attacker quickly determine the exact condition. In the attack, the adversary will needto resort to the attack technique that is specific to HTTP/2 as there is no content of therequest reflected in the response. To expose the exact response size, the attacker will
either try to find a different endpoint for which content is reflected in the response, or
combine existing resources (images, scripts, stylesheets, ...) to obtain a similar result.
Even with an extensive list of possible conditions, the attacker is able to pinpoint thevictim’s condition in less than a second. An overview of the attack scenario can be foundin Figure 11.

4Countermeasures

The attack techniques behind HEIST span over multiple layers (browser, HTTP, SSL/TLS,
TCP). In this section, we provide an overview of possible defense mechanisms that can beused to thwart attacks, or make it harder to exploit. We also discuss techniques that lookpromising but in fact fail to properly prevent attacks, or can be circumvented. The titleof each countermeasure indicates the level of the completeness, ranging from infeasible
to complete.

4.1

Browser layer

4.1.1

Prevent browser side-channel leak (infeasible)

Probably the most obvious countermeasure against HEIST is to prevent an attacker fromfinding out when the first byte of a response has been received. This could be achieved byfor instance resolving the Promise only when the complete response has been received.
However, we argue that this method is insufficient to properly prevent attacks leveraging HEIST. The main reason for this, is that there are in fact multiple techniques thatcan be used to infer the moment the initial congestion window has been received. For
instance, the presence or absence of certain response headers cause browsers to expose
specific behavior. These actions occur as soon as response headers have been received(this coincides with receiving the first congestion window), and can be observed by the

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 22 of 27

Figure 11: An overview of the attack scenario described in Section 3.2.2.

adversary. Although it may be possible to prevent all side-channel leaks, we consider thisan unlikely event: the general browser architecture needs to be significantly altered, andany new feature may introduce a new side-channel.

4.1.2

Disable 3rd -party cookies (complete)

When the attacker makes the victim initiate requests to the target website, a user-specificresponse is returned. This is because the victim’s cookies are included in the request,
which means that from the website’s perspective the requests are part of the victim’s
browsing session. By preventing these cookies from being included, the request would

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 23 of 27

be unauthenticated and no user-specific content will be returned, and thus can’t be stolen.
Obviously, it is not possible to block all cookies (as this would prevent us from logging into any website), however it is possible to disable 3rd -party cookies. Concretely, this meansthat when navigating to https://attacker.com, cookies would only be included inrequests (e.g. for images, scripts, ...) to the same origin.
Currently, most major browser vendors provide a way to disable 3rd -party cookies, but
may prevent features of certain websites from working correctly. Nevertheless, we consider this approach one of the best ways to prevent possible attacks.

4.2

HTTP layer

4.2.1

Blocking illicit requests (inadequate)

Similar to the defense of blocking 3rd -party cookies, the web server could also block
requests that are not legitimate. A popular way of doing this, is by analysing the Origin
and/or Referer request headers. This allows the web server to determine whether therequest originated from its own domain or a potentially malicious one. However, it isstill possible to make requests without these two headers, preventing the web server todetermine where to request originated from. As a result, this technique can not be used
to prevent attacks.

4.2.2

Disable compression (incomplete)

HTTP responses are often served with compression (either at SSL level, or using gzip) to
reduce the required bandwidth. It is a well-known fact that this leads to compressionbased attack such as CRIME (SSL compression) and BREACH (gzip). Preventing these
attack from being exploited in the browser can be done in the same way as preventing thegeneric attack, namely by disabling compression. Unfortunately, this does not prevent
any of the other length-based attacks discussed in this report.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

4.3

Network layer

4.3.1

Randomize TCP congestion window (inadequate)

page 24 of 27

The attack vectors included in HEIST uncover the length of responses by inspecting
whether a response fits in a single TCP congestion window, or requires multiple. By
randomizing the number of TCP packets included in a TCP congestion window for eachconnection (e.g. by selecting a random value for initcwnd, and growing the congestion window in an unpredictable manner), the attacker will not uncover the reason why
a response required multiple congestion windows. Either the TCP congestion window
was small, or the response was in fact large. However, the attacker can still try to obtain the length of a certain response multiple times. As the size of the TCP congestion
window is relatively small, it’s not possible to introduce a lot of variation. Although thiscountermeasure requires that the adversary needs to initiate more requests, an attack
can typically be performed in just a few seconds. Even a tenfold increase in the numberof requests would still leave attacks very practical. Therefore, we do not consider this avalid defense strategy.

4.3.2

Apply random padding (inadequate)

The idea behind this approach is similar to randomizing the TCP congestion window:
prevent the attacker from directly learning the exact length of a response by masking itwith a random value. As such, it also suffers from the same vulnerability, namely thatthe attacker just needs to make more requests to filter out the randomness. Anotherdownside of padding is that the response can only become larger, and thus will havean impact on the bandwidth. In contrast to applying randomization on the congestion
window size, adding random padding to the response works slightly better with regards
to preventing the attacker from learning the exact response size. This is because therange of possible values can be much higher. However, in case the adversary does notneed to know the exact size of a response, but just the range it is in, the number of
additional requests that need to be made may be negligible. Hence, we do not consider
this countermeasure appropriate in defending against HEIST-based attacks.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

5

page 25 of 27

Related WorkIn 2007, Bortz et al. [4] showed that network load times of cross-site resources can bemeasured in JavaScript. These load times can leak private information. At the 2011
edition of JSConf, Tellis presented his work on how to determine network conditions in
the browser [11]. Among other things, he employed JavaScript to request increasingly
large images, and noticed that larger images required more TCP windows. Ling et al.
later showed that the effect of TCP Slow-Start could in fact be abused in attacks [9].
That is, they showed that the round-trip time of encrypted web traffic could leak criticalinformation. This allowed an external network observer to determine which websites a
victim was visiting. In the TIME attack [2], TCP congestion control behaviour was combined with JavaScript time measurements to determine one-byte differences in resource
lengths. It was explained how this, in combination with the CRIME attack, could theoretically [2, §4.3] be used to infer secrets in third-party content. Unfortunately, a fulldemonstration of their technique was not provided. Our work does contain a full demonstration of the attack, uses a more reliable and noise-resistant timing side-channel, works
against large resources, and shows how to leverage HTTP/2 to increase the applicabilityof the attack. Furthermore, we verified all TCP behavior abused in our attack, using acustom Linux kernel module.
Compression based side-channel attacks against secure channels were first demonstratedby Kelsey in 2002 [8]. Here, he showed that an adversary can obtain sensitive information of a file by observing its compressed size. In particular, he demonstrated a chosenplaintext attack that is capable of inferring the precise content of secret information ina file. Duong and Juliano presented a variant of this chosen-plaintext attack against
SSL/TLS in 2012, where they showed how to recover an encrypted cookie [7]. In 2013,
Be’ery proposed a timing-based variant of this attack against HTTPS that did not requirea man-in-the-middle position [2]. Finally, Prado et al. presented a similar compressionbased attack called BREACH. It was demonstrated BREACH could recover CSRF tokens
in HTTPS responses [10].

6Conclusion

We have shown that it is possible to execute attacks on network protocols such as SSL/TLS
purely by running (malicious) JavaScript inside the victim’s browser. In particular, HEISTHEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 26 of 27

can be used to determine the exact size of HTTP responses, by increasing the amount ofreflected content until the HTTP response no longer fits into the initial TCP congestion
window. We have also shown that the introduction of HTTP/2 further worsens the situation, as it enables even more attack techniques. Therefore, we expect these types ofattacks to be more prevalent as the adoption of HTTP/2 increases.
The impact of our findings have been illustrated by showing how compression-based
attacks such as BREACH can be executed without requiring a man-in-the-middle position. Additionally, by using search-based oracles, personal information such as credit
card numbers can be obtained, and the medical conditions of victims can be exposed.
Finally, we have argued that it is difficult to defend against our attacks. One of the few,
if not the only, adequate countermeasure is to disable third-party cookies.

References[1] M. Allman, V. Paxson, and E. Blanton. TCP Congestion Control. RFC 5681, September 2009.
[2] Tal Be’ery and Amichai Shulman. A perfect crime? only time will tell. Black Hat
Europe, 2013, 2013.
[3] M. Belshe, R. Peon, and M. Thomson.

Hypertext Transfer Protocol Version 2(HTTP/2). RFC 7540, 2015.
[4] Andrew Bortz and Dan Boneh. Exposing private information by timing web applications. In Proceedings of the 16th international conference on World Wide Web,
pages 621–628. ACM, 2007.
[5] P. Deutsch. DEFLATE Compressed Data Format Specification version 1.3. RFC 1951,
1996.
[6] Nandita Dukkipati, Tiziana Refice, Yuchung Cheng, Jerry Chu, Tom Herbert, Amit
Agarwal, Arvind Jain, and Natalia Sutin. An argument for increasing TCP’s initialcongestion window. Computer Communication Review, 40(3):26–33, 2010.
[7] Thai Duong and Juliano Rizzo. The crime attack. In Presentation at ekoparty Security
Conference, 2012.

HEIST: HTTP Encrypted Information can be Stolen through TCP-windows

page 27 of 27[8] John Kelsey. Compression and information leakage of plaintext. In Fast Software
Encryption, pages 263–276. Springer, 2002.
[9] Zhen Ling, Junzhou Luo, Yang Zhang, Ming Yang, Xinwen Fu, and Wei Yu. A novel
network delay based side-channel attack: modeling and defense. In INFOCOM,
pages 2390–2398. IEEE, 2012.
[10] Angelo Prado, Neal Harris, and Yoel Gluck. SSL, Gone in 30 seconds. BREACH
Attack, 2013.
[11] Philip Tellis. Messing with JavaScript and the DOM to measure network char-https://www.smashingmagazine.com/2011/11/analyzingnetwork-characteristics-using-javascript-and-the-dom-part-1/,

acteristics.
2011.

[12] Anne Van Kesteren and WHATWG.

Fetch Standard.

https://fetch.spec.

whatwg.org/, January 2015.
[13] W3C. Service Workers. https://www.w3.org/TR/service-workers/, June
2015.
[14] W3C.

Resource Timing Standard.

https://www.w3.org/TR/resource-

timing/, February 2016.
[15] David Wagner, Bruce Schneier, et al. Analysis of the SSL 3.0 protocol. In The Second
USENIX Workshop on Electronic Commerce Proceedings, pages 29–40, 1996.