SSL/TLS: the Ugly Truth Examining the flaws in SSL/TLS Protocols, and the Use of Certificate Authorities
Total Page:16
File Type:pdf, Size:1020Kb
SSL/TLS: The Ugly Truth Examining the flaws in SSL/TLS protocols, and the use of certificate authorities. Adrian Hayter CNS Hut 3 Team [email protected] Contents • Introduction to SSL/TLS • Cryptography Crash Course • Certificates • Weaknesses in SSL/TLS • The Certificate Authority System • Solutions & Recommendations • Questions Adrian Hayter Page: 2/26 What is SSL/TLS? Secure Sockets Layer (versions 2.0, 3.0) Transport Layer Security (versions 1.0, 1.1, 1.2) Cryptographic protocols that allow secure communication over a network. Uses: • Authentication of participants. • Key exchange. • Encryption of data. • Data integrity. Adrian Hayter Page: 3/26 What is SSL/TLS? Secure Sockets Layer (versions 2.0, 3.0) Transport Layer Security (versions 1.0, 1.1, 1.2) Cryptographic protocols that allow secure communication over a network. Uses: • Authentication of participants. • Key exchange. • Encryption of data. • Data integrity. Adrian Hayter Page: 3/26 Cryptography Crash Course If you already know about cryptography, feel free to ignore the next few slides! Adrian Hayter Page: 4/26 Cryptography Crash Course: Symmetric Cryptography Alice Bob Alice and Bob both have a copy of a secret key. Alice encrypts a message using the secret key and sends it to Bob. Bob decrypts the message using the secret key. Bob encrypts a message using the secret key and sends it to Alice. Alice decrypts the message using the secret key. Adrian Hayter Page: 5/26 Cryptography Crash Course: Symmetric Cryptography • Encryption / Decryption is simple and easy for a computer to do. Secret keys are also easy to generate. • Requires participants to have set up the shared secret key beforehand. Problems: How do participants set up a shared secret key? What if the participants don’t know each other? Adrian Hayter Page: 6/26 Cryptography Crash Course: Symmetric Cryptography • Encryption / Decryption is simple and easy for a computer to do. Secret keys are also easy to generate. • Requires participants to have set up the shared secret key beforehand. Problems: How do participants set up a shared secret key? What if the participants don’t know each other? Adrian Hayter Page: 6/26 Cryptography Crash Course: Asymmetric Cryptography Alice Bob Alice and Bob generate their own private and public key pairs. Alice and Bob share their public keys with each other. Alice encrypts a message with Bob's public key and sends it to Bob. Bob decrypts the message with his private key. Bob encrypts a message with Alice's public key and sends it to Alice. Alice decrypts the message with her private key. Adrian Hayter Page: 7/26 Cryptography Crash Course: Asymmetric Cryptography • Asymmetric Cryptography is also known as Public-key Cryptography. • Public / Private keys are mathematically linked. Knowledge of one of the keys does not compromise the other. • Does not require the participants to have set up any shared secrets beforehand, or even know each other. Problem: Both the key pair generation and the encryption / decryption processes are complex and take much longer for computers to do than with symmetric cryptography. Adrian Hayter Page: 8/26 Cryptography Crash Course: Asymmetric Cryptography • Asymmetric Cryptography is also known as Public-key Cryptography. • Public / Private keys are mathematically linked. Knowledge of one of the keys does not compromise the other. • Does not require the participants to have set up any shared secrets beforehand, or even know each other. Problem: Both the key pair generation and the encryption / decryption processes are complex and take much longer for computers to do than with symmetric cryptography. Adrian Hayter Page: 8/26 A Solution We can combine symmetric and asymmetric cryptography. 1. Alice & Bob generate public/private keys beforehand. 2. When Alice wants to send a message to Bob, she asks Bob to send her his public key. 3. Bob sends Alice his public key. 4. Alice creates a symmetric key, encrypts it using Bob’s public key, and sends the encrypted key to Bob. 5. Bob decrypts the symmetric key using his private key and stores it. 6. Alice and Bob can now encrypt/decrypt messages using the shared symmetric key. Adrian Hayter Page: 9/26 A Solution We can combine symmetric and asymmetric cryptography. 1. Alice & Bob generate public/private keys beforehand. 2. When Alice wants to send a message to Bob, she asks Bob to send her his public key. 3. Bob sends Alice his public key. 4. Alice creates a symmetric key, encrypts it using Bob’s public key, and sends the encrypted key to Bob. 5. Bob decrypts the symmetric key using his private key and stores it. 6. Alice and Bob can now encrypt/decrypt messages using the shared symmetric key. Adrian Hayter Page: 9/26 A Solution We can combine symmetric and asymmetric cryptography. 1. Alice & Bob generate public/private keys beforehand. 2. When Alice wants to send a message to Bob, she asks Bob to send her his public key. 3. Bob sends Alice his public key. 4. Alice creates a symmetric key, encrypts it using Bob’s public key, and sends the encrypted key to Bob. 5. Bob decrypts the symmetric key using his private key and stores it. 6. Alice and Bob can now encrypt/decrypt messages using the shared symmetric key. Adrian Hayter Page: 9/26 A Solution We can combine symmetric and asymmetric cryptography. 1. Alice & Bob generate public/private keys beforehand. 2. When Alice wants to send a message to Bob, she asks Bob to send her his public key. 3. Bob sends Alice his public key. 4. Alice creates a symmetric key, encrypts it using Bob’s public key, and sends the encrypted key to Bob. 5. Bob decrypts the symmetric key using his private key and stores it. 6. Alice and Bob can now encrypt/decrypt messages using the shared symmetric key. Adrian Hayter Page: 9/26 A Solution We can combine symmetric and asymmetric cryptography. 1. Alice & Bob generate public/private keys beforehand. 2. When Alice wants to send a message to Bob, she asks Bob to send her his public key. 3. Bob sends Alice his public key. 4. Alice creates a symmetric key, encrypts it using Bob’s public key, and sends the encrypted key to Bob. 5. Bob decrypts the symmetric key using his private key and stores it. 6. Alice and Bob can now encrypt/decrypt messages using the shared symmetric key. Adrian Hayter Page: 9/26 A Solution We can combine symmetric and asymmetric cryptography. 1. Alice & Bob generate public/private keys beforehand. 2. When Alice wants to send a message to Bob, she asks Bob to send her his public key. 3. Bob sends Alice his public key. 4. Alice creates a symmetric key, encrypts it using Bob’s public key, and sends the encrypted key to Bob. 5. Bob decrypts the symmetric key using his private key and stores it. 6. Alice and Bob can now encrypt/decrypt messages using the shared symmetric key. Adrian Hayter Page: 9/26 “Man in the Middle Attack” Alice Mallory Bob "Hey Bob, it's Alice. Can I have your public key?" "Hey Bob, it's Alice. Can I have your public key?" Bob sends his public key. Mallory sends his public key. How do we solve this problem? A problem with our solution! Alice and Bob don’t ever verify that they are actually talking to each other! Adrian Hayter Page: 10/26 Alice Mallory Bob "Hey Bob, it's Alice. Can I have your public key?" "Hey Bob, it's Alice. Can I have your public key?" Bob sends his public key. Mallory sends his public key. A problem with our solution! Alice and Bob don’t ever verify that they are actually talking to each other! “Man in the Middle Attack” How do we solve this problem? Adrian Hayter Page: 10/26 Certificates A digital certificate binds a public key to an identity using a digital signature. The digital signature almost always comes from a trusted third party. If the signature is trusted, the certificate is valid, and the public key is verified to belong to the specified identity. In the SSL/TLS system, X.509 certificates are signed by Certificate Authorities (e.g. VeriSign, Comodo, Entrust, PositiveSSL). More on these later... Adrian Hayter Page: 11/26 Certificate Fields Subject: The identity the public key belongs to (e.g. Bob, www.example.com). Issuer: The identity that signed and issued the certificate (e.g. VeriSign). Signature: The signature of the issuer. Not Before / Not After: Dates when the certificate is valid. Public Key: The subject’s public key. Version, Serial Number, Signature Algorithm, Public Key Algorithm Adrian Hayter Page: 12/26 (Highly) Simplified SSL/TLS Handshake Client Server Client requests SSL/TLS connection. Sends some random bytes to the server. Server sends certificate. Sends some random bytes to the client. Client verifies certificate, generates pre-master secret, encrypts the secret with the server's public key, and sends it to the server. The server decrypts the pre-master secret and uses it to generate a shared master secret, which is then used to generate session keys. The client generates the same master secret and session keys. The client and server encrypt and exchange data using the session keys. Adrian Hayter Page: 13/26 SSL/TLS: Common Security Weaknesses • Use of outdated protocols: SSLv2. • Use of weak ciphers: symmetric encryption (<128 bits), asymmetric encryption (<2048 bits). • Expired / invalid certificates. • Self-signed certificates. • Renegotiation. Web based: • Login over HTTPS, everything else over HTTP (sslstrip exploits this). Adrian Hayter Page: 14/26 Attacks against SSL/TLS BEAST (Browser Exploit Against SSL/TLS) – Developed in 2011. Affects all versions of SSL/TLS except TLS 1.1 and 1.2.