🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
10 messages
10 total messages Started by Michael Bäuerle Fri, 26 Apr 2019 15:42
INN 2.6.3 with Debian 10 "Buster"
#87944
Author: Michael Bäuerle
Date: Fri, 26 Apr 2019 15:42
60 lines
3725 bytes
There is another TLS related issue with INN 2.6.3 if the "security
level" feature of OpenSSL 1.1 is used: Negotiations for ciphersuites
using DHE key exchange fail if the security level is set to something
beyond 1. The upcoming Debian 10 seems to do this by default:
<https://wiki.debian.org/ContinuousIntegration/TriagingTips/openssl-1.1.1>

I have tested this with Emil Schuster. His server responded like this:
| 
| $ openssl s_client -connect wieslauf.sub.de:nntps -cipher "DHE-RSA-AES256-GCM-SHA384"
| [...]
| 4157901080:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:s3_pkt.c:1498:SSL alert number 40

Looking at the handshake with wireshark showed the server accepting the
ciphersuite (Code 0x00, 0x9F) as expected in its "Server Hello" Message.
But then there is no "Server Key exchange" Message and instead the fatal
error above.

We tracked down the problem to the function tmp_dh_cb() defined in
"inn-2.6.3/nnrpd/tlc.c". This function is installed as callback for
OpenSSL via SSL_CTX_set_tmp_dh_callback(CTX, tmp_dh_cb) to obtain the
FFDHE group for the key exchange. OpenSSL calls this function with
keylength==1024, but for the security level 2 this is too weak:
<https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_security_level.html>
(At least 2048 would be required)

Because INN doesn't allow to configure the FFDHE group manually, we have
patched the function tmp_dh_cb() to always return the 4096 Bit group
that is compiled into INN:
------------------------------------------------------------------------ 
static DH *
tmp_dh_cb(SSL *s UNUSED, int export UNUSED, int keylength UNUSED)
{
	static DH *dh4096 = NULL;

	if (dh4096 == NULL)
		dh4096 = load_dh_buffer(file_dh4096, sizeof file_dh4096);

	return dh4096;
}
------------------------------------------------------------------------
Such behaviour is allowed and recommended by OpenSSL in the man page:
<https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_tmp_dh_callback.html>
| 
| Previous versions of the callback used is_export and keylength
| parameters to control parameter generation for export and non-export
| cipher suites. Modern servers that do not support export cipher suites
| are advised to either use SSL_CTX_set_tmp_dh() or alternatively, use
| the callback but ignore keylength and is_export and simply supply at
| least 2048-bit parameters in the callback.

With the patch above things are now working again.
A comment of the current INN code says:
| 
| **  FIXME:  support user-specified files, to eliminate risk of
| **  "small group" attacks.

This would be another way to provide a FFDHE group that is strong enough
for a desired security level beyond 1.

Re: INN 2.6.3 with Debian 10 "Buster"
#87946
Author: Julien ÉLIE
Date: Sat, 27 Apr 2019 09:48
75 lines
4324 bytes
Hi Michael,

> There is another TLS related issue with INN 2.6.3 if the "security
> level" feature of OpenSSL 1.1 is used: Negotiations for ciphersuites
> using DHE key exchange fail if the security level is set to something
> beyond 1. The upcoming Debian 10 seems to do this by default:
> <https://wiki.debian.org/ContinuousIntegration/TriagingTips/openssl-1.1.1>

Thanks for the pointer!
Debian Buster enforces the security level to 2.

According to OpenSSL documentation
<https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_security_level.html>
"WARNING at this time setting the security level higher than 1 for 
general internet use is likely to cause considerable interoperability 
issues and is not recommended.  This is because the SHA1 algorithm is 
very widely used in certificates and will be rejected at levels higher 
than 1 because it only offers 80 bits of security."

So here we are.  There is an interoperability issue with INN.


Couldn't it be considered as a Release Candidate bug?
I've just sent a mail to Marco in case he is not aware of this current 
thread.


