SSL TLS Decryption Uncovering Secrets
SSL TLS Decryption Uncovering Secrets
SSL/TLS Decryption
uncovering secrets
Wednesday November 8th, 2017
Peter Wu
Wireshark Core Developer
[email protected]
1
About me
2
Secrets
3
Transport Layer Security (TLS)
I Provides secure communication channel between two endpoints (client and server).
I Network protocol with two components:
I Handshake Protocol: exchange capabilities, establish trust and establish keys.
I Record Protocol: carries messages and protects application data fragments.
Application Application
4
Secure Sockets Layer (SSL) versus Transport Layer Security (TLS)
I SSLv3: old (RFC 6101, 1996) and deprecated (RFC 7568, 2015). Do not use it!
I TLS 1.0 (RFC 2246, 1999), 1.1 (RFC 4346, 2006), 1.2 (RFC 5246, 2008).
I Changes:
I New versions are generally fixing weaknesses due to new attacks.
I TLS 1.0 (RFC 3546, 2003) and up allow for extensions, like Server Name Indication
(SNI) to support virtual hosts.
I TLS 1.2: new authenticated encryption with additional data (AEAD) mode.
I “SSL” term still stuck, e.g. “SSL certificate”, “SSL library” and field names in
Wireshark (e.g. ssl.record.content type).
I Mail protocols: TLS often refers to STARTTLS while SSL directly starts with the
handshake.
5
“Secure” communication channel
6
Certificates and trust
7
TLS handshake with RSA key exchange method
I Client receives Server Hello, knows protocol version and cipher suite.
I Client generates a new random 48-byte premaster secret, encrypts it using the
public key from the Certificate and sends the result to the server in a
ClientKeyExchange message.
I Using the private RSA key, server (or anyone else!) decrypts the premaster secret.
9
TLS handshake with RSA key exchange method - Finishing up
10
Handshake overview
Client Server
ClientHello -------->
ServerHello
Certificate*
ServerKeyExchange*
<-------- ServerHelloDone
ClientKeyExchange
[ChangeCipherSpec]
Finished -------->
[ChangeCipherSpec]
<-------- Finished
Application Data <-------> Application Data
12
Decryption using private RSA server key
1 13
See https://wiki.wireshark.org/SSL#Preference_Settings
Limitations of RSA private key
I Clients usually do not have access to the RSA key, only server operators can use it.
I In case of mutual authentication (client certificates), the private key is only used
for signing. The client private RSA key cannot decrypt.
I Encrypted premaster secret is not sent with resumed sessions.
Client Server
ClientHello -------->
ServerHello
[ChangeCipherSpec]
<-------- Finished
[ChangeCipherSpec]
Finished -------->
Application Data <-------> Application Data
I Decryption using RSA private key not possible with cipher suites like
TLS ECDHE ECDSA WITH AES 128 GCM SHA256 and
TLS ECDHE RSA WITH AES 128 GCM SHA256.
I Although it has RSA in its name, it is not used for encryption, but signing.
I Instead it uses Diffie-Hellman to establish a shared secret (the premaster secret)
based on ephemeral secrets (different secrets for every session).
I Server chooses a group/curve, generates private value and its related public value
and sends it to the client. Client uses same group/curve and also generates a pair.
I Computationally hard to find the private value given the public one.
15
TLS secrets summary
16
SSL key log file
2 17
File format at https://developer.mozilla.org/NSS_Key_Log_Format
Using SSL key log file in Wireshark
18
Application and library support
I Any application built using NSS and GnuTLS enable key logging via the
SSLKEYLOGFILE environment variable.
I Applications using OpenSSL 1.1.1 or BoringSSL d28f59c27bac (2015-11-19) can
be configured to dump keys:
v o i d S S L C T X s e t k e y l o g c a l l b a c k ( SSL CTX ∗ c t x ,
v o i d ( ∗ cb ) ( c o n s t SSL ∗ s s l , c o n s t c h a r ∗ l i n e ) ) ;
I cURL supports many TLS backends, including NSS, GnuTLS and OpenSSL. Key
logging with OpenSSL/BoringSSL is possible with curl 7.56.03
3 19
Requires a build time option, see https://curl.haxx.se/bug/?i=1866
Key log with OpenSSL 1.1.0 and before
4
https://security.stackexchange.com/q/80158/2630
5 20
https://git.lekensteyn.nl/peter/wireshark-notes/tree/src
Unsupported applications for SSLKEYLOGFILE
6
https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/
16310230-ssl-key-logging-aka-sslkeylogfile
7
https://www.blackhat.com/docs/us-16/materials/
21
us-16-Kambic-Cunning-With-CNG-Soliciting-Secrets-From-SChannel.pdf
Alternative ways to get the secret
8
http://docs.mitmproxy.org/en/stable/dev/sslkeylogfile.html
9
Durumeric et. al., The Security Impact of HTTPS Interception,
https://jhalderm.com/pub/papers/interception-ndss17.pdf
10
https://conference.hitb.org/hitbsecconf2016ams/sessions/
22
telescope-peering-into-the-depths-of-tls-traffic-in-real-time/
Feature: Follow SSL Stream
23
Feature: Export HTTP Objects
24
Feature: Export SSL Session Keys
I Suppose you have a capture which is decrypted using a RSA private key file. How
to allow others to decrypt data without handing over your RSA private key file?
I File → Export SSL Session Keys. . .
I Generates a key log file which can be used instead of the private RSA key file.
I Note: currently contains all keys. Remove lines which are not needed (match by
the second field, the Random field from Client Hello).
25
Feature: Display Filters
I Display filters can be used for filtering, columns and coloring rules.
I Discover by selecting a field in packet list, look in status bar.
I Recognize TCP/TLS stream in packet list: Right-click TCP Stream Index
(tcp.stream) field in packet details, Apply as Column.
I Right-click field in packet details, Apply/Prepare as Filter.
I SNI in Client Hello: ssl.handshake.extensions server name
I Change in Wireshark 2.4: ssl.handshake.random selects full Client or Server
Random instead of the just the Random Bytes field. Reason: real time is often no
longer included, full bytes field is useful for matching with key log file.
26
Feature: Decode As
I Force dissector for custom ports. Decode as SSL (TCP) or DTLS (UDP).
I Select application data protocol within SSL/TLS layer (since Wireshark 2.4).
I Example: HTTPS on non-standard TCP server port 4433.
I Right-click TCP layer, Decode As. Change current protocol for TCP Port to SSL.
I Press OK to apply just for now or Save to persist this port-to-protocol mapping.
I Right-click SSL layer, Decode As. Change current protocol for SSL Port to HTTP.
I For STARTTLS protocols, select SMTP/IMAP/. . . instead of SSL for TCP Port.
I Tip: there are many protocols, just select the field, then use arrow keys or type
the protocol name (typing H gives HTTP).
27
Feature: Tshark
28
Future: TLS 1.3
I Replaces all previous cipher suites with new one. Dropped all old cipher suites (no
more CBC, RC4, NULL, export ciphers).
I RSA key exchange is gone, all ciphers are forward secret.
I Encrypted early (0-RTT) data.
I Encrypted server extensions (like ALPN)
I Encrypted server certificate.
I Multiple derived secrets for resumption, handshake encryption, application data
encryption. (Safer resumption!)
I Decryption and dissection is supported by Wireshark 2.4 (drafts 18-21 as of
Wireshark 2.4.2).
29
Conclusions
30