jeboehm / docker-mailserver

Docker Mailserver based on the famous ISPMail guide
MIT License
371 stars 97 forks source link

[Request] Easy way to disable TLS v1.0 & v1.1 #208

Closed the-hotmann closed 1 year ago

the-hotmann commented 2 years ago

Is your feature request related to a problem? Please describe. These days SSL v2, v3, TLSv1 & v1.1 are considered insecure and therefore should be disabled by default - with the option to enable it, for those who really want to. I anyway don't see any reason since littlerally all programms that support TLSv1.0 also support 1.2 and mostly also v1.3.

Describe the solution you'd like By default all insecure TLS & SSL Versions to be disabled.

Describe alternatives you've considered Disableing by default, but giving an option in .env to enable insecure stuff.

Additional context I tried to add the config manually to main.cf and main.cf.proto in postfix, but all this just resultet in the container throwing errors.

The config I used was:

# disable tls 1.0 & 1.1
# disable ssl 2 & 3
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1

The config seems valid, but overwriting the config files through docker-volumes (for persistent storage) was not possible.

For the dovecot I added this:

ssl_min_protocol = TLSv1.2

to /etc/dovecot/conf.d/10-ssl.conf but I don't know if it is enough to force TLS >= v1.2

Best regards & thanks in advance!

the-hotmann commented 2 years ago

Any news on this? Would be nice to at least have the option to disable unsecure encryption :)

Thanks!

jeboehm commented 1 year ago

Hi @MartinHotmann there's a pull request for the latest Alpine versions. The PR's tests are failing with some SSL errors, so I think Alpine has changed something about it anyway. Could you test if #216 matches your requirements?

the-hotmann commented 1 year ago

Hi, thanks for the heads-up! As far as I see, #216 is just an alpine update/upgrade to v3.17, but nothing specific about old TLS & SSL versions is mentioned there.

I guess adding the mentioned config snippets to the config, would solve this issue - apparently I could not overwrite the config with docker volumes as the container crashed, when I mapped in my own (modified config) due to some weird fs errors.

A short sumit what could have caused the SSL errors in alpine v3.17: It might be OpenSSL, as v3.16 uses v1.1.1s and v3.17 uses the newer v3.0.7. (click links to see repository)

But in fact I think this does not address the insecure TLS & SSL issue directly, since v3 of openssl also is capable of using them, it must be disabled in the application itself, so it that the application does not accept these insecure versions and rejects them.

Both mda & mta would need it - snippets are mentioned in the first post, I guess just copying them in the config-template will work if it is done at build time of the image.

the-hotmann commented 1 year ago

Just for reference I will link this tutorial, where it is described how to disable the insecure SSL & TLS versions: https://www.transip.eu/knowledgebase/entry/5389-disabling-tls-and-your-mailserver/

I realised, that dovecot now does have the ssl_min_protocol = TLSv1.2 implemented?

jeboehm commented 1 year ago

Hi @MartinHotmann thank you for your useful information! I took a deeper look into it.

I've committed the changes in d65ff03. My testing library imap-tester is not able to connect to TLS1.2, as described in this bugreport. So now I have to dig deeper and implement another IMAP library into the tester. It might be Horde/Imap_Client.

I'll keep you updated.

jeboehm commented 1 year ago

Hi @MartinHotmann the issue is solved! Version 3.5.2 is ready to test.

the-hotmann commented 1 year ago

Thank you very much! I will test it immediately and report back :)

the-hotmann commented 1 year ago

Sooo. I'm back to report back:

  1. thanks for the quick fix!
  2. it worked. TLSv1 & TLSv1.1 are not entorely disabled, but the application does not accept any data on them, but instead signalises to the client Secure Renegotiation IS supported to renegotiate the TLS version and hopefully upgrade.

This is all I expected. Sadly I forgot to add something, but the substance of this request is fullfilled, so I will create a new one.

New Ticket: https://github.com/jeboehm/docker-mailserver/issues/228

the-hotmann commented 1 year ago

@jeboehm actually it seems, that TLSv1 & TLSv1.1 are not disabled. At least that is what testssl.sh reports:

 SSLv2      not offered (OK)
 SSLv3      not offered (OK)
 TLS 1      offered (deprecated)
 TLS 1.1    offered (deprecated)
 TLS 1.2    offered (OK)
 TLS 1.3    offered (OK): final
 NPN/SPDY   not offered
 ALPN/HTTP2 not offered

So it seems it is still offered and not disabled completely.

the-hotmann commented 1 year ago

I tested it like this:

docker run --rm -it drwetter/testssl.sh:latest [###IP###]:465

the-hotmann commented 1 year ago

I think that at dovecot the config ssl_min_protocol was not doing the trick on it's own. This seems to be required aswell:

ssl_protocols = TLSv1.3 TLSv1.2 !TLSv1.1 !TLSv1 !SSLv3 !SSLv2
ssl_prefer_server_ciphers = yes
ssl_cipher_list = ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH

I tbh don't know if it is ssl_cipher_list or ssl_ciphers

  1. disable TLSv1.1, TLSv1, SSLv3, SSLv2 (!TLSv1.1 !TLSv1 !SSLv3 !SSLv2)
  2. enable TLSv1.3, TLSv1.2 (TLSv1.3 TLSv1.2)
  3. disable anonym & non-encrypting chiphers (!aNULL:!eNULL)
  4. maybe the ssl_cipher_list should be chosen even more strict!? Maybe ssl_cipher_list = HIGH:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH so that not everything needs to be disallowed explicitly.

I hope that can make it a little more secure :)

jeboehm commented 1 year ago

Thank you @MartinHotmann! This will be solved in #241