> We tracked down the problem to the function tmp_dh_cb() defined in
> "inn-2.6.3/nnrpd/tls.c". This function is installed as callback for
> OpenSSL via SSL_CTX_set_tmp_dh_callback(CTX, tmp_dh_cb) to obtain the
> FFDHE group for the key exchange. OpenSSL calls this function with
> keylength==1024, but for the security level 2 this is too weak:
> <https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_security_level.html>
> (At least 2048 would be required)
> 
> Because INN doesn't allow to configure the FFDHE group manually, we have
> patched the function tmp_dh_cb() to always return the 4096 Bit group
> that is compiled into INN

Thanks for having investigated and your proposal of patch.
I've just committed the following one:
   https://inn.eyrie.org/trac/changeset/10337


> Such behaviour is allowed and recommended by OpenSSL in the man page:
> <https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_tmp_dh_callback.html>
> |
> | Previous versions of the callback used is_export and keylength
> | parameters to control parameter generation for export and non-export
> | cipher suites. Modern servers that do not support export cipher suites
> | are advised to either use SSL_CTX_set_tmp_dh() or alternatively, use
> | the callback but ignore keylength and is_export and simply supply at
> | least 2048-bit parameters in the callback.

Nice to know that what INN does is recommended by OpenSSL.


> A comment of the current INN code says:
> |
> | **  FIXME:  support user-specified files, to eliminate risk of
> | **  "small group" attacks.
> 
> This would be another way to provide a FFDHE group that is strong enough
> for a desired security level beyond 1.

Yes, this feature would be worthwhile.

-- 
Julien ÉLIE

« Plus j'y pense, plus je me dis qu'il n'y a aucune raison pour que le
   carré de l'hypoténuse soit égal à la somme des carrés des deux
   autres côtés. » (San-Antonio)

Re: INN 2.6.3 with Debian 10 "Buster"
#87948
Author: Michael Bäuerle
Date: Sat, 27 Apr 2019 11:16
58 lines
3412 bytes
Julien ÉLIE wrote:
> Michael Bäuerle wrote:
> > 
> [Security Level 2]
> Couldn't it be considered as a Release Candidate bug?
> I've just sent a mail to Marco in case he is not aware of this current 
> thread.

Even if Level 2 will not be in the final Debian release, Level 1 looks
weak compared to what is in common use for TLS today:
- Authentication with Let's Encrypt certificates using 2048 Bit RSA-keys
  (=> Level 2)
- ECC-based key exchange with 256 Bit curves
  (=> Level 3)
- Symmetric encryption for the payload with AES128
  (=> Level 3)

FFDHE key exchange with 4096 Bit group (Threshold for Level 3: 3072 Bit)
should be a bit stronger than ECDHE with curve P-256.

> > We tracked down the problem to the function tmp_dh_cb() defined in
> > "inn-2.6.3/nnrpd/tls.c". This function is installed as callback for
> > OpenSSL via SSL_CTX_set_tmp_dh_callback(CTX, tmp_dh_cb) to obtain the
> > FFDHE group for the key exchange. OpenSSL calls this function with
> > keylength==1024, but for the security level 2 this is too weak:
> > <https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_security_level.html>
> > (At least 2048 would be required)
> > 
> > Because INN doesn't allow to configure the FFDHE group manually, we have
> > patched the function tmp_dh_cb() to always return the 4096 Bit group
> > that is compiled into INN
> 
> Thanks for having investigated and your proposal of patch.
> I've just committed the following one:
>   https://inn.eyrie.org/trac/changeset/10337

Thanks.

> > A comment of the current INN code says:
> > |
> > | **  FIXME:  support user-specified files, to eliminate risk of
> > | **  "small group" attacks.
> > 
> > This would be another way to provide a FFDHE group that is strong enough
> > for a desired security level beyond 1.
> 
> Yes, this feature would be worthwhile.

