Analyzing Forget SSL Certificates in The Wild PDF
Analyzing Forget SSL Certificates in The Wild PDF
Abstract—The SSL man-in-the-middle attack uses forged SSL the attacker’s certificates were signed by trusted CAs, standard
certificates to intercept encrypted connections between clients browsers cannot simply distinguish the attacker’s intercepting
and servers. However, due to a lack of reliable indicators, it is server from the legitimate server (unless the forged certificate
still unclear how commonplace these attacks occur in the wild. In
this work, we have designed and implemented a method to detect is later revoked). Hypothetically [9], some governments may
the occurrence of SSL man-in-the-middle attack on a top global also compel CAs to issue trusted SSL certificates for spying
website, Facebook. Over 3 million real-world SSL connections purposes without the website’s consent.
to this website were analyzed. Our results indicate that 0.2% Furthermore, even if the attacker cannot obtain a trusted
of the SSL connections analyzed were tampered with forged certificate of legitimate websites, it is still possible to intercept
SSL certificates, most of them related to antivirus software and
corporate-scale content filters. We have also identified some SSL SSL connections against some users (that ignore browser secu-
connections intercepted by malware. Limitations of the method rity warnings). Historically, browsers tend to behave leniently
and possible defenses to such attacks are also discussed. when encountering errors during SSL certificate validation,
Keywords-SSL; certificates; man-in-the-middle attack; and still allow users to proceed over a potentially insecure
connection. One could argue that certificate warnings are
I. I NTRODUCTION mostly caused by server mis-configurations (e.g. certificate
Secure Socket Layer (SSL) [1], or its successor, Transport expirations) rather than real attacks, therefore browsers should
Layer Security (TLS) [2], is an encryption protocol designed let users determine whether they should dismiss the errors.
to provide secure communication and data transfers over the However, designing an effective security warning dialog has
Internet.1 SSL allows clients to authenticate the identity of been a challenging task for browser vendors. A number of
servers by verifying their X.509 [3] digital certificates, and usability studies [10], [11], [12], [13] have shown that many
reject connections if the server’s certificate is not issued by users actually ignore SSL certificate warnings. Note that
a trusted certificate authority (CA). SSL is most popular for users who incautiously ignore certificate warnings would be
enabling the encryption of HTTP traffic between websites vulnerable to the simplest SSL interception attacks (using self-
and browsers, but also widely used for other applications signed certificates).
such as instant messaging and email transfers. An SSL man- Despite that SSL man-in-the-middle attack attempts have
in-the-middle attack is an interception of such an encrypted previously been observed in the wild (e.g. in Iran [8] and
connection between a client and a server where the attacker Syria [14]), it is unclear how prevalent these attacks actually
impersonates the server through a forged SSL certificate — are. Several existing SSL surveys [4], [15], [16], [17] have
that is, an SSL certificate not provided or authorized by the collected large amounts of SSL certificates via scanning public
legitimate owner. We explain how this is possible below. websites or monitoring SSL traffic on institutional networks,
In practice, certificates issued through hundreds [4] of yet no significant data on forged SSL certificates have been
CAs are automatically trusted by modern browsers and client publicly available. We hypothesize that real attackers are
operating systems. Under the current X.509 public key in- more likely to perform only highly targeted attacks at certain
frastructure, every single CA has the ability to issue trusted geographical locations, or on a small number of high-value
certificates to any website on the Internet. Therefore, CAs must sessions, therefore, previous methodologies would not be able
ensure that trusted certificates are only issued to the legitimate to detect these attacks effectively.
owners of each website (by certifying the real identities of Unfortunately, detecting SSL man-in-the-middle attacks
their customers). However, if any of the trusted CAs suffers a from the website’s perspective, on a large and diverse set
security breach, then it is possible for attackers to obtain forged of clients, is not a trivial task. Since most users do not use
CA certificates for any desired website. In other words, a client certificates, servers cannot simply rely on SSL client
single CA failure would allow the attacker to intercept all SSL authentication to distinguish legitimate clients from attackers.
connections on the Internet. In fact, multiple commercial CAs Furthermore, there is currently no way for a web application
(DigiNotar [5], Comodo [6], and TURKTRUST [7]) have been to check the certificate validation status of the underlying SSL
found to mis-issue fraudulent certificates in the past. Some of connection, not even when an SSL error has occurred on the
these CA incidents actually resulted in real man-in-the-middle client. Also, it is currently not possible for web applications
attacks against high-profile websites such as Google [8]. Since to directly access the SSL handshake with native browser
networking APIs, like XMLHttpRequest and WebSockets, to
1 For brevity, we refer to SSL/TLS as SSL in this paper. validate SSL certificates on their own.
In this paper, we first introduce a practical method for Browser HTTPS server
websites to detect SSL man-in-the-middle attacks in a large
scale, without alterations on the client’s end (e.g. custom
browsers). We utilized the widely-supported Flash Player
plugin to enable socket functionalities not natively present in ClientHello
current browsers, and implemented a partial SSL handshake
on our own to capture forged certificates. We deployed this ServerHello, Certificateserver, ServerHelloDone
detection mechanism on an Alexa top 10 website, Facebook,
ClientKeyExchange, ChangeCipherSpec, Finished
which terminates connections through a diverse set of network
operators across the world. We analyzed 3, 447, 719 real-world ChangeCipherSpec, Finished
SSL connections and successfully discovered at least 6, 845
(0.2%) of them were forged SSL certificates.
Our contributions can be summarized as follows:
• We designed a novel method for websites to collect Fig. 1. A basic SSL handshake with no client certificates
direct evidence of man-in-the-middle attacks against their
SSL connections. We further implemented this detection
method on Facebook’s website. the cipher algorithms and parameters to be used. Figure 1
• We conducted the first analysis on forged SSL certificates
depicts a basic SSL handshake using the RSA key exchange
by measuring over 3 million SSL connections. Our results with no client certificates. First, the client sends a ClientHello
show that 0.2% SSL connections are in fact tampered message to the server, which specifies a list of supported
with forged certificates. cipher suites and a client-generated random number. Second,
• Based real-world data, we categorized the root causes
the server responds with the ServerHello message which
of forged SSL certificates. We showed that most of contains the server-chosen cipher suite and a server-generated
the SSL interceptions are due to antivirus software and random number. In addition, the Certificate message contains
organization-scale content filters. the server’s public key and hostname, digitally signed by
• We provided evidence of SSL interceptions by malware,
a certificate authority, in which the client is responsible of
which have infected users across at least 45 countries. verifying. The client then encrypts the pre-master secret using
the server’s public key and sends the pre-master secret to the
The rest of this paper is organized as follows. Section II
server over a ClientKeyExchange message. Both the client
provides background information and surveys related work.
and server can hence derive the same session key from the
Section III details the design, implementation, and experimen-
pre-master secret and random numbers. Finally, the client
tation of our plugin-based detection method. Section IV gives
and server exchanges ChangeCipherSpec messages to notify
an analysis of the forged SSL certificates that were observed.
each other that subsequent application data within the current
Section V surveys possible mitigations. Section VI concludes.
session will be encrypted using the derived session key.
II. BACKGROUND As mentioned in Section I, the SSL protocol allows clients
In this section, we provide an overview of the SSL protocol, to authenticate the identity of servers by verifying their SSL
and how the SSL man-in-the-middle attack works. We then certificates. In practice, commercial SSL certificates are often
survey related work, and discuss existing tamper detection signed by intermediate CAs (a delegated certificate signer),
techniques that may be used by websites to detect network instead of directly signed by a trusted root CA (which are kept
interceptions. offline to reduce the risk of being compromised). Therefore,
the server’s Certificate message normally includes a chain
A. The SSL Protocol of certificates, consisting of one leaf certificate (to identify
The Secure Socket Layer (SSL) protocol was designed the server itself), and one or more intermediate certificates (to
to ensure secure communications between two entities over identify the intermediate CAs). Each certificate is cryptograph-
untrusted networks. The SSL protocol provides authentication ically signed by the entity of the next certificate in the chain,
based on the X.509 public key infrastructure, protects data and so on. A valid certificate chain must chain up to a root
confidentiality using symmetric encryption, and ensures data CA that is trusted by the client. Note that SSL certificates are
integrity with cryptographic message digests. SSL is com- by design transferred in plaintext since the integrity can be
monly used for securing websites and mail servers, preventing verified by signatures. It is critical that clients must validate
passive network attackers from eavesdropping or replaying the every certificate in the chain. In the following section, we will
client’s messages, and is generally considered security best explain why validating SSL server certificates is necessary.
practice for websites. By enabling encryption, websites can
easily prevent the eavesdropping of unencrypted confidential B. The SSL Man-in-the-Middle Attack
data (e.g. Firesheep [18]). The SSL man-in-the-middle (MITM) attack is a form of
To establish an SSL connection, the client and the server active network interception where the attacker inserts itself
performs a handshake to authenticate each other, and negotiate into the communication channel between the victim client and
Browser Man-in-the-middle HTTPS server between them (decrypting messages from the client, and
then re-encrypting them before sending to the server).
Now, the attacker can read and even modify the en-
crypted messages between the client and the server.
ClientHello ClientHello As soon as the client accepts the forged SSL certificate, the
ServerHello ServerHello client’s secrets will be encrypted with the attacker’s public key,
Certificateattacker Certificateserver which can be decrypted by the attacker. Note that regardless of
ServerHelloDone ServerHelloDone whether the attacker’s forged certificate is issued by a trusted
ClientKeyExchange ClientKeyExchange CA, the attack steps are the same. If one of the client’s trusted
ChangeCipherSpec ChangeCipherSpec CAs went rogue or was otherwise coerced [9] into issuing
Finished Finished a certificate for the attacker, the browser will automatically
ChangeCipherSpec ChangeCipherSpec accept the forged certificate. In fact, professional attackers
Finished Finished have proven capable of compromising CAs themselves in
order to obtain valid certificates, as has occurred during the
Encryptattacker(data) Encryptattacker(data)
security breaches of DigiNotar [5] and Comodo [6]. Moreover,
even if the attacker does not have a trusted certificate of the
victim server and uses a self-signed certificate, researchers
have shown that many users ignore SSL certificate warnings
Fig. 2. An SSL man-in-the-middle attack between the browser and the server,
using a forged SSL certificate to impersonate as the server to the client. presented by the browser [11]. Even worse, studies have
discovered that some non-browser software and native mobile
applications actually contain faulty SSL certificate validation
the server (typically for the purpose of eavesdropping or ma- code, which silently accepts invalid certificates [20], [21], [22].
nipulating private communications). The attacker establishes Lastly, numerous automated tools that can mount SSL man-
two separate SSL connections with the client and the server, in-the-middle attacks are publicly available on the Internet
and relays messages between them, in a way such that both the (e.g. sslsniff [23]), which greatly reduce the level of technical
client and the server are unaware of the middleman. This setup sophistication necessary to mount such attacks.
enables the attacker to record all messages on the wire, and C. Certificate Observatories
even selectively modify the transmitted data. Figure 2 depicts
A number of SSL server surveys [4], [15], [16], [17] have
an SSL man-in-the-middle attack with a forged certificate
analyzed SSL certificates and certificate authorities on the
mounted between a browser and a HTTPS server. We describe
Internet. The EFF SSL Observatory [4] analyzed over 1.3
the basic steps of a generic SSL man-in-the-middle attack as
million unique SSL certificates by scanning the entire IPv4
follows:
space, and indicated that 1,482 trusted certificate signers are
1) The attacker first inserts itself into the transport path being used. Similarly, Durumeric et al. [17] collected over
between the client and the server, for example, by 42 million unique certificates by scanning 109 million hosts,
setting up a malicious WiFi hotspot. Even on otherwise and identified 1,832 trusted certificate signers. Holz et al. [15]
trusted networks, a local network attacker may often analyzed SSL certificates by passively monitoring live SSL
successfully re-route all of the client’s traffic to itself traffic on a research network in addition to actively scanning
using exploits like ARP poisoning, DNS spoofing, BGP popular websites, and found that over 40% certificates ob-
hijacking, etc. The attacker could also possibly configure served were invalid due to expiration, incorrect host names, or
itself as the client’s proxy server by exploiting auto- other reasons. Akhawe et al. [16] analyzed SSL certificates by
configuration protocols (PAC/WPAD) [19]. At this point, monitoring live user traffic at several institutional networks,
the attacker has gained control over the client’s traffic, and provided a categorization of common certificate warn-
and acts as a relay server between the client and the ings, including server mis-configurations and browser design
server. decisions. However, existing studies do not provide insights
2) When the attacker detects an SSL ClientHello message on forged certificates, probably since network attackers are
being sent from the client, the attacker accurately deter- relatively rare on those research institutional networks. In our
mines that the client is initiating an SSL connection. The work, we set out to measure real-world SSL connections from
attacker begins the impersonation of the victim server a large and diverse set of clients, in an attempt to find forged
and establishes an SSL connection with the client. Note SSL certificates.
that the attacker uses a forged SSL certificate during its
SSL handshake with the client. D. Tamper Detection Techniques for WebSites
3) In parallel to the previous step, the attacker creates Several techniques have been proposed to assist websites
a separate SSL connection to the legitimate server, in detecting whether the client’s network connections has
impersonating the client. Once both SSL connections are been tampered with. In this paper, we focus on detection
established, the attacker relays all encrypted messages methods that do not require user interaction, and do not require
the installation of additional software or browser extensions. III. SSL TAMPER D ETECTION M ETHOD
Notably, Web Tripwires [24] uses client-side JavaScript code In Section II-D, we discussed a number of existing tech-
to detect in-flight modifications to a web page. Several other niques for websites to detect network tampering. However,
studies [25], [26], [27], [28] have utilized Java applets to probe none of the current methods (without browser modifications)
the client’s network configurations and detect proxies that are are effective in detecting SSL man-in-the-middle attacks. In
altering the client’s traffic. this section, we present a new method for detecting SSL
man-in-the-middle attacks from the website’s end. First, we
• Web Tripwires. Web Tripwires [24] was a technique describe our threat model. We then detail the design and our
proposed to ensure data integrity of web pages, as an implementation of the detection method on the Facebook web-
alternative to HTTPS. Websites can deploy JavaScript site. Lastly, we present our findings from analyzing millions
to the client’s browser that detects modifications on of real-world SSL connections.
web pages during transmission. In their study of real-
world clients, over 1% of 50, 000 unique IP addresses A. Threat Model
observed altered web pages. Roughly 70% of the page We primarily consider an active network attacker who has
modifications were caused by user-installed software that control over the victim’s network connection. However, the
injected unwanted JavaScript into web pages. They found attacker does not have control over the website (such as
that some ISPs and enterprise firewalls were also injecting accessing internal machines and stealing the server’s private
ads into web pages, or benignly adding compression to key). The goal of the adversary is to read encrypted messages
the traffic. Interestingly, they spotted three instances of between the victim client and the HTTPS website. The attacker
client-side malware that modified their web pages. Web may impersonate the legitimate website with either (1) a
Tripwires was mainly designed to detect modifications to trusted certificate issued by a trusted CA, or (2) an untrusted
unencrypted web traffic. By design, Web Tripwires does certificate (e.g. a self-signed certificate). In the case of an
not detect passive eavesdropping (that does not modify untrusted certificate, we assume that users may still be vulner-
any page content), nor does it detect SSL man-in-the- able, since previous studies [11], [12] have shown that many
middle attacks. In comparison, our goal is to be able to users ignore browser security warnings. Users are assumed to
detect eavesdropping on encrypted SSL connections. use up-to-date browsers (with no SSL implementation bugs).
• Content Security Policy. Content Security Policy In addition, we will discuss separately another type of
(CSP) [29] enables websites to restrict browsers to load local attacker, where the attacker may be a piece of software
page content, like scripts and stylesheets, only from a running on the client with the ability to modify the client’s
server-specified list of trusted sources. In addition, web- trusted CA store, as well as manipulate network connections.
sites can instruct browsers to report CSP violations back Such local attackers are much stronger than active network
to the server with the report-uri directive. Interest- attackers, and are naturally not in scope of the SSL protocol’s
ingly, CSP may detect untrusted scripts that are injected protection.
into the protected page, and report them to websites. Like
Web Tripwires, CSP does not detect eavesdropping on B. Design
SSL connections. There are several obstacles for websites to detect whether
• Browser Plugins. Another technique for websites to any SSL man-in-the-middle attacks are mounted against their
diagnose the client’s network is by using browser plugins, connections. First of all, since SSL client certificates are rarely
such as Java and Flash Player. Browser plugins may sent by normal users, it is not possible to distinguish a legit-
provide more network capabilities than JavaScript, in- imate client from an attacker directly via the SSL handshake
cluding the ability to open raw network sockets and even from the server’s perspective. In order to determine whether
perform DNS requests. For instance, the Illuminati [25] an SSL connection is being intercepted, our fundamental
project used Java applets to identify whether clients were approach is to observe the server’s certificate from the client’s
connecting through proxies or NAT devices. Jackson et perspective. Intuitively, if the client actually received a server
al. conducted studies using both Java and Flash Player certificate that does not exactly match the website’s legitimate
on real-world clients to find web proxy vulnerabilities, certificate, we would have direct evidence that the client’s
including multi-pin DNS rebinding [26] and cache poi- connection must have been tampered with.
soning [27]. The ICSI Netalyzer [28] used a signed Java Although one could easily develop a binary executable file
applet to perform extensive tests on the client’s network or a custom browser extension that probes SSL certificates as
connectivity, such as detecting DNS manipulations. an SSL client, it would not be scalable to distribute additional
software to a large number of normal users, especially for
In our work, we focused on detecting SSL man-in-the- non-tech-savvy users. Ideally, we would like to develop a
middle attacks in real-world, from a website’s perspective, JavaScript code snippet to observe SSL certificates, which
without modifications to current browsers. Other proposals to runs in existing browsers and can reach a large population of
prevent or mitigate SSL interception will be later discussed in clients. However, there are currently no existing browser APIs
Section V. that allows web applications to directly check the observed
Browser HTTPS server order for a SWF applet from example.com to open a socket
connection to a HTTPS server example.com on port 443, a
valid socket policy file must be served at example.com on
port 843, which permits socket access from example.com
Request HTML applications to port 443, as follows (in XML format):
<?xml version="1.0"?>
<html>… <object src="applet.swf"></object> … <!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
Request applet.swf <cross-domain-policy>
<allow-access-from domain="example.com" to-ports="443" />
</cross-domain-policy>
applet.swf
Note that the socket policy file should not be confused with
Flash Player
the crossdomain.xml file served by web servers, which
restricts access to HTTP, HTTPS, and FTP access, but not
socket access. If the Flash Player cannot successfully retrieve
Port 843 a valid socket policy (e.g. blocked by a firewall), the socket
<policy-file-request />
connection will be aborted and an exception will be thrown.
<cross-domain-policy>...</cross-domain-policy>
Once the socket connection is permitted, our applet will
Port 443 initiate an SSL handshake by sending a ClientHello message
ClientHello
over the socket, and wait for the server to respond with
ServerHello, Certificateattacker… the ServerHello and Certificate messages, which will be
recorded. To support clients behind explicit HTTP proxies,
Log Certificateattacker the applet may send a CONNECT request over the socket to
create an SSL tunnel prior to sending the ClientHello message,
as follows:
Fig. 3. The website loads a client-side applet, that performs the SSL CONNECT example.com:443 HTTP/1.1
handshake over a Flash-based socket connection to observe SSL certificates.
Our SSL handshake implementation was based on the SSL
3.0 protocol version. Since our goal to observe the server’s
server certificate or validation status of their SSL connections. certificate chain, our applet closes the socket connection
To workaround this, we utilized browser plugins to implement after successfully receiving the certificate chain. Lastly, our
a client-side applet that is capable of imitating the browser’s applet converts the raw bytes of the recorded SSL handshake
SSL handshake, accompanied with the ability to report the responses into an encoded string, and sends it back to our log
observed certificate chain. The applet can open a socket con- server with a POST request.
nection to the HTTPS server (skipping the browser’s network We note that the Flash Player plugin is currently supported
stack), perform an SSL handshake over the socket, record on 95% of web browsers [31], therefore, our applet should
the SSL handshake, and report the certificate chain back to be able to run on most clients. In fact, one of the major
our logging servers, shown in Figure 3. We describe our browsers, Google Chrome, has the Flash Player plugin built
implementation details below. in by default. Also, SWF applets are usually allowed to
1) Client-Side Applet: Our approach is to use a client- execute without any additional user confirmation, and do not
side applet that observes the server’s SSL certificate from trigger any visual indicators (e.g. system tray icons) while
the client’s perspective, directly during the SSL handshake. running, thus, deploying this method should not affect the
Since native browser networking APIs like XMLHttpRequest visual appearance of the original web page.
and WebSockets do not provide web applications access to Alternatively, the client-side applet may be implemented
raw bytes of socket connections, we must utilize browser using other browser plugins, for example, the Java plugin.
plugins. We implemented a Shockwave Flash (SWF) applet Java applets are allowed to create socket connections from
that can open a raw socket connection to its own HTTPS server the client to any port on the same host that the applet was
(typically on port 443), and perform an SSL handshake over served from. As an example, an applet served from port
the connection in the Flash Player. 80 on example.com can open a raw socket to port 443
By default, the Flash Player plugin does not allow any on example.com without requesting any additional access.
applets to access socket connections, unless the remote host However, due to security concerns, the Java plugin is currently
runs a Flash socket policy server [30]. The Flash socket policy blocked by default on several client platforms, and may require
server, normally running on port 843, serves a socket policy additional user interaction to activate the Java plugin. Such
file that declares whether SWF applications may open socket user interaction would be too obtrusive for our experiment
connections to the server. Note that even if a SWF file is and client diversity suffers greatly once all potential interactive
requesting a socket connection to the same host it was served platforms are removed from the experiment. Another side
from, a socket policy server is still required. As a result, in effect of running a Java applet on some platforms is that a
EURZVHUKWPO