Cipher Suites: Best Practices and Pitfalls
Total Page:16
File Type:pdf, Size:1020Kb
Cipher Suite Practices and Pitfalls: An Overview of Cipher Suite Configuration and Pitfalls on BIG-IP PRESENTED BY: “A cipher suite is a named combination of authentication, encryption, message authentication code (MAC) and key exchange algorithms used to negotiate the security settings for a network connection using the Transport Layer Security (TLS) / Secure Sockets Layer (SSL) network protocol.” – Wikipedia When we talk about configuring ciphers on BIG-IP we’re really talking about configuring cipher suites. More specifically the configured list of cipher suites is a menu of options available to be negotiated. Each cipher suite specifies the key exchange algorithm, authentication algorithm, cipher, cipher mode, and MAC that will be used. I recommend reading K15194: Overview of the BIG-IP SSL/TLS cipher suite for more information. https://en.wikipedia.org/wiki/Cipher_suite Let’s consider this cipher suite: ECDHE-RSA-AES256-GCM-SHA384 Key Exchange Algorithm: ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) Authentication Algorithm: RSA Cipher: AES256 (aka AES with a 256-bit key) Cipher Mode: GCM (Galois/Counter Mode) MAC: SHA384 (aka SHA-2 (Secure Hash Algorithm 2) with 384-bit hash) This is arguably the strongest cipher suite we have on BIG-IP at this time. What about this cipher suite: AES128-SHA Key Exchange Algorithm: RSA (Implied) – When it isn’t specified, presume RSA. Authentication Algorithm: RSA (Implied) – When it isn’t specified, presume RSA. Cipher: AES128 (aka AES with a 128-bit key) Cipher Mode: CBC (Cipher Block Chaining) (Implied) – When it isn’t specified, presume CBC. MAC: SHA1 (Secure Hash Algorithm 1; SHA-1 always produces a 160-bit hash.) This is to illustrate that the cipher suite may not always explicitly specify every parameter, but they’re still there. There are ‘default’ values that are fairly safe to presume when not otherwise specified. If an algorithm isn’t specified, it is RSA. That’s a safe bet. And if a cipher mode isn’t specified it is CBC. Always CBC. Note that all ciphers supported on BIG-IP are CBC mode except for AES-GCM and RC4. ALL. I stress this as it has been a recurring source of confusion. This presentation is really about cipher suite configuration and ciphers, and not the SSL/TLS protocol, so I won’t dive too deeply here. As a quick review of the difference between asymmetric key (aka public key) cryptography and symmetric key cryptography: With the asymmetric key you have two keys – Kpublic and Kprivate. Since you can openly share the public key there is no need to pre-share keys with anyone. The downside is these algorithms are computationally expensive. Key lengths for a common algorithm such as RSA are at least 1024-bit, and 2048-bit is really the minimally acceptable these days. Symmetric key has only Kprivate. Both ends use the same key, which poses the problem of key distribution. The advantage is higher performance; common key sizes are 128-bit or 256-bit. SSL/TLS uses both systems – the Key Exchange Algorithm is the public key system used to exchange the symmetric key. Examples: ECDHE, DHE, RSA, ECDH, ADH This is sometimes grouped in with the Key Exchange Algorithm – written as ‘ECDHE_RSA’ for example. But we’ll consider it as a separate component. This is the algorithm used in the SSL/TLS handshake for the server to sign (using the server’s private key) elements sent to the client in the negotiation. The client can authenticate them using the server’s public key. Examples include: RSA, ECDSA, DSS (aka DSA), and Anonymous. Anonymous means no authentication; this is generally bad. Using an ‘ADH’ cipher suite will cause this. More on this later when we talk about pitfalls. Note that when RSA is used for the key exchange authentication is inherent to the scheme so there really isn’t a separate authentication step. “In cryptography, a cipher (or cypher) is an algorithm for performing encryption or decryption—a series of well-defined steps that can be followed as a procedure. An alternative, less common term is encipherment. To encipher or encode is to convert information into cipher or code. In common parlance, 'cipher' is synonymous with 'code', as they are both a set of steps that encrypt a message; however, the concepts are distinct in cryptography, especially classical cryptography.” – Wikipedia Examples: DES (Data Encryption Standard), 3DES (Triple DES), AES (Advanced Encryption Standard), RC4 (Rivest Cipher 4), Camellia, RC6, RC2, Blowfish, Twofish, IDEA, SEED, GOST, Rijndael, Serpent, MARS, etc. For a little cryptography humor see: RFC2410: The NULL Encryption Algorithm and Its Use With IPsec https://en.wikipedia.org/wiki/Cipher All of the secrecy in encryption comes from the key that is used. Obtain the key and you can unlock the ciphertext. The cipher itself – the algorithm, source code, etc. – not only can be, but should be, openly available. History is full of examples of private cryptosystems failing due to weaknesses missed by their creators, while the most trusted ciphers were created via open processes (AES for example). Keys are of varying lengths and, generally speaking, the longer the key the more secure the encryption. DES only had 56-bits of key data, and thus is considered insecure. We label 3DES as 168-bit, but it is really only equivalent to 112-bit strength. (More on this at the end if there is time.) Newer ciphers, such as AES, often offer options – 128-bits, 192- bits, or 256-bits of key. Remember, a 256-bit key is far more than twice as strong as a 128-bit key. It is 2128 vs. 2256. Cipher mode is the mode of operation used by the cipher when encrypting plaintext into ciphertext, or decrypting ciphertext into plaintext. The most common mode is CBC – Cipher Block Chaining. In cipher block chaining the ciphertext from block n feeds into the process for block n+1 – the blocks are chained together. To steal an image from Wikipedia: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Block_Chaining_.28CBC.29 As I said earlier, all ciphers on BIG-IP are CBC mode except for RC4 (the lone stream cipher, disabled by default starting in 11.6.0) and AES-GCM. AES-GCM was first introduced in 11.5.0, and it is only available for TLSv1.2 connections. GCM stands for Galois/Counter Mode, a more advanced mode of operation than CBC. In GCM the blocks are not chained together. GCM runs in an Authenticated Encryption with Associated Data (AEAD) mode which eliminates the separate per- message hashing step, therefore it can achieve much higher performance on a given HW platform than CBC. It is also immune to classes of attack that have harried CBC, such as padding (BEAST, Lucky 13, etc.) The main drawback to AES-GCM is that it was only added in the TLSv1.2 revision, so any older clients which don’t support TLSv1.2 cannot use it. Pronouncing Galois: https://youtu.be/bjHuJyGf-vE “A hash function is any function that can be used to map data of arbitrary size to data of fixed size. The values returned by a hash function are called hash values, hash codes, hash sums, or simply hashes. [snip] They are also useful in cryptography. A cryptographic hash function allows one to easily verify that some input data maps to a given hash value, but if the input data is unknown, it is deliberately difficult to reconstruct it (or equivalent alternatives) by knowing the stored hash value. This is used for assuring integrity of transmitted data, and is the building block for HMACs, which provide message authentication.” – Wikipedia In short, the MAC provides message integrity. Hash functions include MD5, SHA-1 (aka SHA), SHA-2 (aka SHA128, SHA256, & SHA384), and AEAD (Authenticated Encryption with Associated Data). MD5 has long since been rendered completely insecure and is deprecated. SHA-1 is now being ‘shamed’ by browsers as it is falling victim to advances in cryptographic attacks. It is encouraged to migrate to SHA-2 ASAP. https://en.wikipedia.org/wiki/Hash_function Now that we’ve covered what cipher suites are, lets look at where we use them. There are two distinct and separate areas where cipher suites are used – the host, or control plane, and tmm, or the data plane. On the control plane SSL/TLS is handled by OpenSSL and the configuration follows the standard OpenSSL configuration options. In tmm the cipher suites are configured in the Ciphers field of the Client SSL or Server SSL profiles. See K14783 & K14806, respectively. It is important to keep in mind that these are two different worlds with their own requirements and quirks. SSL/TLS on the control plane basically means httpd. This is the default in 12.0.0: tmsh list sys http ssl-ciphersuite sys httpd { ssl-ciphersuite DEFAULT:!aNULL:!eNULL:!LOW:!RC4:!MD5:!EXP } You can configure the cipher suite with ’tmsh modify sys http ssl-ciphersuite <value>’. Note that the default is not just ‘DEFAULT’, as it is in tmm. So what ciphers are actually supported? For that you want to run: openssl ciphers -v 'DEFAULT:!aNULL:!eNULL:!LOW:!RC4:!MD5:!EXP‘ That will list out all of the ciphers enabled by this configuration. Let’s see that on the next slide. openssl ciphers -v 'DEFAULT:!aNULL:!eNULL:!LOW:!RC4:!MD5:!EXP' ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD ECDHE-ECDSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AESGCM(256) Mac=AEAD ECDHE-RSA-AES256-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AES(256) Mac=SHA384 ECDHE-ECDSA-AES256-SHA384 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AES(256) Mac=SHA384 ECDHE-RSA-AES256-SHA SSLv3 Kx=ECDH Au=RSA Enc=AES(256) Mac=SHA1 ECDHE-ECDSA-AES256-SHA SSLv3 Kx=ECDH Au=ECDSA Enc=AES(256)