If Debian really increase the minimum TLS protocol version to 1.2, then
I would expect little collateral damage (clients that are too old to
support the 4096 Bit FFDHE-Group are expected to not support TLSv1.2 or
TLSv1.3 too).

Otherwise the group in user-specified file would be "nice to have",
to be able to configure an anachronistic weak setup only for old
newsreaders by intend.

Re: INN 2.6.3 with Debian 10 "Buster"
#87950
Author: Julien ÉLIE
Date: Sun, 28 Apr 2019 07:54
29 lines
2245 bytes
Hi Michael,

> If Debian really increase the minimum TLS protocol version to 1.2, then
> I would expect little collateral damage (clients that are too old to
> support the 4096 Bit FFDHE-Group are expected to not support TLSv1.2 or
> TLSv1.3 too).

Another possibility for INN would be to get the security level (for 
OpenSSL 1.1.0 and above) and select:
- 2048-bit for levels 0, 1 and 2,
- 4096-bit for level 3.
I bet two stronger 8192-bit and 16384-bit pre-computed DH parameters 
should be added for levels 4 and 5?

If an older version of OpenSSL is in use, select 2048-bit.

Does it sound good to you?

(Otherwise, everyone would only have 4096-bit DH parameters, be they on 
Debian or not.)

-- 
Julien ÉLIE

« Les longues fiançailles donnent une chance de mieux se connaître
   avant le mariage, ce qui n'est jamais une bonne idée. » (Oscar
   Wilde)

Re: INN 2.6.3 with Debian 10 "Buster"
#87949
Author: Michael Bäuerle
Date: Sun, 28 Apr 2019 09:55
31 lines
2285 bytes
Julien ÉLIE wrote:
> Michael Bäuerle wrote:
> > 
> > If Debian really increase the minimum TLS protocol version to 1.2, then
> > I would expect little collateral damage (clients that are too old to
> > support the 4096 Bit FFDHE-Group are expected to not support TLSv1.2 or
> > TLSv1.3 too).
> 
> Another possibility for INN would be to get the security level (for 
> OpenSSL 1.1.0 and above) and select:
> - 2048-bit for levels 0, 1 and 2,
> - 4096-bit for level 3.
> I bet two stronger 8192-bit and 16384-bit pre-computed DH parameters 
> should be added for levels 4 and 5?
> 
> If an older version of OpenSSL is in use, select 2048-bit.
> 
> Does it sound good to you?
> 
> (Otherwise, everyone would only have 4096-bit DH parameters, be they on 
> Debian or not.)

The "right" way to do this should be negotiation as defined in RFC 7919:
<https://tools.ietf.org/html/rfc7919>
But AFAIK this is not supported by OpenSSL yet.

If you prefer autoselection over user-provided group, then I think
the algorithm you proposed is good (maybe based on the groups from
RFC 7919, except for Level 5).

Re: INN 2.6.3 with Debian 10 "Buster"
#87951
Author: Julien ÉLIE
Date: Sun, 28 Apr 2019 12:34
40 lines
2869 bytes
Hi Michael,
>> Another possibility for INN would be to get the security level (for
>> OpenSSL 1.1.0 and above) and select:
>> - 2048-bit for levels 0, 1 and 2,
>> - 4096-bit for level 3.
>> I bet two stronger 8192-bit and 16384-bit pre-computed DH parameters
>> should be added for levels 4 and 5?
>>
>> If an older version of OpenSSL is in use, select 2048-bit.
>>
>> Does it sound good to you?
>>
>> (Otherwise, everyone would only have 4096-bit DH parameters, be they on
>> Debian or not.)
> 
> The "right" way to do this should be negotiation as defined in RFC 7919:
> <https://tools.ietf.org/html/rfc7919>
> But AFAIK this is not supported by OpenSSL yet.
> 
> If you prefer autoselection over user-provided group, then I think
> the algorithm you proposed is good (maybe based on the groups from
> RFC 7919, except for Level 5).

