in Uncategorized

Fix for Weak Diffie-Hellman and the Logjam Attack

Diffie-Hellman key exchange is an popular cryptographic algorithm that provide secure way of exchanging cryptographic key ever a public network/channel. D–H is one of the earliest practical examples of public key exchange implemented within the field of cryptography. It is fundamental to many protocols including HTTPS, SSH, IPsec, SMTPS, and protocols that rely on TLS.

Below are several weaknesses in how Diffie-Hellman key exchange has been deployed:

  1. Logjam attack against the TLS protocol. The Logjam attack allows a man-in-the-middle attacker to downgrade vulnerable TLS connections to 512-bit export-grade cryptography. This allows the attacker to read and modify any data passed over the connection. The attack is reminiscent of the FREAK attack, but is due to a flaw in the TLS protocol rather than an implementation vulnerability, and attacks a Diffie-Hellman key exchange rather than an RSA key exchange.
  2. Millions of HTTPS, SSH, and VPN servers all use the same prime numbers for Diffie-Hellman key exchange. Practitioners believed this was safe as long as new key exchange messages were generated for every connection. However, the first step in the number field sieve—the most efficient algorithm for breaking a Diffie-Hellman connection—is dependent only on this prime. After this first step, an attacker can quickly break individual connections.

To fix issue with weak Diffie Hellman Logjam Attack you need to:

  1. Disable Export Cipher Suites.
  2. Deploy (Ephemeral) Elliptic-Curve Diffie-Hellman (ECDHE)
  3. Use a Strong Diffie Hellman Group

Below is a Fix for Nginx web server:

Update strong ssl_ciphers in global NGINX configuration file

vim /etc/nginx/nginx.conf
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;

Create a Strong DH Group

Run following command on your server

openssl dhparam -out /etc/nginx/dhparams.pem 2048

open your NGINX configuration file

vim /etc/nginx/nginx.conf

and update below directive into it

ssl_dhparam /etc/nginx/dhparams.pem;

Reload or Restart Nginx Services.

service nginx restart

References: