Bug 37566 - More fine-grained configuration of mod_ssl
More fine-grained configuration of mod_ssl
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Apache
UCS 4.0
Other Linux
: P5 enhancement (vote)
: UCS 4.0-1-errata
Assigned To: Moritz Muehlenhoff
Erik Damrose
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-19 11:28 CET by Moritz Muehlenhoff
Modified: 2015-06-02 14:33 CEST (History)
5 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
klaeser: Patch_Available+


Attachments
Patch adding more fine-grained configuration of mod_ssl (1.44 KB, patch)
2015-02-15 18:02 CET, Lutz Willek
Details | Diff
Patch adding more fine-grained configuration of mod_ssl (1.54 KB, patch)
2015-02-15 20:19 CET, Lutz Willek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Muehlenhoff univentionstaff 2015-01-19 11:28:54 CET
It would be useful to allow more configuration options for mod_ssl (it's already a UCR template: /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf)

- Allow SSLProtocol to only accept TLS 1.2
- Make SSLCipherSuite configurable
- Make SSLCompression configurable
Comment 1 Lutz Willek 2015-02-15 18:02:51 CET
Created attachment 6676 [details]
Patch adding more fine-grained configuration of mod_ssl

# apt-get install patch

# cp /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf etc/univention/templates/files/etc/apache2/mods-available/ssl.conf.orig

# patch -p0 <ssl.conf.patch /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf
patching file /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf

# ucr set apache2/ssl/honorcipherorder='On'
Create apache2/ssl/honorcipherorder

# ucr set apache2/ssl/ciphersuite='kEECDH+ECDSA:kEECDH:kEDH:HIGH:+SHA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!DSS:!PSK:!SRP:!kECDH:!CAMELLIA:!RC4'
Create apache2/ssl/ciphersuite

## Note: Enabling compression causes security issues in most setups 
## (the so called CRIME attack).
##
# ucr set apache2/ssl/compression='On'
Create apache2/ssl/compression

# ucr commit /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf

# service apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
Comment 2 Lutz Willek 2015-02-15 20:19:31 CET
Created attachment 6677 [details]
Patch adding more fine-grained configuration of mod_ssl

## first, apply and commit patch from from comment #1
## - Make SSLCipherSuite configurable
## - Make SSLCompression configurable
## - Make SSLHonorCipherOrder configurable
##
# patch -p0 < ssl.conf.patch /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf
patching file /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf
# ucr commit /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf
# cp /etc/apache2/mods-available/ssl.conf /etc/apache2/mods-available/ssl.conf.orig 
## this .orig file will be used to monitor the success of following  patch1

## apply and commit patch "patch1" (attached to this comment)
## - Allow SSLProtocol to only accept TLS 1.2
## - Allow SSLProtocol to only accept TLS 1.1
## - Allow SSLProtocol to only accept TLS 1.0
## - Allow SSLProtocol to any mixture of the protocols TLS 1.0, TLS 1.1, TLS 1.2, SSLv3
##
# patch -p0 < ssl.conf.patch1 /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf
patching file /etc/univention/templates/files/etc/apache2/mods-available/ssl.conf
# ucr commit /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf
# diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
84a85,103
> #   SSLProtocol
> #   This directive can be used to control the SSL protocol flavors mod_ssl should use when 
> #   establishing its server environment. 
> #   Clients then can only connect with one of the provided protocols.
> #   Default: SSLProtocol all -SSLv2 -SSLv3
> #   SSLv3
> #      This is the Secure Sockets Layer (SSL) protocol, version 3.0, from the Netscape Corporation.
> #      It is the successor to SSLv2 and the predecessor to TLSv1. It's supported by almost all browsers.
> #      Setting UCR variable apache2/ssl/v3 to "True" enables SSLv3 (default: disabled)
> #   TLSv1
> #      Transport Layer Security (TLS) protocol, version 1.0.
> #      It is the successor to SSLv3 and is defined in RFC 2246.
> #      Setting UCR variable apache2/ssl/tlsv1 to "False" disables TLSv1 (default: enabled)
> #   TLSv1.1
> #      A revision of the TLS 1.0 protocol, as defined in RFC 4346.
> #      Setting UCR variable apache2/ssl/tlsv11 to "False" disables TLSv1.1 (default:enabled)
> #   TLSv1.2
> #      A revision of the TLS 1.0 protocol, as defined in RFC 5246.
> #      Setting UCR variable apache2/ssl/tlsv12 to "False" disables TLSv1.2 (default:enabled)

# ## --> as you can see, patch1 adds some comments by default, but no config will be changed
# ## --> let's hide the comment lines above:
# cp /etc/apache2/mods-available/ssl.conf /etc/apache2/mods-available/ssl.conf.orig 
# diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
# ## --> comment lines are "hidden" now

# ## test 1: apache2/ssl/v3: (default: unset, SSLv3 is disabled)
# ucr set apache2/ssl/v3="true" ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Create apache2/ssl/v3
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf
104c104
< SSLProtocol all -SSLv2 -SSLv3
---
> SSLProtocol all -SSLv2
# ## --> passed.

# ## test 2: apache2/ssl/v3: (default: unset, SSLv3 is disabled)
# ucr set apache2/ssl/v3="false" ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Setting apache2/ssl/v3
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf
# ## --> passed.

# ## test 3: apache2/ssl/v3: (default: unset, SSLv3 is disabled)
# ucr unset apache2/ssl/v3 ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Unsetting apache2/ssl/v3
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf
# ## --> passed.  UCR variable "apache2/ssl/v3" works as expected. 

# ## test 4: new UCR variable apache2/ssl/tlsv1: (default: unset, TLSv1 is enabled)
# ucr set apache2/ssl/tlsv1="false" ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Create apache2/ssl/tlsv1
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
104c104
< SSLProtocol all -SSLv2 -SSLv3
---
> SSLProtocol all -SSLv2 -SSLv3 -TLSv1
# ## --> passed.

# ## test 5: new UCR variable apache2/ssl/tlsv1: (default: unset, TLSv1 is enabled)
# ucr set apache2/ssl/tlsv1="true" ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Setting apache2/ssl/tlsv1
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
# ## --> passed.

# ## test 6: new UCR variable apache2/ssl/tlsv1: (default: unset, TLSv1 is enabled)
# ucr unset apache2/ssl/tlsv1 ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Unsetting apache2/ssl/tlsv1
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
# ## --> passed.  NEW UCR variable "apache2/ssl/tlsv1" works as expected.


# ## test 7: new UCS variables apache2/ssl/tlsv11 and apache2/ssl/tlsv12 (default: unset, TLSv1.1 and  TLSv1.2 are enabled)
# ucr set apache2/ssl/tlsv1="false"; ucr set apache2/ssl/tlsv11="false" ; ucr set apache2/ssl/tlsv12="false" ; ucr set apache2/ssl/v3="true" ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Create apache2/ssl/tlsv1
Module: zarafa-cfg
Create apache2/ssl/tlsv11
Module: zarafa-cfg
Create apache2/ssl/tlsv12
Module: zarafa-cfg
Create apache2/ssl/v3
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf
104c104
< SSLProtocol all -SSLv2 -SSLv3
---
> SSLProtocol all -SSLv2 -TLSv1 -TLSv1.1 -TLSv1.2
# ## --> passed.

# ## test 8: new UCS variables apache2/ssl/tlsv11 and apache2/ssl/tlsv12 (default: unset, TLSv1.1 and  TLSv1.2 are enabled)
# ucr unset apache2/ssl/tlsv1 ; ucr unset apache2/ssl/tlsv11 ; ucr unset apache2/ssl/tlsv12 ; ucr unset apache2/ssl/v3 ; ucr commit /etc/apache2/mods-available/ssl.conf ; diff /etc/apache2/mods-available/ssl.conf.orig /etc/apache2/mods-available/ssl.conf
Unsetting apache2/ssl/tlsv1
Module: zarafa-cfg
Unsetting apache2/ssl/tlsv11
Module: zarafa-cfg
Unsetting apache2/ssl/tlsv12
Module: zarafa-cfg
Unsetting apache2/ssl/v3
Module: zarafa-cfg
File: /etc/apache2/mods-available/ssl.conf
File: /etc/apache2/mods-available/ssl.conf
# ## --> passed.  NEW UCR variable "apache2/ssl/tlsv1" works as expected.

# ## --> all tests passed.
Comment 3 Lutz Willek 2015-02-15 22:51:23 CET
Hallo, guten Morgen Univention,

ich hatte heute Zeit mich wieder mit dem Thema auseinanderzusetzen: Die Standardkonfiguration des Apache ist, vorsichtig ausgedrückt, ja nicht mehr ganz zeitgemäß, wenn dieser direkt im Internet betrieben wird.
Das wird er ja hier bei uns, daher ist das Thema für mich wichtig. Ich habe deshalb für diesen Bugreport von Herr Muehlenhoff einen bereits in Bug 34391 eingereichten Patch weiterentwickelt und gegen einen aktuellen UCS 4.0.1 getestet, damit dieser Zustand ohne manuelles Anpassen von Konfigurationsdateien behoben werden kann.

Beim schreiben des Patches wurde darauf geachtet bestehende Konfiguration der Systeme (mit Ausnahme von Hinzufügen von Kommentarzeilen) nicht zu verändern, solange die UCR Variablen nicht explizit gesetzt werden.
Durch den Patch werden alle geforderten Konfigurationsvarianten erlaubt. Zusätzlich habe ich SSLHonorCipherOrder hinzugefügt, da dies ja doch recht oft benötigt wird, wenn die SSLCipherSuite Directive angepasst wird.
Der Patch wurde soweit mir möglich getestet: Ich habe keine Seiteneffekte feststellen können.

Ich hoffe natürlich (schon aus Eigennutz) das dieses enhancement möglichst schnell in UCS4 integriert wird: Wenn ich etwas tun kann um den Prozess für Sie zu vereinfachen oder zu beschleunigen, dann lassen Sie mich das bitte wissen. Ich denke da an noch fehlende Beschreibungsdateien, Patches direkt gegen das svn, so etwas in der Art.

Schöne Grüße aus Berlin, Ihnen einen guten Start in die neue Woche!
Lutz Willek


Folgend noch die Beschreibung der durch den Patch neu geschaffenen Variablen.

services/univention-apache/debian/univention-apache.univention-config-registry-variables: (ergänzen)

[apache2/ssl/tlsv1]
Description[de]=Konfiguriert das SSL-Protokoll Transport Layer Security (TLS) version 1.0. Es ist der Nachfolger von SSLv3 und ist in RFC 2246 definiert. Ist die Variable nicht (Standard) oder auf den Wert true gesetzt, so ist TLSv1 aktiviert ist und wird verwendet.
Description[en]=Configures SSL flavor Transport Layer Security (TLS) protocol, version 1.0. It is the successor to SSLv3 and is defined in RFC 2246. If the variable is unset (default) or set to true, TLSv1 is enabled and will be used.
Type=bool
Categories=service-apache

[apache2/ssl/tlsv11]
Description[de]=Konfiguriert das SSL-Protokoll Transport Layer Security (TLS) version 1.1, definiert in RFC 4346. Ist die Variable nicht (Standard) oder auf den Wert true gesetzt, so ist TLSv1.1 aktiviert ist und wird verwendet.
Description[en]=Configures SSL flavor Transport Layer Security (TLS) version 1.1, as defined in RFC 4346. If the variable is unset (default) or set to true, TLSv1.1 is enabled and will be used.
Type=bool
Categories=service-apache

[apache2/ssl/tlsv12]
Description[de]=Konfiguriert das SSL-Protokoll Transport Layer Security (TLS) version 1.2, definiert in RFC 5246. Ist die Variable nicht (Standard) oder auf den Wert true gesetzt, so ist TLSv1.2 aktiviert ist und wird verwendet.
Description[en]=Configures SSL flavor Transport Layer Security (TLS) version 1.2, as defined in RFC 5246. If the variable is unset (default) or set to true, TLSv1.2 is enabled and will be used.
Type=bool
Categories=service-apache

[apache2/ssl/honorcipherorder]
Description[de]=Bei der Wahl einer Chiffre während des SSLv3 oder TLSv1 Handshake wird normalerweise die Präferenz des Clients verwendet. Wenn diese Variable auf 'On' eingestellt ist, dann wird stattdessen die Präferenz des Server verwendet werden. Siehe auch apache2/ssl/ciphersuite
Description[en]=When choosing a cipher during an SSLv3 or TLSv1 handshake, normally the client's preference is used. If this varable is set to 'On', the server's preference will be used instead. See also apache2/ssl/ciphersuite
Type=str
Categories=service-apache

[apache2/ssl/compression]
Description[de]=Diese Variable ermöglicht die Komprimierung auf dem SSL-Ebene zu aktivieren, wenn auf 'On' gesetzt. Achtung: Die Aktivierung der Komprimierung verursacht Sicherheitsprobleme (siehe auch CRIME Angriff) in den meisten Setups und wird daher nicht empfohlen.
Description[en]=This variable allows to enable compression on the SSL level if set to 'On'. Warning: Enabling compression causes security issues in most setups (the so called CRIME attack) and is not recomended
Type=str
Categories=service-apache

[apache2/ssl/ciphersuite]
Description[de]=Dies konfiguriert die Cipher Suite, die ein Client in der SSL-Handshake-Phase zum Zeitpunkt des Verbindungsaufbaus aushandeln darf. Die Variable verwendet durch Doppelpunkte getrennte Ciphern aus der OpenSSL Verschlüsselungsspezifikationen, wie in http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslciphersuite definiert. Beispiel: 'kEECDH+ECDSA:kEECDH:kEDH:HIGH:+SHA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!DSS:!PSK:!SRP:!kECDH:!CAMELLIA:!RC4'
Description[en]=This configures the Cipher Suite the client is permitted to negotiate in the SSL handshake phase, when a connection is established. The variable uses a colon-separated cipher-spec string consisting of OpenSSL cipher specifications, as defined in http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslciphersuite. Example: 'kEECDH+ECDSA:kEECDH:kEDH:HIGH:+SHA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!DSS:!PSK:!SRP:!kECDH:!CAMELLIA:!RC4'
Type=str
Categories=service-apache




services/univention-apache/debian/univention-apache.univention-config-registry: (erweitern)

...
Type: file
File: etc/apache2/mods-available/ssl.conf
Variables: hostname
Variables: domainname
Variables: apache2/ssl/certificate
Variables: apache2/ssl/key
Variables: apache2/ssl/ca
Variables: apache2/ssl/certificatechain
Variables: apache2/ssl/v3
Variables: apache2/ssl/tlsv1
Variables: apache2/ssl/tlsv11
Variables: apache2/ssl/tlsv12
Variables: apache2/ssl/honorcipherorder
Variables: apache2/ssl/compression
Variables: apache2/ssl/ciphersuite
...
Comment 4 Moritz Muehlenhoff univentionstaff 2015-02-25 12:05:57 CET
(In reply to Lutz Willek from comment #3)
> Ich habe
> deshalb für diesen Bugreport von Herr Muehlenhoff einen bereits in Bug 34391
> eingereichten Patch weiterentwickelt und gegen einen aktuellen UCS 4.0.1
> getestet, damit dieser Zustand ohne manuelles Anpassen von
> Konfigurationsdateien behoben werden kann.

Hallo,
vielen Dank für den Patch! Ich habe ihn mit kleineren Anpassungen übernommen und er wird nach Abschluß der QA in einem kommenden Erratum erscheinen.
(Die folgenden Anmerkungen auf Englisch, damit es alle Kunden lesen können):

- SSL compression is now explicitly disabled by default (it's disabled on the openssl level anyway unless you set a special environment variable)

- I've simplified the selection of TLS versions:
# By default Apache supports TLS 1.0, 1.1 and 1.2
# If you want to enable the insecure legacy protocol SSL3, use apache2/ssl/v3=true
# To only allow TLS 1.1 and TLS 1.2, use apache/ssl/tlsv11=true
# To only allow TLS 1.2, use apache/ssl/tlsv12=true

- apache2/ssl/honorcipherorder and apache2/ssl/compression are treated as boolean UCR variables

While we will retain TLS 1.0 as the base version (IE 7 doesn't support TLS 1.2/1.2 at all and 8-10 require configuration changes) we plan to publish a guide to document stricter options (see Bug 37877)
Comment 5 Moritz Muehlenhoff univentionstaff 2015-03-05 11:24:35 CET
I've additionally changed the default value of apache2/ssl/ciphersuite to
"HIGH:MEDIUM:!aNULL:!MD5:!RC4'". 

This disables the following insecure protocols on the server side:

TLS_RSA_EXPORT_WITH_RC4_40_MD5
TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
TLS_RSA_WITH_DES_CBC_SHA
TLS_DHE_RSA_WITH_DES_CBC_SHA
TLS_RSA_WITH_RC4_128_MD5 (0x4)
TLS_ECDHE_RSA_WITH_RC4_128_SHA
TLS_RSA_WITH_RC4_128_SHA

MD5 and RC4 are both cryptographically broken and should no longer be used. In practice such ciphers would not be negiotiated anyway due to browser preference, but it's a useful hardening against potential future protocol downgrade attacks.

I compared the results of simulated handshake attempts (as simulated by ssllabs.com) and there's no change in unsupported browsers compared to the previous default.



All variables tested with https://www.ssllabs.com/ssltest and sslyze.

For the QA:
In the default setting only TLS 1.0 and above should be allowed and SSL compression should be disabled.

This can be made stricter by setting apache2/ssl/tlsv1[12] to true.
Comment 6 Moritz Muehlenhoff univentionstaff 2015-03-05 12:19:16 CET
YAML file: 2015-03-04-univention-apache.yaml
Comment 7 Erik Damrose univentionstaff 2015-03-09 16:48:55 CET
r58756 small fix to yaml

OK: Updated apache default configuration
OK: Usage of apache2/ssl/tlsv1{1,2}, compression, ciphersuite
OK: Checks with ssllabs and sslyze
OK: Browser compatibility
OK: yaml
Comment 8 Moritz Muehlenhoff univentionstaff 2015-03-11 15:07:44 CET
http://errata.univention.de/ucs/4.0/103.html