When you say user-provided group, is it a /etc/inn2/dhparam.pem (path 
configurable via inn.conf) file that would apply to all connections?
It would contain by default 2048-bit DH parameters.
If the file does not exist, INN would use its currently hard-coded 
4096-bit DH parameters.
Is that what you had in mind?

As for DH parameters to take, is RFC 7919 preferable over RFC 3526?

-- 
Julien ÉLIE

« Les longues fiançailles donnent une chance de mieux se connaître
   avant le mariage, ce qui n'est jamais une bonne idée. » (Oscar
   Wilde)

Re: INN 2.6.3 with Debian 10 "Buster"
#87952
Author: Michael Bäuerle
Date: Mon, 29 Apr 2019 10:00
68 lines
4057 bytes
Julien ÉLIE wrote:
> Michael Bäuerle:
> > Julien ÉLIE wrote:
> > > 
> > > Another possibility for INN would be to get the security level (for
> > > OpenSSL 1.1.0 and above) and select:
> > > - 2048-bit for levels 0, 1 and 2,
> > > - 4096-bit for level 3.
> > > I bet two stronger 8192-bit and 16384-bit pre-computed DH parameters
> > > should be added for levels 4 and 5?
> > > 
> > > If an older version of OpenSSL is in use, select 2048-bit.
> > > 
> > > Does it sound good to you?
> > > 
> > > (Otherwise, everyone would only have 4096-bit DH parameters, be they on
> > > Debian or not.)
> > 
> > The "right" way to do this should be negotiation as defined in RFC 7919:
> > <https://tools.ietf.org/html/rfc7919>
> > But AFAIK this is not supported by OpenSSL yet.
> > 
> > If you prefer autoselection over user-provided group, then I think
> > the algorithm you proposed is good (maybe based on the groups from
> > RFC 7919, except for Level 5).
> 
> When you say user-provided group, is it a /etc/inn2/dhparam.pem (path 
> configurable via inn.conf) file that would apply to all connections?

Yes. Other server software currently uses similar mechanisms (e.g.
postfix [1]).

> It would contain by default 2048-bit DH parameters.
> If the file does not exist, INN would use its currently hard-coded 
> 4096-bit DH parameters.
> Is that what you had in mind?

I think the default should be "no file" (compiled in groups, the
autoselect algorithm based on the security level would be nice to have).

And the file only for manual intervention (if the autoselected group is
not what is desired by the admin -- for whatever reason).

> As for DH parameters to take, is RFC 7919 preferable over RFC 3526?

Quoted from RFC 7919 [2]:
| 
| [...]
| These additions to the "Supported Groups Registry" are described in
| detail in Appendix A.  They are all safe primes derived from the base
| of the natural logarithm ("e"), with the high and low 64 bits set to
| 1 for efficient Montgomery or Barrett reduction.
| 
| The use of the base of the natural logarithm here is as a "nothing-
| up-my-sleeve" number.  The goal is to guarantee that the bits in the
| middle of the modulus are effectively random, while avoiding any
| suspicion that the primes have secretly been selected to be weak
| according to some secret criteria.  [RFC3526] used pi for this value.
| See Section 8.5 for reasons that this document does not reuse pi.

This means not reusing the groups from RFC 3526 for TLS is intended.


_____________
[1] <http://www.postfix.org/postconf.5.html#smtpd_tls_dh1024_param_file>
[2] <https://tools.ietf.org/html/rfc7919#section-2>

Re: INN 2.6.3 with Debian 10 "Buster"
#87969
Author: Julien ÉLIE
Date: Fri, 31 May 2019 22:55
65 lines
3539 bytes
Hi Michael,
>>> If you prefer autoselection over user-provided group, then I think
>>> the algorithm you proposed is good (maybe based on the groups from
>>> RFC 7919, except for Level 5).
> 
>> It would contain by default 2048-bit DH parameters.
>> If the file does not exist, INN would use its currently hard-coded
>> 4096-bit DH parameters.
>> Is that what you had in mind?
> 
> I think the default should be "no file" (compiled in groups, the
> autoselect algorithm based on the security level would be nice to have).

