apache2.2 SSL has no forward-secrecy: need ECDHE keys

Bug #1197884 reported by RichardNeill
414
This bug affects 29 people
Affects Status Importance Assigned to Milestone
Apache2 Web Server
Fix Released
Wishlist
apache2 (Debian)
Fix Released
Unknown
apache2 (Ubuntu)
Fix Released
Wishlist
Unassigned
Precise
Fix Released
Wishlist
Marc Deslauriers

Bug Description

In the light of recent revelations about Prism/NSA/GCHQ etc, it is more important than ever to keep SSL secure.

But... as far as I can tell, there exists no combination of SSL cIphers that satisfies all of:

 * Resistant to the BEAST attack
 * Has Perfect Forward Secrecy
 * Is in Apache 2.2

[I'm testing with: https://www.ssllabs.com/ssltest/analyze.html ]

The only solution seems to be to deploy Apache 2.4 (or backport the ECDHE ciphers into the 2.2 package).

Can I suggest therefore that the lack of Apache 2.4 packages represents a serious security vulnerability to people visiting websites hosted on Ubuntu.

This affects every currently released Ubuntu distro (including raring). There is still no pacakge of apache 2.4, nor is there a backport of the ECDHE feature. There are some PPAs of 2.4, but these aren't maintained with security updates, nor do they support mod_php.

Tags: precise
Revision history for this message
In , Erwann-abalea (erwann-abalea) wrote :

Created attachment 25714
Allow admin-choosen DH parameters for DHE enabled cipher-modes

In order to be EAL4+ validated for one of our customers, Apache needs to be able to support 2048+ bits group size for Diffie-Hellman parameters. Right now, temporary parameters are 512 and 1024 bits only.

We can still disallow DH at all, leaving only RSA for authentication and pre-master secret encryption, but that's a suboptimal solution, as we then loose forward secrecy.

Adding a 2048 bits DH temporary key into mod_ssl is not possible, since OpenSSL would only ask for a 512/1024 bits one, depending on the "exportability" of the choosen ciper-mode.

This patch adds a new configuration directive, "SSLDHParametersFile <file>", allowing the administrator to supply its own Diffie-Hellman parameters ("openssl dhparam 2048 > dhparam2048.pem" to generate 2048 bits ones, for example).
If this directive is specified and parameters are found in the supplied file, then these parameters will be used whenever DHE is used to negociate the pre-master secret. If this directive is not used, then it works like it does now, leaving OpenSSL ask mod_ssl for a set of parameters of the desired size (512 or 1024 bits).

We'd like this to be evaluated, discussed, and if possible, applied.

Regards.

Revision history for this message
In , Erwann-abalea (erwann-abalea) wrote :

Created attachment 28699
Updated patch for 2.4.2

Revision history for this message
In , Erwann-abalea (erwann-abalea) wrote :

A new version of the patch has been provided, based on httpd 2.4.2.
When generating your own DH parameters, add the "-dsaparam" option to openssl commandline, this speeds up the handshake by about 15% for a 1024bits prime to 30% for a 2048bits prime.
With "-dsaparam" option, the private key is limited to 160 bits for a <2048bits prime, and 256 bits for a >=2048bits one. You then have 80bits of security for a 1024bits prime, but based on NFS results you can't get much.
2048bits prime with a 256bits private key length gives you 128bits of security.

Revision history for this message
In , Michaelm12-asfbugzilla (michaelm12-asfbugzilla) wrote :

Any idea on when this might make it into 2.4.x or 2.2.x?

Many thanks.

information type: Private Security → Public Security
Changed in apache2 (Ubuntu):
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
RichardNeill (ubuntu-richardneill) wrote :

Thanks for your assistance.

Can I ask why you think this is merely a wishlist item?

If I've understood the import of this correctly, then the privacy of every visitor to every website served by Apache on every version(*) of Ubuntu is at risk. I don't think that forward-secrecy in SSL is an optional extra; I think it's a requirement. Also, in my view, server administrators who deploy https are making an implicit promise to their site's visitors - and this is a promise which they cannot honour.

(*)even Saucy doesn't have 2.4 packages yet, though 2.4 is in Debian, Mageia, and Fedora.

Revision history for this message
In , Frazzzzze (frazzzzze) wrote :

I would like to see this added to 2.2.x and 2.4.x too!

Revision history for this message
RichardNeill (ubuntu-richardneill) wrote :

Just to answer this, the upgrade has hit Saucy, and I have tested it successfully. I'll mark it as fix-committed. Thanks for your time.

Changed in apache2 (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
In , Geoffroy+dev (geoffroy+dev) wrote :

In addition, Elliptic Curve choice should also be given to the server admin in a similar way (e.g. SSLCurveList <enabled_curve_list> ). Tell the admin to execute 'openssl ecparam -list_curves' to get a list of the supported curves.

Revision history for this message
In , Christoph_vW (christoph-apiviewer) wrote :

Would someone please apply this patch to 2.2.x and 2.4.x ... ?

Revision history for this message
In , Harald-dunkel-r (harald-dunkel-r) wrote :

I'd love to see this added to 2.2.x and 2.4.y

Revision history for this message
In , Asfbugz (asfbugz) wrote :

Created attachment 30804
PoC: read (EC)DHE parameters from SSLCertificateFile (applies to trunk and 2.4.x)

I'm fine with the idea, but the implementation in the patches submitted so far is too complex, in my opinion (in particular the SSL_read_DHparams stuff, which tries to support/read three different formats).

Here is an alternative proposal:

- only support PEM-formatted parameters (-----BEGIN DH PARAMETERS---- / -----END DH PARAMETERS-----)

- use the existing SSLCertificateFile directive to support per-vhost, custom DHE and ECDHE parameters

Attached is a - lightly tested - proof of concept, to be applied to either trunk or 2.4.x... testing and feedback welcome. To specify EC curve names, append the output of "openssl ecparam -name secp521r1" or your favorite curve to SSLCertificateFile (of course the docs for SSLCertificateFile would have to be extended, if there is a general agreement on taking this approach).

Revision history for this message
In , Erwann-abalea (erwann-abalea) wrote :

(In reply to Kaspar Brand from comment #8)
> Created attachment 30804 [details]
> PoC: read (EC)DHE parameters from SSLCertificateFile (applies to trunk and
> 2.4.x)
>
> I'm fine with the idea, but the implementation in the patches submitted so
> far is too complex, in my opinion (in particular the SSL_read_DHparams
> stuff, which tries to support/read three different formats).

This function is similar to SSL_read_X509 and SSL_read_PrivateKey defined in the same file, and used by the module to read the corresponding objects.

That said, I'm not fluent in Apache internals, and I admit some things may have been done more easily. I tried to mimic how already existing elements (keys and certs) were declared, registered and used, when adding a new element type (DHParams).

> - use the existing SSLCertificateFile directive to support per-vhost, custom
> DHE and ECDHE parameters

The original patch is also vhost-aware.
It doesn't know about ECDHE, that's true. That wasn't critical at that time (2010) because nobody used ECDHE, and even today the used curve is the standard NIST P256, offering 128bits of security in theory. Since a few weeks, some people want to be able to specify the curve used, there's nothing wrong with that.

Revision history for this message
In , Hiding-l (hiding-l) wrote :

(In reply to Kaspar Brand from comment #8)

I applied your patch in my testing environment with httpd-2.4.6 and it works as advertised. After appending DH parameters to the certificate file, all DH ciphers were using the expected key size.

I found it a bit confusing that you actually have to put the params alongside your certificate into one file. One has to pay more attention to these additional settings on changing the certificate.

But if it is actually way more easy to implement DH / ECDHE parameters this way, then it is probably the way to go.

Revision history for this message
Christoph_vW (christoph-apiviewer) wrote :

Don't you think it would be better to backport this for Apache 2.2?
What about all the Ubuntu 12.04 LTS versions which will be running for some more years?

Revision history for this message
In , Asfbugz (asfbugz) wrote :

(In reply to Erwann Abalea from comment #9)
> This function is similar to SSL_read_X509 and SSL_read_PrivateKey defined in
> the same file, and used by the module to read the corresponding objects.

Perhaps this is an opportunity to clean up some mod_ssl cruft... I just took an extended proposal to the mailing list, to stir some further discussion:

http://mail-archives.apache.org/mod_mbox/httpd-dev/201309.mbox/%<email address hidden>%3E

Additionally, I think we should consider to use 2048-bit DH parameters by default if the cert's RSA/DSA key is 2048 bits or more (so that sysadmin's don't have to generate their custom DH parameters to get more than 1024 bits for DHE). Changing this by default is probably debatable, and therefore another reason I'm taking it to the list.

Revision history for this message
In , Frazzzzze (frazzzzze) wrote :

DH-parameters should always be at least the same size as the SSL certificate, so if I use 4096 or even 8192 bit for the certificate a DH parameter with only 2048 bit would effectively weaken the whole connection down to 2048 bit, which we don't want and in a few years we would have the exactly same situation ( DH parameters too weak and not FULLY selectable) as we do right now
So please consider this and let the admin choose freely, but at least make sure DH parameters bits are never smaller than SSL certificate bits!

Revision history for this message
In , Asfbugz (asfbugz) wrote :

Comment on attachment 30804
PoC: read (EC)DHE parameters from SSLCertificateFile (applies to trunk and 2.4.x)

For trunk, this issue has been addressed with r1527295 (with updated documentation under https://httpd.apache.org/docs/trunk/mod/mod_ssl.html#sslcertificatefile). A backport proposal for 2.4.x will likely follow.

Revision history for this message
In , Asfbugz (asfbugz) wrote :

Backport to 2.4.x proposed with r1528154. Patch available at https://people.apache.org/~kbrand/mod_ssl-2.4.x-ekh.diff.

Revision history for this message
Nestor Urquiza (nestoru) wrote :

+1 for Chris question. Any plans for an Apache 2.2 back-port?

Revision history for this message
mike (msidnam) wrote :

An Apache 2.2 back-port would be great. what are the plans for this?

Revision history for this message
Douglas Perry (dperry) wrote :

+1 on the backport. I'm a co-founder of a non-profit. Our websites have to default to SSL to protect the privacy of our clients. Since this is a production webserver, we can only use Ubuntu 12.04 LTS as that's what our IaaS vendor offers us for Ubuntu/Debian distros. The lack of forward-secrecy is a risk exposure to us and would like see it addressed.

Revision history for this message
In , Nick Le Mouton (7icq) wrote :

The patch https://people.apache.org/~kbrand/mod_ssl-2.4.x-ekh.diff seems to break TLS 1.1 and 1.2 on my setup (RHEL 6.x, apache 2.4.6, openssl 1.0.1e). I haven't had a chance to look into it further, but using ssllabs.com it no longer showed me as supporting > TLS 1.0

Revision history for this message
In , Nick Le Mouton (7icq) wrote :

Sorry, was a config error on my side. Patch works well.

Revision history for this message
In , dkg (dkg0) wrote :

I'm glad to see this patch being backported to 2.4. What are the considerations for backporting it to the 2.2.x branch as well?

Revision history for this message
Lloyd Day (lloyd-mcse) wrote :

Yeah I have to add my +1 to this too, as I feel waiting for Ubuntu 14.04 LTS is too long!

Revision history for this message
In , Asfbugz (asfbugz) wrote :

Comment on attachment 28699
Updated patch for 2.4.2

Marking as obsolete, since a different approach has been implemented in 2.4.x.

Revision history for this message
In , Asfbugz (asfbugz) wrote :

Fixed in 2.4.7 with r1542327.

Revision history for this message
Robie Basak (racb) wrote :

Since this is fixed in Saucy, I'm marking this bug as Fix Released. If you want PFS in an official Ubuntu release, use Ubuntu 13.10.

I understand that some of you want this feature backported to 12.04. That's fine, but this is a considerable amount of work and I don't think it falls under the Ubuntu "LTS" remit. If somebody wants to backport Apache 2.4 and make it available in 12.04, please do so - see https://wiki.ubuntu.com/UbuntuBackports for the process. Or alternatively, publish and maintain a third party PPA and announce it here.

Backports and PPAs are the acceptable options here. We do not backport features to LTS releases. That's why they're LTS - because you expect them to be stable and not introduce unnecessary regressions. You may want PFS added, but others don't want their production systems running on LTS messed with. So we generally do not backport features, and I don't think PFS warrants an exception. See https://wiki.ubuntu.com/StableReleaseUpdates for the policy. Your route is simple: if you want a new feature, use a newer release, or sponsor the backport work yourselves and use a third party maintained backport or PPA.

Changed in apache2 (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Nestor Urquiza (nestoru) wrote :

I thought this request felt under the below wording in https://wiki.ubuntu.com/StableReleaseUpdates :

<quote>
Stable release updates will, in general, only be issued in order to fix high-impact bugs. Examples of such bugs include:

Bugs which may, under realistic circumstances, directly cause a security vulnerability. These are done by the security team and are documented at SecurityTeam/UpdateProcedures.
...
</quote>
I believe this threat is very realistic ( http://blog.ivanristic.com/2013/06/ssl-labs-deploying-forward-secrecy.html ). I guess the metrics to determine what warrants an exception are up to you for sure but as far as I can tell the privacy cost of this vulnerability justifies the upgrade for apache servers *only* or the usage of a PPA like https://launchpad.net/~derek-morton/+archive/apache-2.4 if you decide to trust it or simply building apache 2.4 from scratch. If the server is not running apache clearly there is nothing to be worry about.

Thanks for the statement because at least the wait is over.

Best,
- Nestor

Revision history for this message
JorSol (jorsol) wrote :

This bug is for Apache 2.2 not for Apache 2.4 so don't mark as fix released when thats not the case...

This has been fixed already in Debian 7.6 and there is a debdiff for it so there should not be a considerable amount of work to apply it right now.

Ubuntu 12.04 will be supported until 2017 thats 3 more years, this qualify as SRU as the regression potential is near to zero, since it just adds support for more ciphers to Apache, if for some reason anyone don't want to use the EC cipher suites just add !ECDH to the list of cipher suites.

Changed in apache2 (Debian):
status: Unknown → Fix Released
Revision history for this message
Robie Basak (racb) wrote :

Thank you for linking the Debian bug.

> This bug is for Apache 2.2 not for Apache 2.4 so don't mark as fix released when thats not the case...

The status is defined to reflect the status in the development release, where it is fixed. I'll add a Precise task for you though, to track status for 12.04 specifically.

> This has been fixed already in Debian 7.6 and there is a debdiff for it so there should not be a considerable amount of work to apply it right now.

Agreed. That Debian has chosen to do this suggests that it may be a good idea for Ubuntu also, and that there is a way to minimise regression.

> ...as the regression potential is near to zero

Message https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733564#37 suggests that this is not true, and that we need to also patch openssl to avoid regressing Mac clients. Please can you expand on this?

If someone can post a debdiff and post an accurate regression potential analysis, then I think it's fine to ask the SRU team to consider this case.

I would still want someone to drive this please; both in preparing the patches for Ubuntu, and also in thoroughly testing for regressions during the SRU process.

I would note though that 14.04 is out now, so an LTS path is also already available to users.

Haw Loeung (hloeung)
Changed in apache2 (Ubuntu Precise):
status: New → Confirmed
dino99 (9d9)
tags: added: precise
Haw Loeung (hloeung)
Changed in apache2 (Ubuntu Precise):
importance: Undecided → Wishlist
Revision history for this message
Jonathan (jonathan00) wrote :

hi,

i included the patch from debian to ubuntu. Added an debdiff.

about the openssl/mac os x problem:

if i follow the ciphers from https://community.qualys.com/blogs/securitylabs/2013/08/05/configuring-apache-nginx-and-openssl-for-forward-secrecy

ciphers with ECDHE-ECDSA-* are not enabled, so this should not be a problem.
for details see http://wiki.openssl.org/index.php/SSL_OP_SAFARI_ECDHE_ECDSA_BUG

my patched apache is now running without any problem more than a week.

Revision history for this message
Jonathan (jonathan00) wrote :

for a quick & dirty solution you can replace /usr/lib/apache2/modules/mod_ssl.so (x86_64)

Revision history for this message
Haw Loeung (hloeung) wrote :

FYI, ECDHE-ECDSA-* cipher suites are only enabled when using ECDSA SSL certificates (with RSA being the most common).

Revision history for this message
Jonathan (jonathan00) wrote :

i created a ppa: https://launchpad.net/~jonathan00/+archive/ubuntu/apache2/

@Haw: Thanks for the info

Revision history for this message
Haw Loeung (hloeung) wrote :

With the recently released logjam attack, can we please revisit and increase the priority for, backporting ECDHE support to apache2.2?

https://weakdh.org/
http://openssl.org/blog/blog/2015/05/20/logjam-freak-upcoming-changes/

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

I'll work on releasing this for precise next week.

Changed in apache2 (Ubuntu Precise):
assignee: nobody → Marc Deslauriers (mdeslaur)
Revision history for this message
Patrick Domack (patrickdk) wrote :

This is a patch I created, by backporting 2.4 commits for DH keys to 2.2, to solve the DH keys too small issues on certs.

Adding here in case it helps anyone.

Revision history for this message
Andreas Tauscher (ta-lonestar-bbs) wrote :

I did not want to wait until this is fixed for apache 2.22 in Ubuntu 12.04

So I took mod_ssl from apache 2.2.29 which supports ECDH.
Additional I removed the 512 and 1024 bit DH parameters from ssl_engine_dh.c and replaced them with 2048 and 3072 bit.
Two DH keys are not needed because libssl in 12.04 never asks for more than 1024 bit so always 3072 are returned. But I realised this afterwards....

You can download my modified mod_ssl from http://download.ict-pros.co.tz/mod_ssl-apache2.22.tar.bz2
Short instructions:
apt-get source apache2
apt-get build-dep apache2
Replace modules/ssl with the modified version.
Run within modules/ssl perl ./ssl_engine_dh.c to generate your own DH parameters.
Build the package. After updates mod_ssl.so will be overwritten so you have to copy your compiled version from debian/apache2.2-bin/usr/lib/apache2/modules/ to /usr/lib/apache2/modules/ and restarting apache.

Andreas

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

There is a test package for precise available here:

https://launchpad.net/~ubuntu-security-proposed/+archive/ubuntu/ppa/+packages

Once it has gone through testing, it will be published as an update.

Revision history for this message
In , Ylavic-dev (ylavic-dev) wrote :

Backported to 2.2.30 in r1680916.

Revision history for this message
Haw Loeung (hloeung) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apache2 - 2.2.22-1ubuntu1.9

---------------
apache2 (2.2.22-1ubuntu1.9) precise-security; urgency=medium

  * SECURITY IMPROVEMENT: add support for ECC keys and ECDH ciphers
    (LP: #1197884)
    - debian/patches/ecc_support.patch: add support to
      modules/ssl/mod_ssl.c, modules/ssl/ssl_engine_init.c,
      modules/ssl/ssl_engine_kernel.c, modules/ssl/ssl_private.h,
      modules/ssl/ssl_toolkit_compat.h, modules/ssl/ssl_util.c,
  * SECURITY IMPROVEMENT: add TLSv1.x options to SSLProtocol (LP: #1400473)
    - debian/patches/tls_options.patch: allow specifying later TLSv1.x
      options in modules/ssl/mod_ssl.c, modules/ssl/ssl_engine_config.c,
      modules/ssl/ssl_engine_init.c, modules/ssl/ssl_engine_kernel.c,
      modules/ssl/ssl_private.h.
  * SECURITY IMPROVEMENT: improve ephemeral key handling, including
    allowing DH parameters to be loaded from SSLCertificateFile and
    disabling EXPORT ciphers.
    - debian/patches/ephemeral_key_handling.patch: numerous improvements to
      modules/ssl/mod_ssl.c, modules/ssl/ssl_engine_config.c,
      modules/ssl/ssl_engine_dh.c, modules/ssl/ssl_engine_init.c,
      modules/ssl/ssl_engine_kernel.c, modules/ssl/ssl_private.h,
      modules/ssl/ssl_util_ssl.c, modules/ssl/ssl_util_ssl.h.

 -- Marc Deslauriers <email address hidden> Thu, 28 May 2015 12:26:50 -0400

Changed in apache2 (Ubuntu Precise):
status: Confirmed → Fix Released
Mathew Hodson (mhodson)
Changed in apache2:
importance: Undecided → Unknown
status: New → Unknown
Changed in apache2:
importance: Unknown → Wishlist
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Duplicates of this bug

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.