First step done!
Auto-selection with 2048-bit DH parameter for levels 0, 1 and 2; 
4096-bit for level 3; 8192-bit for level 4.
The pre-computed DH parameters are taken from RFC 7919.
Unfortunately, there is no suitable DH parameter for level 5 (but I 
doubt it will be set by a news admin).

I've just submitted the patch to Marco so that it could be integrated 
into Debian Buster:
   https://inn.eyrie.org/trac/changeset/10344


The new feature of user-provided group will come later.




FWIW, the DH modulus can be shown with the following command:

   openssl s_client -msg -cipher 'DHE-RSA-AES256-SHA256' -connect 
localhost:563

<<< TLS 1.2 Handshake [length 030f], ServerKeyExchange
     0c 00 03 0b 01 00 ff ff ff ff ff ff ff ff ad f8
                 ^^^^^
(with a 2048-bit DH key => modulus is an integer encoded over 0x0100 = 
256 bytes)


<<< TLS 1.2 Handshake [length 050f], ServerKeyExchange
     0c 00 05 0b 02 00 ff ff ff ff ff ff ff ff ad f8
                 ^^^^^
(with a 4096-bit DH key => modulus is an integer encoded over 0x0200 = 
512 bytes)


<<< TLS 1.2 Handshake [length 090f], ServerKeyExchange
     0c 00 09 0b 04 00 ff ff ff ff ff ff ff ff ad f8
                 ^^^^^
(with a 8192-bit DH key => modulus is an integer encoded over 0x0400 = 
1024 bytes)

It permits to check that the patch works fine with all the pre-computed 
DH parameters.

-- 
Julien ÉLIE

« Internet restera toujours un joujou pour les universitaires. »
   (1991)

Re: INN 2.6.3 with Debian 10 "Buster"
#87971
Author: Michael Bäuerle
Date: Sat, 01 Jun 2019 16:22
37 lines
2644 bytes
Julien ÉLIE wrote:
> Michael Bäuerle wrote:
> > Julien ÉLIE wrote:
> > > Michael Bäuerle wrote:
> > > > 
> > > > If you prefer autoselection over user-provided group, then I think
> > > > the algorithm you proposed is good (maybe based on the groups from
> > > > RFC 7919, except for Level 5).
> > > 
> > > It would contain by default 2048-bit DH parameters.
> > > If the file does not exist, INN would use its currently hard-coded
> > > 4096-bit DH parameters.
> > > Is that what you had in mind?
> > 
> > I think the default should be "no file" (compiled in groups, the
> > autoselect algorithm based on the security level would be nice to have).
> 
> First step done!
> Auto-selection with 2048-bit DH parameter for levels 0, 1 and 2; 
> 4096-bit for level 3; 8192-bit for level 4.
> The pre-computed DH parameters are taken from RFC 7919.

Thanks, this implementation looks much better than my proposed 4096-bit
only solution.

> Unfortunately, there is no suitable DH parameter for level 5 (but I 
> doubt it will be set by a news admin).

I agree.


Emil Schuster has compiled an nnrpd with the patch and flnews now gets
2048-bits as expected:
| 
| flnews: TLS: FFDHE group size: 2048 bit

Re: INN 2.6.3 with Debian 10 "Buster"
#87973
Author: Julien ÉLIE
Date: Sat, 01 Jun 2019 19:33
16 lines
2010 bytes
Hi Michael,
> Emil Schuster has compiled an nnrpd with the patch and flnews now gets
> 2048-bits as expected:
> |
> | flnews: TLS: FFDHE group size: 2048 bit

Thanks to both of you for the confirmation the patch works fine!

-- 
Julien ÉLIE

« – Du potage : c'est tout ce que le cuisinier a pu faire !
   – Ce blocus devient très horripilant !
   – Blocus, c'est ton cuisinier ? » (Astérix)

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads