Add per session pseudo-random component to --reneg-sec intervals
PATCH 1/1 Add per session pseudo-random component to --reneg-sec intervals
Hi,
Initially I've created this RFE but have been told to send it to the devel list instead:
https://community.openvpn.net/openvpn/ticket/865
Unfortunately I'm not a developer and have never used git so please bear with me as I send a classic patch to the list.
As suggested by user "syzzer" I also tried to improve the patch and here it is:
-------%<--------------------------------------------------------------- While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is still room for improvement in our use case.
It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things worse, we realized that most renegotiation procedures took place at almost the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.
I've created attached patch to add a per session pseudo-random component to the --reneg-sec intervals so that renegotiation is evenly spread over time. It is configured by simply adding a second value to --reneg-sec as described in the --help text:
--reneg-sec n [r] : Renegotiate data chan. key after n seconds default=3600)
and if r is specified, add a per session pseudo-random component in the range of 1 ... r to n (default=0).
Note that the patch also slightly changes the log output to show the sec value
in the same way as the bytes/pkts values:
TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0 -------%<---------------------------------------------------------------
The patch is tested and seems to work well in my environment. As always, comments are very welcome.
Would be nice to have this patch accepted and included in OpenVPN 2.4.2.
Regards,
Simon
doc/openvpn.8 +10 -2
@@ -34,7 +34,7 @@ .\" .ft -- normal face .\" .in +|-{n} -- indent .\" -.TH openvpn 8 "25 August 2016" +.TH openvpn 8 "28 March 2017" .\"********************************************************* .SH NAME openvpn \- secure IP tunnel daemon.
@@ -4919,11 +4919,19 @@ packets sent and received (disabled by default). .\"********************************************************* .TP -.B \-\-reneg\-sec n +.B \-\-reneg\-sec n [random] Renegotiate data channel key after .B n seconds (default=3600). +If the optional +.B random +parameter is specified, a per session pseudo-random component in the range of +.B 1 ... random +is added to the +.B n +seconds above (default=0). + When using dual-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.
src/openvpn/init.c +4 -0
@@ -2592,6 +2592,10 @@ to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; to.renegotiate_seconds = options->renegotiate_seconds; +if (options->renegotiate_seconds_random) + { + to.renegotiate_seconds +=max_int ((int )(get_random () % options->renegotiate_seconds_random) +1 ,1 ); + } to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;
src/openvpn/options.c +11 -2
@@ -603,7 +603,9 @@" if no ACK from remote within n seconds (default=%d).\n" "--reneg-bytes n : Renegotiate data chan. key after n bytes sent and recvd.\n" "--reneg-pkts n : Renegotiate data chan. key after n packets sent and recvd.\n" -"--reneg-sec n : Renegotiate data chan. key after n seconds (default=%d).\n" +"--reneg-sec n [r] : Renegotiate data chan. key after n seconds (default=%d)\n" +" and if r is specified, add a per session pseudo-random\n" +" component in the range of 1 ... r to n (default=%d).\n" "--hand-window n : Data channel key exchange must finalize within n seconds\n" " of handshake initiation by any peer (default=%d).\n" "--tran-window n : Transition window -- old key can live this many seconds\n"
@@ -1773,6 +1775,7 @@SHOW_INT (renegotiate_bytes);SHOW_INT (renegotiate_packets);SHOW_INT (renegotiate_seconds); +SHOW_INT (renegotiate_seconds_random);SHOW_INT (handshake_window);SHOW_INT (transition_window);
@@ -2741,6 +2744,7 @@MUST_BE_UNDEF (renegotiate_bytes);MUST_BE_UNDEF (renegotiate_packets);MUST_BE_UNDEF (renegotiate_seconds); +MUST_BE_UNDEF (renegotiate_seconds_random);MUST_BE_UNDEF (handshake_window);MUST_BE_UNDEF (transition_window);MUST_BE_UNDEF (tls_auth_file);
@@ -4091,6 +4095,7 @@ o.authname, o.ciphername, o.replay_window, o.replay_time, o.tls_timeout, o.renegotiate_seconds, + o.renegotiate_seconds_random, o.handshake_window, o.transition_window);#else /* ifdef ENABLE_CRYPTO */ fprintf(fp, usage_message,
@@ -7983,10 +7988,14 @@VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_packets =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[2 ]) +else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[3 ]) {VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_seconds =positive_atoi (p[1 ]); +if (p[2 ]) + { + options->renegotiate_seconds_random =positive_atoi (p[2 ]); + } }else if (streq (p[0 ],"hand-window" ) && p[1 ] && !p[2 ]) {
src/openvpn/options.h +1 -0
@@ -545,6 +545,7 @@int renegotiate_bytes;int renegotiate_packets;int renegotiate_seconds; +int renegotiate_seconds_random;/* Data channel key handshake must finalize * within n seconds of handshake initiation. */
src/openvpn/ssl.c +2 -2
@@ -2719,8 +2719,8 @@ || (packet_id_close_to_wrapping(&ks->crypto_options.packet_id.send)))) {msg (D_TLS_DEBUG_LOW , -"TLS: soft reset sec=%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , - (int )(ks->established + session->opt->renegotiate_seconds - now), +"TLS: soft reset sec=%d/%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , + (int )(now - ks->established), (int )session->opt->renegotiate_seconds, ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session);
Quoted 41 lines
Hi,
Initially I've created this RFE but have been told to send it to the devel list instead:
https://community.openvpn.net/openvpn/ticket/865
Unfortunately I'm not a developer and have never used git so please bear with me as I send a classic patch to the list.
As suggested by user "syzzer" I also tried to improve the patch and here it is:
-------%<--------------------------------------------------------------- While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is still room for improvement in our use case.It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things worse, we realized that most renegotiation procedures took place at almost the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.
I've created attached patch to add a per session pseudo-random component to
the --reneg-sec intervals so that renegotiation is evenly spread over time.
It is configured by simply adding a second value to --reneg-sec as described
in the --help text:--reneg-sec n [r] : Renegotiate data chan. key after n seconds default=3600)
and if r is specified, add a per session pseudo-random component in the range of 1 ... r to n (default=0).Note that the patch also slightly changes the log output to show the sec value
in the same way as the bytes/pkts values:
Quoted 8 lines
TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0 -------%<---------------------------------------------------------------
The patch is tested and seems to work well in my environment. As always, comments are very welcome.
Would be nice to have this patch accepted and included in OpenVPN 2.4.2.
Any comments on this patch? Would be nice to get some feedback :)
Simon
Hi,
Quoted 49 lines
Quoted 49 lines
Hi,
Initially I've created this RFE but have been told to send it to the devel list instead:
https://community.openvpn.net/openvpn/ticket/865
Unfortunately I'm not a developer and have never used git so please bear with me as I send a classic patch to the list.
As suggested by user "syzzer" I also tried to improve the patch and here it is:
-------%<--------------------------------------------------------------- While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is
still room for improvement in our use case.It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things
worse, we realized that most renegotiation procedures took place at almost
the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.I've created attached patch to add a per session pseudo-random component to
the --reneg-sec intervals so that renegotiation is evenly spread over time.
It is configured by simply adding a second value to --reneg-sec as described
in the --help text:--reneg-sec n [r] : Renegotiate data chan. key after n seconds default=3600)
and if r is specified, add a per session
pseudo-random
component in the range of 1 ... r to n (default=0).Note that the patch also slightly changes the log output to show the sec value
in the same way as the bytes/pkts values:TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0 -------%<---------------------------------------------------------------
Quoted 8 lines
Quoted 4 lines
The patch is tested and seems to work well in my environment. As always, comments are very welcome.
Would be nice to have this patch accepted and included in OpenVPN 2.4.2.
Any comments on this patch? Would be nice to get some feedback :)
Simon
Interesting to see that there is zero interest in this patch here.
I'm very sure a lot of people are suffering this issue without knowing it. On heavy loaded multi instance servers OpenVPN tends to lose packets every hour (with default reneg-sec settings).
That's only in a short period of time but still very annoying for things like VoIP over the VPN links.
We only found this out after the problem became worse with the bug mentioned above introduced in OpenVPN 2.4.0. The problem has always been there but we only became aware of it with the 2.4.0 release.
I guess I'll change the patch then to work without any changes to the config. That way our binary builds are still compatible with the upstream version but still improve the issue mentioned above.
For those interested to see how the problem shows up, try this:
Run "prettyping -i 0.1 <destination>" to different locations in different terminals and let it run for a longer time. You will easily see the hourly packet losses in the patterns. Prettyping is here
https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping
Regards,
Simon
Hi,
Quoted 1 line · Simon Matter
Interesting to see that there is zero interest in this patch here.
This is a misinterpretation.
If you monitor the list, it has been fairly quiet since 2.4.0 release - the active core of openvpn developers have all been busy with other things for one or the other reason, so progress on all fronts has been slow, and response times could be much better.
I think this is a useful addition, but didn't have time to really think through the code changes yet (= review), so I didn't say anything. I know Steffan is busy with OpenSSL 1.1 plus paid-for work, David is busy with other important business. So it might take a bit.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Quoted 7 lines
Hi,
Quoted 1 line · Simon Matter
Interesting to see that there is zero interest in this patch here.
This is a misinterpretation.
Hi Gert,
Thanks for the explanation, I'll be patient then :)
If it's preferred for the patch to keep it even simpler and compatible the current configs, it could be broken down to something like this in init.c:
#define RENEG_RND_PCT 25
to.renegotiate_seconds = max_int((int)options->renegotiate_seconds - (get_random() % (options->renegotiate_seconds / (100 / RENEG_RND_PCT))), 1);
With the default config this should result in reneg times in the range of 2700 ... 3600 seconds.
Thanks,
Simon
Quoted 11 lines · Simon Matter
Quoted 7 lines
Hi,
Quoted 1 line · Simon Matter
Interesting to see that there is zero interest in this patch here.
This is a misinterpretation.
Hi Gert,
Thanks for the explanation, I'll be patient then :)
As a non-dev I can not help with implementing this. But for the record: I think it would be an excellent edition to openvpn as currently per peer --reneg-* in --mode server is not possible.
Regards
Quoted 8 lines
Quoted 7 lines
Hi,
Quoted 1 line · Simon Matter
Interesting to see that there is zero interest in this patch here.
This is a misinterpretation.
Quoted 6 lines
Hi Gert,
Thanks for the explanation, I'll be patient then :)
If it's preferred for the patch to keep it even simpler and compatible the current configs, it could be broken down to something like this in
init.c:
I've attached v2 now which works without any config change:
--reneg-sec n
Renegotiate data channel key after n seconds (default=3600).
Note that the effective value used here is a per session pseudo- randomized 25% of n deducted from n. With the default value of 3600 this results in an effective per session value in the range of 2701 ... 3600 seconds.
I prefer this version as it allows everybody to profit from it without touching any config files.
Thanks,
Simon
doc/openvpn.8 +10 -1
@@ -34,7 +34,7 @@ .\" .ft -- normal face .\" .in +|-{n} -- indent .\" -.TH openvpn 8 "25 August 2016" +.TH openvpn 8 "04 April 2017" .\"********************************************************* .SH NAME openvpn \- secure IP tunnel daemon.
@@ -4924,6 +4924,15 @@ .B n seconds (default=3600). +Note that the effective value used here is a per session pseudo-randomized +.B 25% +of +.B n +deducted from +.B n\fR. +With the default value of 3600 this results in an effective per session +value in the range of 2701 ... 3600 seconds. + When using dual-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.
src/openvpn/init.c +2 -1
@@ -2591,7 +2591,8 @@ to.packet_timeout = options->tls_timeout; to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; - to.renegotiate_seconds = options->renegotiate_seconds; + to.renegotiate_seconds = options->renegotiate_seconds - + (get_random () %max_int (options->renegotiate_seconds / (100 /25 ),1 )); to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;
src/openvpn/options.c +4 -0
@@ -604,6 +604,10 @@"--reneg-bytes n : Renegotiate data chan. key after n bytes sent and recvd.\n" "--reneg-pkts n : Renegotiate data chan. key after n packets sent and recvd.\n" "--reneg-sec n : Renegotiate data chan. key after n seconds (default=%d).\n" +" The effective value used here is a per session\n" +" pseudo-randomized 25%% of n deducted from n. With the\n" +" default value of 3600 this results in an effective per\n" +" session value in the range of 2701 ... 3600 seconds.\n" "--hand-window n : Data channel key exchange must finalize within n seconds\n" " of handshake initiation by any peer (default=%d).\n" "--tran-window n : Transition window -- old key can live this many seconds\n"
src/openvpn/ssl.c +2 -2
@@ -2719,8 +2719,8 @@ || (packet_id_close_to_wrapping(&ks->crypto_options.packet_id.send)))) {msg (D_TLS_DEBUG_LOW , -"TLS: soft reset sec=%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , - (int )(ks->established + session->opt->renegotiate_seconds - now), +"TLS: soft reset sec=%d/%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , + (int )(now - ks->established), (int )session->opt->renegotiate_seconds, ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session);
Hi,
Quoted 1 line · Simon Matter
I've attached v2 now which works without any config change:
[..]
Quoted 2 lines
I prefer this version as it allows everybody to profit from it without touching any config files.
I can see the reasoning, but 25% feels a bit on the high side :-) - so let the ratholing begin what the number should be.
Steffan, any views from the crypto side of things?
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi,
Quoted 10 lines · Gert Doering
Quoted 1 line · Simon Matter
I've attached v2 now which works without any config change:
[..]
Quoted 2 lines
I prefer this version as it allows everybody to profit from it without touching any config files.
I can see the reasoning, but 25% feels a bit on the high side :-) - so let the ratholing begin what the number should be.
Steffan, any views from the crypto side of things?
Not really. I think the feature makes sense, and I like that this will only *substract* from the set time (so not exceed any set limits).
(And I agree that 25% feels on the high side - my gut says somewhere around 10%, but I have no analysis to show why that would be better. I'll leave picking that number to you.)
-Steffan
Quoted 12 lines · Steffan Karger
Hi,
Quoted 9 lines · Gert Doering
Quoted 1 line · Simon Matter
I've attached v2 now which works without any config change:
[..]
Quoted 2 lines
I prefer this version as it allows everybody to profit from it without touching any config files.
I can see the reasoning, but 25% feels a bit on the high side :-) - so let the ratholing begin what the number should be.
Quoted 8 lines
Quoted 1 line
Steffan, any views from the crypto side of things?
Not really. I think the feature makes sense, and I like that this will only *substract* from the set time (so not exceed any set limits).
(And I agree that 25% feels on the high side - my gut says somewhere around 10%, but I have no analysis to show why that would be better. I'll leave picking that number to you.)
The default is 60 minutes. With 25% that means a time window of 15 minutes, so reneg-sec will occur between 45-60 minutes.
I see this can be too much for some sites, and perhaps too little on
sites which have many users. With 10%, the reneg-window is reduced to
54-60 minutes. For larger sites, this is most likely too small of a window - though far better than everyone at "exactly" 60 minutes.
But I am also wondering if this randomness should only occur on the first renegotiation.
If you have a 6 minutes time window and 100 connected clients, there is a big chance that at some point the randomness will cause a similar congestion again, as multiple clients to have the same delay. With 25% that chance is lower, but the chance increases again with more clients.
So what if this randomness instead only occurs on the _first_ negotiation and then respect the --regneg-sec setting? Then clients will somewhat spread out and then keep a certain predictable renegotiation load. And if using 17%, you get a time window of roughly 10-11 minutes where renegotiation happens. With 100 clients, that means roughly (with a theoretical, ideal and even spread) 10 clients per minute. Which is more reasonable. With 200 clients, it is still getting crowded but not too bad.
But all that said ... I think it would be wise to have an optional argument to --reneg-sec (in addition to the 'sec' argument we have today) which can be used to further open or close this time window. Larger sites will most likely want a larger time window than smaller ones.
Btw ... is --reneg-sec pushable? (Too lazy to check the code, man page says "no"). If not, it would probably be a good idea to enable that.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 47 lines · Steffan Karger
Quoted 12 lines
Hi,
Quoted 9 lines · Gert Doering
Quoted 1 line · Simon Matter
I've attached v2 now which works without any config change:
[..]
Quoted 2 lines
I prefer this version as it allows everybody to profit from it without touching any config files.
I can see the reasoning, but 25% feels a bit on the high side :-) - so let the ratholing begin what the number should be.
Quoted 8 lines
Quoted 1 line
Steffan, any views from the crypto side of things?
Not really. I think the feature makes sense, and I like that this will only *substract* from the set time (so not exceed any set limits).
(And I agree that 25% feels on the high side - my gut says somewhere around 10%, but I have no analysis to show why that would be better. I'll leave picking that number to you.)
The default is 60 minutes. With 25% that means a time window of 15 minutes, so reneg-sec will occur between 45-60 minutes.
I see this can be too much for some sites, and perhaps too little on
sites which have many users. With 10%, the reneg-window is reduced to
54-60 minutes. For larger sites, this is most likely too small of a window - though far better than everyone at "exactly" 60 minutes.But I am also wondering if this randomness should only occur on the first renegotiation.
If you have a 6 minutes time window and 100 connected clients, there is a big chance that at some point the randomness will cause a similar congestion again, as multiple clients to have the same delay. With 25% that chance is lower, but the chance increases again with more clients.
So what if this randomness instead only occurs on the _first_ negotiation and then respect the --regneg-sec setting? Then clients will somewhat spread out and then keep a certain predictable renegotiation load. And if using 17%, you get a time window of roughly 10-11 minutes where renegotiation happens. With 100 clients, that means roughly (with a theoretical, ideal and even spread) 10 clients per minute. Which is more reasonable. With 200 clients, it is still getting crowded but not too bad.
Quoted 7 lines
But all that said ... I think it would be wise to have an optional argument to --reneg-sec (in addition to the 'sec' argument we have today) which can be used to further open or close this time window. Larger sites will most likely want a larger time window than smaller ones.
Btw ... is --reneg-sec pushable? (Too lazy to check the code, man page says "no"). If not, it would probably be a good idea to enable that.
As I understand it client and server have 60 min. by default. Whatever is configured, the smaller value wins. That means, bad clients can set their reneg-sec to very low values and trash the server on the other end. From the server side this looks more or less like a DDOS.
In our environment we have set reneg-sec=0 on all clients because we want the server to have control over it. That's fine because we have only trusted clients. Making it pushable could be a solution to overwrite bad settings in clients. A more radical solution was to just remove the option on the client side.
Regards,
Simon
Quoted 52 lines · Simon Matter
Quoted 52 lines · Steffan Karger
Quoted 12 lines
Hi,
Quoted 9 lines · Gert Doering
Quoted 1 line · Simon Matter
I've attached v2 now which works without any config change:
[..]
Quoted 2 lines
I prefer this version as it allows everybody to profit from it without touching any config files.
I can see the reasoning, but 25% feels a bit on the high side :-) - so let the ratholing begin what the number should be.
Quoted 8 lines
Quoted 1 line
Steffan, any views from the crypto side of things?
Not really. I think the feature makes sense, and I like that this will only *substract* from the set time (so not exceed any set limits).
(And I agree that 25% feels on the high side - my gut says somewhere around 10%, but I have no analysis to show why that would be better. I'll leave picking that number to you.)
The default is 60 minutes. With 25% that means a time window of 15 minutes, so reneg-sec will occur between 45-60 minutes.
I see this can be too much for some sites, and perhaps too little on
sites which have many users. With 10%, the reneg-window is reduced to
54-60 minutes. For larger sites, this is most likely too small of a window - though far better than everyone at "exactly" 60 minutes.But I am also wondering if this randomness should only occur on the first renegotiation.
If you have a 6 minutes time window and 100 connected clients, there is a big chance that at some point the randomness will cause a similar congestion again, as multiple clients to have the same delay. With 25% that chance is lower, but the chance increases again with more clients.
So what if this randomness instead only occurs on the _first_ negotiation and then respect the --regneg-sec setting? Then clients will somewhat spread out and then keep a certain predictable renegotiation load. And if using 17%, you get a time window of roughly 10-11 minutes where renegotiation happens. With 100 clients, that means roughly (with a theoretical, ideal and even spread) 10 clients per minute. Which is more reasonable. With 200 clients, it is still getting crowded but not too bad.
But all that said ... I think it would be wise to have an optional argument to --reneg-sec (in addition to the 'sec' argument we have today) which can be used to further open or close this time window. Larger sites will most likely want a larger time window than smaller ones.
Quoted 7 lines
Quoted 2 lines
Btw ... is --reneg-sec pushable? (Too lazy to check the code, man page says "no"). If not, it would probably be a good idea to enable that.
As I understand it client and server have 60 min. by default. Whatever is configured, the smaller value wins. That means, bad clients can set their reneg-sec to very low values and trash the server on the other end. From the server side this looks more or less like a DDOS.
That's possible today as well .... so I don't fully follow why this is interesting in regards to the randomness or push-ability of --reneg-sec.
This can be pulled much further. If you have an OpenVPN server on TCP, even that is susceptible to D/DoS attacks too, where even --tls-{auth,crypt} won't protect you. For UDP, --tls-{auth,crypt} does provide a nice barrier - unless the attacker(s) have access to that. There's not even a need to complete the full TLS negotiation.
The point is, if I ever wanted to D/DoS an OpenVPN server, I'd partially implement the OpenVPN protocol in an attack tool to start and perhaps complete the TLS handshake just to start over again. This would be far more efficient than to use OpenVPN itself. This can be multi-thread, kicking off thousands of connections in parallel, and then deploy that on a variety of VMs around the world. Have 64 such VMs initiating 1024 TCP connections each to any TCP based server in a loop - and the port pool on the server is exhausted.
So I doubt any reasonable client would really knowingly set
--reneg-sec 1 just for the bloody fun of it. The tunnel would be close
to useless. Unless you're a clueless, bored script kiddie with no imagination (yes, I know, there's plenty of them too).
As a mitigation to such attacks, it is possible to deploy some firewall rules (see the iptables recent module for example) to restrict how often IP address may initiate connections to the server.
Bottom line is ... I don't see D/DoS being a real issue, especially not in regards to --reneg-sec.
Quoted 4 lines
In our environment we have set reneg-sec=0 on all clients because we want the server to have control over it. That's fine because we have only trusted clients. Making it pushable could be a solution to overwrite bad settings in clients.
Yes, I think this makes sense. If the client don't want it - it is possible to deploy a --pull-filter in the local client configuration.
Quoted 1 line
A more radical solution was to just remove the option on the client side.
Probably not going to happen. This implies that the client trust the server. While that is reasonable in some configurations (corporate or private servers, fpr exampe), using a commercial VPN provider to avoid Geo-blocking (or whatever reason they have) - this assumption might not be equally true.
Plus it would break lots of already existing configurations. We could discuss making it a NOP on the client side. But that can be more painful to tackle; the exact same option parser in OpenVPN is used for all command line arguments, configuration files, CCD files and pushed options - and I might have forgotten a few more handfuls of users.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 17 lines · Simon Matter
Quoted 8 lines
Quoted 7 lines
Hi,
Quoted 1 line · Simon Matter
Interesting to see that there is zero interest in this patch here.
This is a misinterpretation.
Quoted 6 lines
Hi Gert,
Thanks for the explanation, I'll be patient then :)
If it's preferred for the patch to keep it even simpler and compatible the current configs, it could be broken down to something like this in
init.c:I've attached v2 now which works without any config change:
Quoted 8 lines
--reneg-sec n
Renegotiate data channel key after n seconds (default=3600).Note that the effective value used here is a per session pseudo- randomized 25% of n deducted from n. With the default value of 3600 this results in an effective per session value in the range of 2701 ... 3600 seconds.
A different approach could be like so:
--reneg-sec 3600
--reneg-sec-1sttime-rand 1|0 (The name here for detail)
where --reneg-sec is essentially left alone
but --reneg-sec-1sttime-rand does the very first renegotiation at some random time upto the --reneg-sec parameter. After that --reneg-sec is only in play.
It could even be done as --rand-reneg 1|0 and that could be set
to randomize *all* --reneg-* parameters upto the limit of the --reneg-*
in question and then hand control back to the --reneg-* in use after --rand-reneg has executed one time. (Although, I expect only --reneg-sec has such a specific issue)
my2c
Quoted 30 lines · On 05/04/17 16:42, debbie10t wrote:
Quoted 17 lines · Simon Matter
Quoted 8 lines
Quoted 7 lines
Hi,
Quoted 1 line · Simon Matter
Interesting to see that there is zero interest in this patch here.
This is a misinterpretation.
Quoted 6 lines
Hi Gert,
Thanks for the explanation, I'll be patient then :)
If it's preferred for the patch to keep it even simpler and compatible the current configs, it could be broken down to something like this in
init.c:I've attached v2 now which works without any config change:
Quoted 8 lines
--reneg-sec n
Renegotiate data channel key after n seconds (default=3600).Note that the effective value used here is a per session pseudo- randomized 25% of n deducted from n. With the default value of 3600 this results in an effective per session value in the range of 2701 ... 3600 seconds.
Quoted 4 lines
A different approach could be like so:
--reneg-sec 3600
--reneg-sec-1sttime-rand 1|0 (The name here for detail)
Too complicated ;-)
--reneg-sec # 60 minutes, with X % in randomness
--reneg-sec 1800 # 30 minutes, with X % in randomness (X is what we figure is reasonable by default; between 10-25%)
--reneg-sec 3600 30 # 60 minutes, 30% randomness
--reneg-sec 1800 0 # 30 minutes, no randomness
This won't break any configurations and gives full flexibility without adding new options (which we really try to avoid).
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 42 lines · David Sommerseth
Quoted 30 lines · On 05/04/17 16:42, debbie10t wrote:
Quoted 17 lines · Simon Matter
Quoted 8 lines
Quoted 7 lines
Hi,
Quoted 1 line · Simon Matter
Interesting to see that there is zero interest in this patch here.
This is a misinterpretation.
Quoted 6 lines
Hi Gert,
Thanks for the explanation, I'll be patient then :)
If it's preferred for the patch to keep it even simpler and compatible the current configs, it could be broken down to something like this in
init.c:I've attached v2 now which works without any config change:
Quoted 8 lines
--reneg-sec n
Renegotiate data channel key after n seconds (default=3600).Note that the effective value used here is a per session pseudo- randomized 25% of n deducted from n. With the default value of 3600 this results in an effective per session value in the range of 2701 ... 3600 seconds.
Quoted 4 lines
A different approach could be like so:
--reneg-sec 3600
--reneg-sec-1sttime-rand 1|0 (The name here for detail)Too complicated ;-)
--reneg-sec # 60 minutes, with X % in randomness
--reneg-sec 1800 # 30 minutes, with X % in randomness (X is what we figure is reasonable by default; between 10-25%)
Quoted 5 lines
--reneg-sec 3600 30 # 60 minutes, 30% randomness
--reneg-sec 1800 0 # 30 minutes, no randomnessThis won't break any configurations and gives full flexibility without adding new options (which we really try to avoid).
Oh, and in regards to the first-time/non-first-time .... if we decide for such flexibility, that can be a flag after the randomness.
For example --reneg-sec 3600 12 first-only
I am far from convinced if that should be configurable or not. But still, this approach is still far better than introducing new options.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 12 lines · David Sommerseth
Quoted 9 lines · David Sommerseth
Quoted 7 lines · On 05/04/17 16:42, debbie10t wrote:
A different approach could be like so:
--reneg-sec 3600
--reneg-sec-1sttime-rand 1|0 (The name here for detail)
Quoted 8 lines
Oh, and in regards to the first-time/non-first-time .... if we decide for such flexibility, that can be a flag after the randomness.
For example --reneg-sec 3600 12 first-only
I am far from convinced if that should be configurable or not. But still, this approach is still far better than introducing new options.
Ok - accept that new options is not preferred but ..
I like the idea of "first-only" addition (which is more or less as I proposed anyway) - And so, instead of having randomness in the reneg-sec itself, it is only randomness in the first run, after that the expected
behaviour would be restored. eg: --reneg-sec 3600
To my mind (as a non programmer) this essentially boils down to setting the first --reneg-sec timer to something between 1 and 3600 (default). This affords a much larger window for the scattering of clients and further behaviour is "as expected now".
and it looks very non-instrusive to me ..
Regards
would probably be a good idea to enable that.
Quoted 10 lines
As I understand it client and server have 60 min. by default. Whatever is configured, the smaller value wins. That means, bad clients can set their reneg-sec to very low values and trash the server on the other end. From the server side this looks more or less like a DDOS.
In our environment we have set reneg-sec=0 on all clients because we want the server to have control over it. That's fine because we have only trusted clients. Making it pushable could be a solution to overwrite bad settings in clients. A more radical solution was to just remove the option on the client side.
At its heart OpenVPN is still p2p instead of client of server, (Actually client is p2p mode). So removing a client setting removes it also for p2p.
I would also say have a 5% random component by default (makes 3 minutes for the 1h default) but let the user specify it as explicit range when then second (optional) parameter is present.
Either
reneg-sec 3600 3500 for 3500s-3600s (absolute)
or
reneg-sec 3600 100 for 3500s-3600s (relative)
I think percent based for user inputs are always creating confusion.
Arne
Quoted 31 lines · On 05/04/17 17:13, debbie10t wrote:
Quoted 12 lines · David Sommerseth
Quoted 9 lines · David Sommerseth
Quoted 7 lines · On 05/04/17 16:42, debbie10t wrote:
A different approach could be like so:
--reneg-sec 3600
--reneg-sec-1sttime-rand 1|0 (The name here for detail)Quoted 8 lines
Oh, and in regards to the first-time/non-first-time .... if we decide for such flexibility, that can be a flag after the randomness.
For example --reneg-sec 3600 12 first-only
I am far from convinced if that should be configurable or not. But still, this approach is still far better than introducing new options.
Ok - accept that new options is not preferred but ..
I like the idea of "first-only" addition (which is more or less as I proposed anyway) - And so, instead of having randomness in the reneg-sec itself, it is only randomness in the first run, after that the expected behaviour would be restored. eg: --reneg-sec 3600
Quoted 7 lines
To my mind (as a non programmer) this essentially boils down to setting the first --reneg-sec timer to something between 1 and 3600 (default). This affords a much larger window for the scattering of clients and further behaviour is "as expected now".
and it looks very non-instrusive to me ..
To clarify: --reneg-sec 3600 RAND
Where RAND indicates that the first-run timer should run from a random integer from 1 upto the value of --reneg-sec. RAND does not require a user to specify an amount.
Regards
Quoted 39 lines · On 05/04/17 17:13, debbie10t wrote:
Quoted 36 lines · David Sommerseth
Quoted 12 lines · David Sommerseth
Quoted 9 lines · On 05/04/17 16:42, debbie10t wrote:
Quoted 7 lines
A different approach could be like so:
--reneg-sec 3600
--reneg-sec-1sttime-rand 1|0 (The name here for detail)Quoted 8 lines
Oh, and in regards to the first-time/non-first-time .... if we decide for such flexibility, that can be a flag after the randomness.
For example --reneg-sec 3600 12 first-only
I am far from convinced if that should be configurable or not. But still, this approach is still far better than introducing new options.
Ok - accept that new options is not preferred but ..
I like the idea of "first-only" addition (which is more or less as I proposed anyway) - And so, instead of having randomness in the reneg-sec itself, it is only randomness in the first run, after that the expected behaviour would be restored. eg: --reneg-sec 3600
To my mind (as a non programmer) this essentially boils down to setting the first --reneg-sec timer to something between 1 and 3600 (default). This affords a much larger window for the scattering of clients and further behaviour is "as expected now".
Quoted 8 lines
Quoted 2 lines
and it looks very non-instrusive to me ..
To clarify: --reneg-sec 3600 RAND
Where RAND indicates that the first-run timer should run from a random integer from 1 upto the value of --reneg-sec. RAND does not require a user to specify an amount.
But then, why not just do it always and forget about the additional option?
Simon
Quoted 8 lines
Quoted 5 lines
Where RAND indicates that the first-run timer should run from a random integer from 1 upto the value of --reneg-sec. RAND does not require a user to specify an amount.
But then, why not just do it always and forget about the additional option?
Optional option does not mean that it is disabled by default. If you don't the randomness you would need to do:
reneg-sec 3600 3600
the optional argument also allows it to fine tune it to your needs.
Arne
Quoted 7 lines · Arne Schwabe
Quoted 7 lines
Quoted 5 lines
Where RAND indicates that the first-run timer should run from a random integer from 1 upto the value of --reneg-sec. RAND does not require a user to specify an amount.
But then, why not just do it always and forget about the additional option?
I actually agree, why not simply enable RAND as above *always*
Quoted 8 lines
Quoted 1 line
Optional option does not mean that it is disabled by default. If you don't the randomness you would need to do:
reneg-sec 3600 3600
the optional argument also allows it to fine tune it to your needs.
As the reason for --reneg-sec is to specify how long a key should exist,
I don't see any further need to make the "random window" be specifically
configurable .. The reneg-sec period will remain as specified (def 3600)
except for the first run, where --reneg-sec is started from a random time between now and then. There after returning to "normal" with full randomisation of all connected clients --reneg-sec being spread over the *entire* period of --reneg-sec nn and not some unnecessary window.
Regards
Hi,
Quoted 7 lines · On Wed, Apr 05, 2017 at 07:00:54PM +0100, debbie10t wrote:
Quoted 6 lines
Optional option does not mean that it is disabled by default. If you don't the randomness you would need to do:
reneg-sec 3600 3600
the optional argument also allows it to fine tune it to your needs.
Quoted 7 lines
As the reason for --reneg-sec is to specify how long a key should exist, I don't see any further need to make the "random window" be specifically configurable .. The reneg-sec period will remain as specified (def 3600) except for the first run, where --reneg-sec is started from a random time between now and then. There after returning to "normal" with full randomisation of all connected clients --reneg-sec being spread over the *entire* period of --reneg-sec nn and not some unnecessary window.
Setups with 2FA will have to re-enter auth credentials on reneg. Having OpenVPN all of a sudden default to "it could be asking 5 minutes after connection for the credentials again" is massive annoyance - and brings no real benefit anyway.
It makes sense to jitter reneg-sec somewhat (like, 10%-ish), but changing behaviour too much is not bringing much benefit - you don't need to spread the reneg over the whole period anyway, as different clients connect and disconnect at different times anyway. Just if all of them connect at the same time, the identically-timed renegs are a problem.
I like Arne's and David's suggestion - the existing option "as is" will enable X% jitter, while a second parameter can specify a more specific range. Following Arne's argument about users and percent math, it might indeed be better to have "min max" here ("3500 3600"), because that is really easy to understand and explain.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Quoted 30 lines · Gert Doering
Hi,
Quoted 7 lines · On Wed, Apr 05, 2017 at 07:00:54PM +0100, debbie10t wrote:
Quoted 6 lines
Optional option does not mean that it is disabled by default. If you don't the randomness you would need to do:
reneg-sec 3600 3600
the optional argument also allows it to fine tune it to your needs.
Quoted 7 lines
As the reason for --reneg-sec is to specify how long a key should exist, I don't see any further need to make the "random window" be specifically configurable .. The reneg-sec period will remain as specified (def 3600) except for the first run, where --reneg-sec is started from a random time between now and then. There after returning to "normal" with full randomisation of all connected clients --reneg-sec being spread over the *entire* period of --reneg-sec nn and not some unnecessary window.
Setups with 2FA will have to re-enter auth credentials on reneg. Having OpenVPN all of a sudden default to "it could be asking 5 minutes after connection for the credentials again" is massive annoyance - and brings no real benefit anyway.
It makes sense to jitter reneg-sec somewhat (like, 10%-ish), but changing behaviour too much is not bringing much benefit - you don't need to spread the reneg over the whole period anyway, as different clients connect and disconnect at different times anyway. Just if all of them connect at the same time, the identically-timed renegs are a problem.
Quoted 5 lines
I like Arne's and David's suggestion - the existing option "as is" will enable X% jitter, while a second parameter can specify a more specific range. Following Arne's argument about users and percent math, it might indeed be better to have "min max" here ("3500 3600"), because that is really easy to understand and explain.
I don't believe there is any need to specify "max" because that would be --reneg-sec as is. Otherwise specify a smaller or larger --reneg-sec
I accept that "min" or "window" is viable (provided it is first-run)
But, overall, I think having to login twice in succession at a surprisingly short random time *just the once* and then followed by regular intervals is not such a huge concern, if it is suitably documented. So I vote for my version.
Of course, it is up to you guys and I will leave it at that.
Thanks
Quoted 3 lines · Gert Doering
Following Arne's argument about users and percent math, it might indeed be better to have "min max" here ("3500 3600"), because that is really easy to understand and explain.
I agree to Arne's approach, using only min/max values instead of a percentage value as well.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 2 lines · On 05/04/17 23:13, debbie10t wrote:
I don't believe there is any need to specify "max" because that would be --reneg-sec as is. Otherwise specify a smaller or larger --reneg-sec
I think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness
--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllable
So using --reneg-sec 3600 3600, effectively removes the randomness.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
hello!
just curious how renegotiation is handled in "https" ? is it "an abbrevated ssl handshake" (RFC 2246) or ... ?
2017-04-06 2:39 GMT+05:00 David Sommerseth <
[email protected]...>:
Quoted 36 lines · On 05/04/17 23:13, debbie10t wrote:
Quoted 2 lines
I don't believe there is any need to specify "max" because that would be --reneg-sec as is. Otherwise specify a smaller or larger --reneg-sec
I think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllableSo using --reneg-sec 3600 3600, effectively removes the randomness.
--
kind regards,David Sommerseth
OpenVPN Technologies, Inc------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Hi,
Quoted 11 lines · David Sommerseth
Quoted 2 lines · On 05/04/17 23:13, debbie10t wrote:
I don't believe there is any need to specify "max" because that would be --reneg-sec as is. Otherwise specify a smaller or larger --reneg-sec
I think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness
Quoted 5 lines
--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllableSo using --reneg-sec 3600 3600, effectively removes the randomness.
I understand the proposed methods ..
Of the two above, I would be inclined toward option 2.
eg: (for me) --reneg-sec 0 3600 is ideal.
Thanks :)
Quoted 18 lines · On 05/04/17 22:57, debbie10t wrote:
Hi,
Quoted 15 lines · David Sommerseth
Quoted 2 lines · On 05/04/17 23:13, debbie10t wrote:
I don't believe there is any need to specify "max" because that would be --reneg-sec as is. Otherwise specify a smaller or larger --reneg-sec
I think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllable
Quoted 8 lines
Quoted 1 line
So using --reneg-sec 3600 3600, effectively removes the randomness.
I understand the proposed methods ..
Of the two above, I would be inclined toward option 2.
eg: (for me) --reneg-sec 0 3600 is ideal.Thanks :)
With the proviso of "First-run only" ..
Quoted 24 lines · On 05/04/17 23:01, debbie10t wrote:
Quoted 21 lines · On 05/04/17 22:57, debbie10t wrote:
Hi,
Quoted 17 lines · David Sommerseth
Quoted 3 lines · On 05/04/17 23:13, debbie10t wrote:
I don't believe there is any need to specify "max" because that would be
--reneg-sec as is. Otherwise specify a smaller or larger --reneg-secI think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllableSo using --reneg-sec 3600 3600, effectively removes the randomness.
Quoted 8 lines
Quoted 6 lines
I understand the proposed methods ..
Of the two above, I would be inclined toward option 2.
eg: (for me) --reneg-sec 0 3600 is ideal.Thanks :)
With the proviso of "First-run only" ..
sorry to not shut up ! :)
(due to logic errors)
--reneg-sec reneg-sec "first-run random offset"
eg:
--reneg-sec 3600 0 is equal to --reneg-sec 3600
--reneg-sec 3600 3600 is equal to --reneg-sec 3600 *
* with a first time run of any random number between 0 and 3600. (regardless of sign)
(the opposite of the actual proposal)
--reneg-sec 3600 360 would be equal to the 10% jitter proposal.
Sound ok ?
Regards
Quoted 4 lines · Илья Шипицин
hello!
just curious how renegotiation is handled in "https" ? is it "an abbrevated ssl handshake" (RFC 2246) or ... ?
The HTTPS and OpenVPN protocol is not comparable in this regard at all. AFAIR, OpenVPN does not make use of the TLS renegotiation possibility at all. So a renegotiation in OpenVPN actually results in a completely new and fresh TLS session, not related to previous TLS sessions at all.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 27 lines
2017-04-06 2:39 GMT+05:00 David Sommerseth
<[email protected]...
<mailto:[email protected]...>>:On 05/04/17 23:13, debbie10t wrote:
> I don't believe there is any need to specify "max" because that would be > --reneg-sec as is. Otherwise specify a smaller or larger --reneg-secI think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllableSo using --reneg-sec 3600 3600, effectively removes the randomness.
--
kind regards,David Sommerseth
OpenVPN Technologies, Inc
One final clarification:
As a user, I would prefer to see an early 2fa re-connect than one in the final few minutes, especially if I am already accustomed to a one hour cut off. Such that, I do 45 mins of work and get cut off is more annoying then doing 15 mins and get cut off.
Regards
Quoted 18 lines · On 05/04/17 23:57, debbie10t wrote:
Hi,
Quoted 15 lines · David Sommerseth
Quoted 2 lines · On 05/04/17 23:13, debbie10t wrote:
I don't believe there is any need to specify "max" because that would be --reneg-sec as is. Otherwise specify a smaller or larger --reneg-sec
I think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllable
Quoted 6 lines
Quoted 1 line
So using --reneg-sec 3600 3600, effectively removes the randomness.
I understand the proposed methods ..
Of the two above, I would be inclined toward option 2.
eg: (for me) --reneg-sec 0 3600 is ideal.
We are not going to change the behaviour much of what is already available today. So if we end up at 10% ... the new default will be:
--reneg-sec 3240 3600
If you you do --reneg-sec 1800, that will effectively become:
--reneg-sec 1620 1800
If you want to have a larger time window, then you do what you say above. Your "0 3600" will not become any default value. But you may choose to use those values if you want to.
The key point is that
--reneg-sec 1800
will work; thus not breaking any configurations - this we will not deviate away from. This syntax just calculates the "min" value automatically for you. If you provide both "min" and "max" values, that's what ends up being used.
Currently, I don't see the need to make it more complicated than this. And I don't think Gert nor Arne does either.
What will need to be discussed though is if this randomness should only happen on the first or on all renegotiations; and if that should be configurable or not. And we need a discussion around if we will allow this to be pushable or not.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 7 lines · On 06/04/17 00:30, debbie10t wrote:
One final clarification:
As a user, I would prefer to see an early 2fa re-connect than one in the final few minutes, especially if I am already accustomed to a one hour cut off. Such that, I do 45 mins of work and get cut off is more annoying then doing 15 mins and get cut off.
This doesn't make much sense to me, to be honest.
At least all those 2FA approaches I've used (both hardware and software tokens) usually have a life time of 30 seconds for each token. So unless the user types username and the new OTP code and password within a reasonable time, the connection should be closed regardless. Whenever this renegotiation happens, it doesn't matter if 2FA is used or not - as the 2FA code is most likely outdated already.
That said, doing a re-connect enforcing users to type in another 2FA is also less than ideal - which can in a short term scope be avoided by adding --auth-gen-token to the server config. Which should preserve a reasonably well security level on the session anyway.
And in regards to the --reneg-sec discussion ... whether it happens after 3363 seconds or 3599 seconds doesn't really matter much for the end-user. Regardless of 2FA or not.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
2017-04-06 3:26 GMT+05:00 David Sommerseth <
[email protected]...>:
Quoted 11 lines · Илья Шипицин
Quoted 4 lines
hello!
just curious how renegotiation is handled in "https" ? is it "an abbrevated ssl handshake" (RFC 2246) or ... ?
The HTTPS and OpenVPN protocol is not comparable in this regard at all. AFAIR, OpenVPN does not make use of the TLS renegotiation possibility at all. So a renegotiation in OpenVPN actually results in a completely new and fresh TLS session, not related to previous TLS sessions at all.
both HTTPS and OpenVPN are
1) client-->server
2) long running
3) SSL based
they are similar from many point of view
as, renegotiation does occur for https, and we do not observe "hourly" CPU peaks, I think it worth not reinventing the wheel here
Quoted 41 lines
--
kind regards,David Sommerseth
OpenVPN Technologies, IncQuoted 6 lines
2017-04-06 2:39 GMT+05:00 David Sommerseth
<[email protected]...
<mailto:[email protected]...>>:On 05/04/17 23:13, debbie10t wrote:
> I don't believe there is any need to specify "max" because thatwould be
Quoted 1 line
Quoted 1 line
--reneg-sec as is. Otherwise specify a smaller or larger
--reneg-sec
Quoted 20 lines
I think you, probably without being aware of it, are agreeing to what the current proposal is:
--reneg-sec max
A renegotiation happens within 'max' seconds, but with a 10%-ish randomness--reneg-sec min max
A renegotiation happens within 'min' and 'max' seconds, fully controllableSo using --reneg-sec 3600 3600, effectively removes the randomness.
--
kind regards,David Sommerseth
OpenVPN Technologies, Inc
Quoted 23 lines
Hi,
Quoted 7 lines · On Wed, Apr 05, 2017 at 07:00:54PM +0100, debbie10t wrote:
Quoted 6 lines
Optional option does not mean that it is disabled by default. If you don't the randomness you would need to do:
reneg-sec 3600 3600
the optional argument also allows it to fine tune it to your needs.
Quoted 7 lines
As the reason for --reneg-sec is to specify how long a key should exist, I don't see any further need to make the "random window" be specifically configurable .. The reneg-sec period will remain as specified (def 3600) except for the first run, where --reneg-sec is started from a random time between now and then. There after returning to "normal" with full randomisation of all connected clients --reneg-sec being spread over the *entire* period of --reneg-sec nn and not some unnecessary window.
Setups with 2FA will have to re-enter auth credentials on reneg. Having OpenVPN all of a sudden default to "it could be asking 5 minutes after connection for the credentials again" is massive annoyance - and brings no real benefit anyway.
Quoted 5 lines
It makes sense to jitter reneg-sec somewhat (like, 10%-ish), but changing behaviour too much is not bringing much benefit - you don't need to spread the reneg over the whole period anyway, as different clients connect and disconnect at different times anyway. Just if all of them connect at the same time, the identically-timed renegs are a problem.
That's exactly what happens in the event of an OpenVPN restart on the central server. Our router clients may all restart for updates at the same time and our desktop clients are automatically started in the morning most of them at the same time.
Quoted 5 lines
I like Arne's and David's suggestion - the existing option "as is" will enable X% jitter, while a second parameter can specify a more specific range. Following Arne's argument about users and percent math, it might indeed be better to have "min max" here ("3500 3600"), because that is really easy to understand and explain.
After all the discussion I prefer the simple solution. I've changed my systems to the reduced 10% jitter and I'm wondering if it has to be made more complicated than this? I works very well and after some hours the renegs have spread very well. If you ask me it's perfectly fine that way as long as the docs clearly state that a pseudo random 10% us deducted from reneg-sec automatically to spread renegs.
Simon
Quoted 25 lines · Илья Шипицин
2017-04-06 3:26 GMT+05:00 David Sommerseth
<[email protected]...
<mailto:[email protected]...>>:On 05/04/17 23:43, Илья Шипицин wrote:
> hello!
>
> just curious how renegotiation is handled in "https" ? > is it "an abbrevated ssl handshake" (RFC 2246) or ... ?The HTTPS and OpenVPN protocol is not comparable in this regard at all. AFAIR, OpenVPN does not make use of the TLS renegotiation possibility at all. So a renegotiation in OpenVPN actually results in a completely new and fresh TLS session, not related to previous TLS sessions at all.
both HTTPS and OpenVPN are
1) client-->server
2) long running
3) SSL based
Quoted 4 lines
they are similar from many point of view
as, renegotiation does occur for https, and we do not observe "hourly" CPU peaks, I think it worth not reinventing the wheel here
This is equal to say HTTPS and OpenVPN are both networked applications, disregarding the differences of *how* these applications really work. Just like apples and oranges are both fruits. They are still very much different.
HTTPS in this context is quite misleading. We need to primarily talk about SSL/TLS. HTTPS is basically HTTP over an SSL/TLS connection. So keep that in mind. The same goes for any SSL/TLS enabled service (IMAPS/POP3S, SMTP, XMPP, etc, etc)
A typical HTTPS connection consists of:
a) The client connects to the HTTPS server using a *TCP* port,
b) The TLS handshake happens (managed by the SSL library)
c) Client sends plain text data to the SSL library
d) SSL library encrypts the data
e) Encrypted data is sent to the server
f) Server decrypts data
g) the webserver receives the (decrypted) plain text data, processes the request and sends the plain text result to SSL library
h) SSL library encrypts the data
i) Encrypted result is sent back to the client
j) Client decrypts data, lets the application process the plain text data
k) Client closes the connection to the server
For *each* HTTPS request, these steps happens. The TLS handshake is CPU intensive and costs CPU cycles. So there exists TLS extensions for session resumption, which allows the following connections to re-use the already negotiated encryption keys. And to ensure this keying material is rotated, the application *may* choose to make use of the TLS renegotiation feature. But it is not a requirement.
OpenVPN is different in regards to it's SSL/TLS usage is not bound to TCP (SSL/TLS is by design TCP _only_). OpenVPN splits the communication over a single UDP/TCP socket into a control channel and a data channel. The data channel uses _only_ symmetric encryption, while the TLS packets is sent over the control channel. *All* OpenVPN packets, regardless of data or control channel, are encapsulated with some more information about the client, reliability details, as well as which channel the packet belongs - and a few other bits. This also enables OpenVPN to send SSL/TLS packets over a UDP socket.
A typical OpenVPN TLS connection goes more like this:
1) Client connects to the server, using * UDP _or_ TCP*
2) TLS handshake goes over the control channel
3) Once the TLS handshake has completed successfully, encryption keys are derived for the data channel. This key is not strictly tied to the TLS specification itself, but can be seen as an independent key (this is extremely simplified and not 100% correct, but this background is enough to explain the next steps).
The next things the control channel transports are the network configuration, routing, user/password authentication, other --push'ed options, OCC details, etc.
4) packets sent on the TUN/TAP device gets picked up as "plain text", gets encrypted and sent to the remote side over the UDP/TCP socket as data channel packets, decrypted and put on the remote sides' TUN/TAP device. The encryption used here is the symmetric encryption based on the keying material from step 3.
5) other OpenVPN features (--ping, etc) is sent at regular intervals as control channel packets to the remote side and processed accordingly there, responses are sent back. The data payload of the control channel utilizes the SSL libraries TLS way of sending encrypted data and decrypt it; similar to HTTPS.
6) goto 4, unless a --reneg-* situation hits, the client or server decides to close the connection or other signals are received
7a) In case of --reneg-* situation, goto 2 and start a new TLS
handshake, and prepare a switch from old keys to new keys.
7b) In case of a request/signal to close the tunnel, close the UDP/TCP
socket and exit the program.
The *main* difference here is that while HTTPS initiates a new TCP connection, implying the need for a TLS handshake for each connection, OpenVPN have a single socket open for the life time of the VPN tunnel. HTTPS utilizes very different approaches for session resumption and renegotiations than OpenVPN, as HTTPS doesn't have the notion of control or data packets. It's just a single socket for a single usage.
Web servers these days are also multi-threaded (or "multi-forked"), so they can utilize multiple cores more efficiently. OpenVPN is *single threaded*. So when one client starts a TLS renegotiation, it blocks all the other connected clients until the renegotiation have completed. When you then have 100 connected clients spending 1-2 seconds on each renegotiation happening at the same time, you will have 100-200 seconds of slow and lagging VPN tunnel. This does not mean that you will see a CPU spike, as each client is handled serialized (one by one) - not in parallel.
For a multi-threaded/forked web server, this isn't an issue as each HTTPS request goes to a separate thread/process being handled independently. Which also reduces the risk of slowness and lagging - unless all the allowed configured threads/processes are occupied and busy.
I hope this explains better why you can't compare HTTPS' TLS implementation directly with OpenVPN's implementation. As it truly cannot be compared 1:1.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 7 lines · Simon Matter
Quoted 6 lines
I like Arne's and David's suggestion - the existing option "as is" will enable X% jitter, while a second parameter can specify a more specific range. Following Arne's argument about users and percent math, it might indeed be better to have "min max" here ("3500 3600"), because that is really easy to understand and explain.
Quoted 6 lines
After all the discussion I prefer the simple solution. I've changed my systems to the reduced 10% jitter and I'm wondering if it has to be made more complicated than this? I works very well and after some hours the renegs have spread very well. If you ask me it's perfectly fine that way as long as the docs clearly state that a pseudo random 10% us deducted from reneg-sec automatically to spread renegs.
It must be configurable, based on many years experience with helping out on configuring OpenVPN tunnels. There are millions of OpenVPN configurations out in the world (and I don't even think I'm exaggerating that much even), many small ones and quite some large ones. There are VPN service providers with several hundred thousands paying customers, and there are an enormous amount of VPN service providers in addition. In addition to all the private and corporate deployments.
So enforcing a good feature equally on all these configurations will backfire at us.
And the more I think about the 10% randomness vlaue (or any percentage), I really wonder how clever that is. If a site uses --reneg-sec 1800 (I have seen that), that means a 3 minute window. If a site uses 14400 (4 hours, I've seen that too), that gives a 24 minute window. These window sizes may be perfectly fine. But depending on the amount of connected users, this may be troublesome too.
Last night I chatted with krzee on #openvpn-devel about this. He does quite some cool stuff with OpenVPN and have lots of IP phones connecting to VPN servers. He said that randomness by default may not be ideal for
some of the setups he manages. But he loves the idea behind this
feature.
Krzee argued that configurations explicitly setting --reneg-sec 3600 should not have any randomness. If a configuration does _not* set --reneg-sec, it may have randomness with 1 hour as the base. And those wanting better control of the time window should use:
--reneg-sec min max
I initially was of the opinion --reneg-sec 3600 should have randomness (the 10-17% base). But after having slept on it, I think Krzee have a good point. Setting --reneg-sec explicitly with only a single value should not have any randomness.
With the 1 hour default, not setting --reneg-sec gives a time window of 6 minutes with 10%. That is a reasonable default unless explicitly overridden by either --reneg-sec 3600 (no randomness) or --reneg-sec 3000 4000 (with a 1000 seconds large time window)
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 4 lines · David Sommerseth
With the 1 hour default, not setting --reneg-sec gives a time window of 6 minutes with 10%. That is a reasonable default unless explicitly overridden by either --reneg-sec 3600 (no randomness) or --reneg-sec 3000 4000 (with a 1000 seconds large time window)
I still believe this approach is wrong.
You are changing the meaning of an operand depending on the number of operands and changing the function of the directive depending on number of operands and if the directive is explicitly specified or not.
This is equivalent to:
(no --server specified) = --server 10.8.0.0 255.255.255.0 vs
--server subnet mask (pool determined by default) vs
--server *pool* subnet mask
And so I re-submit my protest!
The syntax for --reneg-sec should be "--reneg-sec seconds window"
where "--reneg-sec 3600" is as it is now !
where "--reneg-sec 3600 360" is as now with a 10% window of random.
Not specifying --reneg-sec at all should *not* imply a default window, it should remain as it is now.
Additionally, "window" *could* be + or - allowing for window to be applied at the beginning of the session or at the end of the session.
Also, IMO this should be first-run *only*
I am sorry David but you have not changed my mind, although the decision is, of course, down to the devs.
my2c
regards
Hi,
Quoted 50 lines · David Sommerseth
Quoted 7 lines · Simon Matter
Quoted 6 lines
I like Arne's and David's suggestion - the existing option "as is" will enable X% jitter, while a second parameter can specify a more specific range. Following Arne's argument about users and percent math, it might indeed be better to have "min max" here ("3500 3600"), because that is really easy to understand and explain.
Quoted 6 lines
After all the discussion I prefer the simple solution. I've changed my systems to the reduced 10% jitter and I'm wondering if it has to be made more complicated than this? I works very well and after some hours the renegs have spread very well. If you ask me it's perfectly fine that way as long as the docs clearly state that a pseudo random 10% us deducted from reneg-sec automatically to spread renegs.
It must be configurable, based on many years experience with helping out on configuring OpenVPN tunnels. There are millions of OpenVPN configurations out in the world (and I don't even think I'm exaggerating that much even), many small ones and quite some large ones. There are VPN service providers with several hundred thousands paying customers, and there are an enormous amount of VPN service providers in addition. In addition to all the private and corporate deployments.
So enforcing a good feature equally on all these configurations will backfire at us.
And the more I think about the 10% randomness vlaue (or any percentage), I really wonder how clever that is. If a site uses --reneg-sec 1800 (I have seen that), that means a 3 minute window. If a site uses 14400 (4 hours, I've seen that too), that gives a 24 minute window. These window sizes may be perfectly fine. But depending on the amount of connected users, this may be troublesome too.
Last night I chatted with krzee on #openvpn-devel about this. He does quite some cool stuff with OpenVPN and have lots of IP phones connecting to VPN servers. He said that randomness by default may not be ideal for
some of the setups he manages. But he loves the idea behind this
feature.Krzee argued that configurations explicitly setting --reneg-sec 3600 should not have any randomness. If a configuration does _not* set --reneg-sec, it may have randomness with 1 hour as the base. And those wanting better control of the time window should use:
--reneg-sec min maxI initially was of the opinion --reneg-sec 3600 should have randomness (the 10-17% base). But after having slept on it, I think Krzee have a good point. Setting --reneg-sec explicitly with only a single value should not have any randomness.
Quoted 4 lines
With the 1 hour default, not setting --reneg-sec gives a time window of 6 minutes with 10%. That is a reasonable default unless explicitly overridden by either --reneg-sec 3600 (no randomness) or --reneg-sec 3000 4000 (with a 1000 seconds large time window)
Wow, this discussion suddenly caught some attention! I'll chip in too.
I was fine with not making this configurable, but the discussion convinced me that people really want to be able to configure this, so I agree we should.
As for the option, I think Arne's proposal is the best:
--reneg-sec max [min]
where <nothing> == --reneg-sec 3600 == --reneg-sec 3600 3240 (assuming 10% default randomization)
Why? Because this
1) doesn't change the meaning of the first argument based on whether the second is present. That's just confusing.
2) does by default what we expect is best for most users: randomize the reneg-sec value
3) still allows administrators to disable randomization
4) 'max' and 'min' are hard to misinterpret ('window', 'jitter' or 'offset' are much easier to misinterpret)
As for 'first time only' or 'always': go for always. That will slowly spread out the clients over the entire reneg-sec window, instead of over just xx% of the window. The odds that 'all periods line up' that David mentioned seem negligible to me. Especially assuming that clients will occasionally reconnect at 'random' times. I did not do the calculations, but can do that if you really want to.
Finally, we should probably only randomize by default on the server side. We effectively renegotiate at min(server-reneg-interval, client-reneg-interval), which will cause a bias towards the earlier part of the interval if randomize at both sides.
-Steffan
Quoted 61 lines · Steffan Karger
Hi,
Quoted 50 lines · David Sommerseth
Quoted 7 lines · Simon Matter
Quoted 6 lines
I like Arne's and David's suggestion - the existing option "as is" will enable X% jitter, while a second parameter can specify a more specific range. Following Arne's argument about users and percent math, it might indeed be better to have "min max" here ("3500 3600"), because that is really easy to understand and explain.
Quoted 6 lines
After all the discussion I prefer the simple solution. I've changed my systems to the reduced 10% jitter and I'm wondering if it has to be made more complicated than this? I works very well and after some hours the renegs have spread very well. If you ask me it's perfectly fine that way as long as the docs clearly state that a pseudo random 10% us deducted from reneg-sec automatically to spread renegs.
It must be configurable, based on many years experience with helping out on configuring OpenVPN tunnels. There are millions of OpenVPN configurations out in the world (and I don't even think I'm exaggerating that much even), many small ones and quite some large ones. There are VPN service providers with several hundred thousands paying customers, and there are an enormous amount of VPN service providers in addition. In addition to all the private and corporate deployments.
So enforcing a good feature equally on all these configurations will backfire at us.
And the more I think about the 10% randomness vlaue (or any percentage), I really wonder how clever that is. If a site uses --reneg-sec 1800 (I have seen that), that means a 3 minute window. If a site uses 14400 (4 hours, I've seen that too), that gives a 24 minute window. These window sizes may be perfectly fine. But depending on the amount of connected users, this may be troublesome too.
Last night I chatted with krzee on #openvpn-devel about this. He does quite some cool stuff with OpenVPN and have lots of IP phones connecting to VPN servers. He said that randomness by default may not be ideal for
some of the setups he manages. But he loves the idea behind this
feature.Krzee argued that configurations explicitly setting --reneg-sec 3600 should not have any randomness. If a configuration does _not* set --reneg-sec, it may have randomness with 1 hour as the base. And those wanting better control of the time window should use:
--reneg-sec min maxI initially was of the opinion --reneg-sec 3600 should have randomness (the 10-17% base). But after having slept on it, I think Krzee have a good point. Setting --reneg-sec explicitly with only a single value should not have any randomness.
Quoted 4 lines
With the 1 hour default, not setting --reneg-sec gives a time window of 6 minutes with 10%. That is a reasonable default unless explicitly overridden by either --reneg-sec 3600 (no randomness) or --reneg-sec 3000 4000 (with a 1000 seconds large time window)
Wow, this discussion suddenly caught some attention! I'll chip in too.
Quoted 8 lines
I was fine with not making this configurable, but the discussion convinced me that people really want to be able to configure this, so I agree we should.
As for the option, I think Arne's proposal is the best:
--reneg-sec max [min]
where <nothing> == --reneg-sec 3600 == --reneg-sec 3600 3240 (assuming 10% default randomization)
The Initial proposal was --reneg-sec [min] max (horrible)
Quoted 11 lines
Why? Because this
1) doesn't change the meaning of the first argument based on whether the second is present. That's just confusing.
2) does by default what we expect is best for most users: randomize the reneg-sec value
3) still allows administrators to disable randomization
4) 'max' and 'min' are hard to misinterpret ('window', 'jitter' or 'offset' are much easier to misinterpret)As for 'first time only' or 'always': go for always.
If it is set to always, you are permanently changing the function of --reneg-sec to always use random *or* no random at all, which the user cannot modify. This randomise is only required for the first period and subsequent periods should return to normal.
People are accustomed to a one hour period, I feel sure that randomising the period permanently will drive people insane!
The point of putting this "into" openvpn binary is in order to break up the "renegging" clients on the first reneg *only*, then changing back to normal behaviour. This "changing back" cannot be done via a script because no scripts are called on --reneg-sec, therefore it *must* be done by the binary.
As you can see, the current proposal does not allow for first random, followed by expected/normal/regular renegs. It is either *always* random or *never* random .. I believe this is a poor decision.
Quoted 3 lines
That will slowly
spread out the clients over the entire reneg-sec window, instead of over just xx% of the window. The odds that 'all periods line up' that
Even you find the term "window" accurate ..
I maintain my position.
Regards
Hi,
Quoted 3 lines · On Thu, Apr 06, 2017 at 01:49:04PM +0100, debbie10t wrote:
As you can see, the current proposal does not allow for first random, followed by expected/normal/regular renegs. It is either *always* random or *never* random .. I believe this is a poor decision.
Your voice has been heard, and nobody else of the core team has been convinced. It is not necessary to repeat that more often.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Quoted 4 lines · On 06/04/17 14:49, debbie10t wrote:
As you can see, the current proposal does not allow for first random, followed by expected/normal/regular renegs. It is either *always* random or *never* random .. I believe this is a poor decision.
Even though I see arguments for first-only, I have no issues having the current implementation being "always" or "none".
Adding a flag so the user can switch it to "first-only" will be a fairly trivial patch to add. In fact, I already now believe 66% of that possible future patch will be updating the man page and Changes.rst. The code itself to manage this will be probably around 10-15 lines of code - possibly even less - when basing it on the "always" behaviour.
And if not a critical mass of users complains within a reasonable time ... well, then we don't need to bother.
No need to make even more noise about that now.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 9 lines
Web servers these days are also multi-threaded (or "multi-forked"), so they can utilize multiple cores more efficiently. OpenVPN is *single threaded*. So when one client starts a TLS renegotiation, it blocks all the other connected clients until the renegotiation have completed. When you then have 100 connected clients spending 1-2 seconds on each renegotiation happening at the same time, you will have 100-200 seconds of slow and lagging VPN tunnel. This does not mean that you will see a CPU spike, as each client is handled serialized (one by one) - not in parallel.
That's only true for single instance servers, with multiple OpenVPN instances and limited CPU cores this quickly becomes an issue.
Simon
Quoted 9 lines · Gert Doering
Hi,
Quoted 3 lines · On Thu, Apr 06, 2017 at 01:49:04PM +0100, debbie10t wrote:
As you can see, the current proposal does not allow for first random, followed by expected/normal/regular renegs. It is either *always* random or *never* random .. I believe this is a poor decision.
Your voice has been heard, and nobody else of the core team has been convinced. It is not necessary to repeat that more often.
I believe the core team has made a poor decision and I am trying to explain clearly "why".
Take for example:
Company A has 1,000 vpn users and (for what ever reason) they reboot the server every 24 hours. They experience the slow down because all their vpn users are permanently connected. They all connect at once. This patch is not trying to address the initial connect it is trying to address the subsequent reneg's all happening at once.
So, Company A decides to use --reneg-sec max min
Subsequently, Company A receive a flood of complaints from users who are being constantly randomly reneg'd .. when they are accustomed to regular hourly reneg's.
Company A either disables the randomisation ..
or tells their users "what" ?
The only justifiable randon reneg is the first one and Company A would be able to explain that to their users, that they must experience one random reneg or they all experience slow down at hourly intervals.
Regards
Quoted 97 lines · Steffan Karger
Quoted 73 lines
Hi,
Quoted 62 lines · David Sommerseth
Quoted 11 lines · Simon Matter
Quoted 10 lines
I like Arne's and David's suggestion - the existing option "as is" will
enable X% jitter, while a second parameter can specify a more specific
range. Following Arne's argument about users and percent math, it might
indeed be better to have "min max" here ("3500 3600"), because that is
really easy to understand and explain.Quoted 8 lines
After all the discussion I prefer the simple solution. I've changed my systems to the reduced 10% jitter and I'm wondering if it has to be made
more complicated than this? I works very well and after some hours the renegs have spread very well. If you ask me it's perfectly fine that way
as long as the docs clearly state that a pseudo random 10% us deducted from reneg-sec automatically to spread renegs.It must be configurable, based on many years experience with helping out
on configuring OpenVPN tunnels. There are millions of OpenVPN configurations out in the world (and I don't even think I'm exaggerating
that much even), many small ones and quite some large ones. There are VPN service providers with several hundred thousands paying customers, and there are an enormous amount of VPN service providers in addition. In addition to all the private and corporate deployments.So enforcing a good feature equally on all these configurations will backfire at us.
And the more I think about the 10% randomness vlaue (or any percentage),
I really wonder how clever that is. If a site uses --reneg-sec 1800 (I have seen that), that means a 3 minute window. If a site uses 14400 (4 hours, I've seen that too), that gives a 24 minute window. These window
sizes may be perfectly fine. But depending on the amount of connected users, this may be troublesome too.Last night I chatted with krzee on #openvpn-devel about this. He does quite some cool stuff with OpenVPN and have lots of IP phones connecting
to VPN servers. He said that randomness by default may not be ideal for
some of the setups he manages. But he loves the idea behind this
feature.Krzee argued that configurations explicitly setting --reneg-sec 3600 should not have any randomness. If a configuration does _not* set --reneg-sec, it may have randomness with 1 hour as the base. And those wanting better control of the time window should use:
--reneg-sec min maxI initially was of the opinion --reneg-sec 3600 should have randomness (the 10-17% base). But after having slept on it, I think Krzee have a good point. Setting --reneg-sec explicitly with only a single value should not have any randomness.
Quoted 4 lines
With the 1 hour default, not setting --reneg-sec gives a time window of 6 minutes with 10%. That is a reasonable default unless explicitly overridden by either --reneg-sec 3600 (no randomness) or --reneg-sec 3000 4000 (with a 1000 seconds large time window)
Wow, this discussion suddenly caught some attention! I'll chip in too.
Quoted 8 lines
I was fine with not making this configurable, but the discussion convinced me that people really want to be able to configure this, so I agree we should.
As for the option, I think Arne's proposal is the best:
--reneg-sec max [min]
where <nothing> == --reneg-sec 3600 == --reneg-sec 3600 3240 (assuming 10% default randomization)The Initial proposal was --reneg-sec [min] max (horrible)
Quoted 10 lines
Why? Because this
1) doesn't change the meaning of the first argument based on whether the second is present. That's just confusing.
2) does by default what we expect is best for most users: randomize the reneg-sec value
3) still allows administrators to disable randomization
4) 'max' and 'min' are hard to misinterpret ('window', 'jitter' or 'offset' are much easier to misinterpret)
Quoted 6 lines
Quoted 1 line
As for 'first time only' or 'always': go for always.
If it is set to always, you are permanently changing the function of --reneg-sec to always use random *or* no random at all, which the user cannot modify. This randomise is only required for the first period and subsequent periods should return to normal.
Without knowing exactly how OpenVPN does it, I'm against the first only approach because it can still result in problems, depending on how the interval logic is handled.
Time windows can, for one or the other reason, slowly move forward or backward. If things go wrong, all time windows can slowly move closer and closer to each other, until the difference between them melts down to zero.
Simon
Quoted 5 lines · On 06/04/17 15:37, debbie10t wrote:
Company A has 1,000 vpn users and (for what ever reason) they reboot the server every 24 hours. They experience the slow down because all their vpn users are permanently connected. They all connect at once. This patch is not trying to address the initial connect it is trying to address the subsequent reneg's all happening at once.
This is not what --reneg-sec is about. --reneg-sec does not control the initial connection. What you want here is a randomized initial connection delay when client have lost connection to the openvpn server and needs to do a reCONNECT.
That is an entirely different feature than reNEGOTIATION of established tunnels (which --reneg-sec targets). However, randomizing --reneg-sec will improve the situation *after* the initial connect congestion, once the first renegotiation round starts. At this point in time, things will start to spread out.
But I emphasize again, --reneg-sec have never tried to solve randomizing of the _initial_ connect step.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
Quoted 12 lines · David Sommerseth
Quoted 5 lines · On 06/04/17 15:37, debbie10t wrote:
Company A has 1,000 vpn users and (for what ever reason) they reboot the server every 24 hours. They experience the slow down because all their vpn users are permanently connected. They all connect at once. This patch is not trying to address the initial connect it is trying to address the subsequent reneg's all happening at once.
This is not what --reneg-sec is about. --reneg-sec does not control the initial connection. What you want here is a randomized initial connection delay when client have lost connection to the openvpn server and needs to do a reCONNECT.
Quoted 9 lines
That is an entirely different feature than reNEGOTIATION of established tunnels (which --reneg-sec targets). However, randomizing --reneg-sec will improve the situation *after* the initial connect congestion, once the first renegotiation round starts. At this point in time, things will start to spread out.
But I emphasize again, --reneg-sec have never tried to solve randomizing of the _initial_ connect step.
Which is exactly what I said ..
Quoted 2 lines
Quoted 2 lines
This patch is not trying to address the initial connect it is trying to address the subsequent reneg's all happening at once.
Regards
PATCH v3 1/1 Add per session pseudo-random jitter to --reneg-sec intervals
In reply to Simon MatterFrom: Simon Matter <[email protected]...>
While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is still room for improvement in our use case.
It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things worse, we realized that most renegotiation procedures took place at almost the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.
I've created attached patch to add a per session pseudo-random component to the --reneg-sec intervals so that renegotiation is evenly spread over time. It is configured by simply adding a second value to --reneg-sec as described in the --help text:
--reneg-sec max [min] : Renegotiate data chan. key after at most max
(default=3600) and at least min (default 90% of max on servers and equal to max on clients).
The jitter is only enabled by default on servers, because the actual reneg time is min(reneg_server, reneg_client). Introducing jitter at both ends would bias the actual reneg time to the min value.
Note that the patch also slightly changes the log output to show the sec value in the same way as the bytes/pkts values:
TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0
The idea and first versions of this patch are from Simon Matter. Steffan Karger later incorporated the mailing list comments into this patch. So credits go to Simon, and all bugs are Steffan's fault ;-)
---
v3: incorporate comments from openvpn-devel@, don't add jitter by
default on the client side.
doc/openvpn.8 | 26 +++++++++++++++++++++----- src/openvpn/init.c | 15 ++++++++++++++- src/openvpn/options.c | 11 +++++++++-- src/openvpn/options.h | 1 + src/openvpn/ssl.c | 6 +++--- 5 files changed, 48 insertions(+), 11 deletions(-)
doc/openvpn.8 +21 -5
@@ -33,7 +33,7 @@ .\" .ft -- normal face .\" .in +|-{n} -- indent .\" -.TH openvpn 8 "25 August 2016" +.TH openvpn 8 "04 April 2017" .\"********************************************************* .SH NAME openvpn \- secure IP tunnel daemon.
@@ -4957,10 +4957,26 @@ Renegotiate data channel key after packets sent and received (disabled by default). .\"********************************************************* .TP -.B \-\-reneg\-sec n -Renegotiate data channel key after -.B n -seconds (default=3600). +.B \-\-reneg\-sec max [min] +Renegotiate data channel key after at most +.B max +seconds (default=3600) and at least +.B min +seconds (default is 90% of +.B max +for servers, and equal to +.B max +for clients). + +The effective +.B reneg\-sec +value used is per session pseudo-uniform-randomized between +.B min +and +.B max\fR. + +With the default value of 3600 this results in an effective per session value +in the range of 3240..3600 seconds for servers, or just 3600 for clients. When using dual\-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.
src/openvpn/init.c +14 -1
@@ -2693,7 +2693,20 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.packet_timeout = options->tls_timeout; to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; - to.renegotiate_seconds = options->renegotiate_seconds; +if (options->renegotiate_seconds_min <0 ) + { +/* Add 10% jitter to the reneg-sec of each connection by default */ +int auto_jitter = options->mode !=MODE_SERVER ?0 : +get_random () %max_int (options->renegotiate_seconds /10 ,1 ); + to.renegotiate_seconds = options->renegotiate_seconds - auto_jitter; + } +else + { +/* Add user-specific jitter to the renge-sec of each connection */ + to.renegotiate_seconds = options->renegotiate_seconds - + (get_random () %max_int (options->renegotiate_seconds + - options->renegotiate_seconds_min,1 )); + } to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;
src/openvpn/options.c +9 -2
@@ -603,7 +603,9 @@ static const char usage_message[] =" if no ACK from remote within n seconds (default=%d).\n" "--reneg-bytes n : Renegotiate data chan. key after n bytes sent and recvd.\n" "--reneg-pkts n : Renegotiate data chan. key after n packets sent and recvd.\n" -"--reneg-sec n : Renegotiate data chan. key after n seconds (default=%d).\n" +"--reneg-sec max [min] : Renegotiate data chan. key after at most max (default=%d)\n" +" and at least min (defaults to 90%% of max on servers and equal\n" +" to max on clients).\n" "--hand-window n : Data channel key exchange must finalize within n seconds\n" " of handshake initiation by any peer (default=%d).\n" "--tran-window n : Transition window -- old key can live this many seconds\n"
@@ -870,6 +872,7 @@ init_options(struct options *o, const bool init_gc) o->tls_timeout =2 ; o->renegotiate_bytes =-1 ; o->renegotiate_seconds =3600 ; + o->renegotiate_seconds_min =-1 ; o->handshake_window =60 ; o->transition_window =3600 ; o->ecdh_curve =NULL ;
@@ -7999,10 +8002,14 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_packets =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[2 ]) +else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[3 ]) {VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_seconds =positive_atoi (p[1 ]); +if (p[2 ]) + { + options->renegotiate_seconds_min =positive_atoi (p[2 ]); + } }else if (streq (p[0 ],"hand-window" ) && p[1 ] && !p[2 ]) {
src/openvpn/options.h +1 -0
@@ -548,6 +548,7 @@ struct optionsint renegotiate_bytes;int renegotiate_packets;int renegotiate_seconds; +int renegotiate_seconds_min;/* Data channel key handshake must finalize * within n seconds of handshake initiation. */
src/openvpn/ssl.c +3 -3
@@ -2732,9 +2732,9 @@ tls_process(struct tls_multi *multi, && ks->n_packets >= session->opt->renegotiate_packets) || (packet_id_close_to_wrapping(&ks->crypto_options.packet_id.send)))) { -msg (D_TLS_DEBUG_LOW , -"TLS: soft reset sec=%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , - (int )(ks->established + session->opt->renegotiate_seconds - now), +msg (D_TLS_DEBUG_LOW ,"TLS: soft reset sec=%lld/%d bytes=" counter_format +"/%d pkts=" counter_format"/%d" , + (now - ks->established), session->opt->renegotiate_seconds, ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session);
Signature · 1 line
2.14.1
Re: [Openvpn-devel] [PATCH v3] Add per session pseudo-random jitter to --reneg-sec intervals
src/openvpn/init.c do_init_crypto_tls(struct context *c, const unsigned int flags) · line 2698
Quoted 10 lines · Steffan Karger
src/openvpn/init.c +3
-1@@ -2693,7 +2693,20 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.packet_timeout = options->tls_timeout; to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; - to.renegotiate_seconds = options->renegotiate_seconds; +if (options->renegotiate_seconds_min <0 ) + { +/* Add 10% jitter to the reneg-sec of each connection by default */
Maybe change that to "of each server connection".
src/openvpn/init.c do_init_crypto_tls(struct context *c, const unsigned int flags) · line 2705
Quoted 7 lines
src/openvpn/init.c +7
-0+int auto_jitter = options->mode !=MODE_SERVER ?0 : +get_random () %max_int (options->renegotiate_seconds /10 ,1 ); + to.renegotiate_seconds = options->renegotiate_seconds - auto_jitter; + } +else + { +/* Add user-specific jitter to the renge-sec of each connection */
s/renge/reneg/
src/openvpn/init.c do_init_crypto_tls(struct context *c, const unsigned int flags) · line 2712
Quoted 7 lines
src/openvpn/init.c +4
-0+ to.renegotiate_seconds = options->renegotiate_seconds - + (get_random () %max_int (options->renegotiate_seconds + - options->renegotiate_seconds_min,1 )); + } to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;
Regards
Simon
Signature · 3 lines
+ privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9
Re: [Openvpn-devel] [PATCH v3] Add per session pseudo-random jitter to --reneg-sec intervals
In reply to Steffan KargerHi Steffan,
Thanks for taking the time to improve this!
Regards,
Simon
Quoted 210 lines
From: Simon Matter <[email protected]...>
While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is still room for improvement in our use case.It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things worse, we realized that most renegotiation procedures took place at almost the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.
I've created attached patch to add a per session pseudo-random component to
the --reneg-sec intervals so that renegotiation is evenly spread over time.
It is configured by simply adding a second value to --reneg-sec as described in the --help text:--reneg-sec max [min] : Renegotiate data chan. key after at most max
(default=3600) and at least min (default 90% of max on servers and equal to max on clients).The jitter is only enabled by default on servers, because the actual reneg time is
min(reneg_server, reneg_client). Introducing jitter at both ends would bias the actual reneg time to the min value.Note that the patch also slightly changes the log output to show the sec value in the same way as the bytes/pkts values:
TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0
The idea and first versions of this patch are from Simon Matter. Steffan Karger later incorporated the mailing list comments into this patch. So credits go to Simon, and all bugs are Steffan's fault ;-)
Signed-off-by Simon Matter <[email protected]...>Signed-off-by Steffan Karger <[email protected]...>---
v3: incorporate comments from openvpn-devel@, don't add jitter by
default on the client side.doc/openvpn.8 | 26 +++++++++++++++++++++----- src/openvpn/init.c | 15 ++++++++++++++- src/openvpn/options.c | 11 +++++++++-- src/openvpn/options.h | 1 + src/openvpn/ssl.c | 6 +++--- 5 files changed, 48 insertions(+), 11 deletions(-)doc/openvpn.8 +20
-5@@ -33,7 +33,7 @@ .\" .ft -- normal face .\" .in +|-{n} -- indent .\" -.TH openvpn 8 "25 August 2016" +.TH openvpn 8 "04 April 2017" .\"********************************************************* .SH NAME openvpn \- secure IP tunnel daemon.@@ -4957,10 +4957,26 @@ Renegotiate data channel key after packets sent and received (disabled by default). .\"********************************************************* .TP -.B \-\-reneg\-sec n -Renegotiate data channel key after -.B n -seconds (default=3600). +.B \-\-reneg\-sec max [min] +Renegotiate data channel key after at most +.B max +seconds (default=3600) and at least +.B min +seconds (default is 90% of +.B max +for servers, and equal to +.B max +for clients). + +The effective +.B reneg\-sec +value used is per session pseudo-uniform-randomized between +.B min +and +.B max\fR. + +With the default value of 3600 this results in an effective per sessionvalue
doc/openvpn.8 +1
-0+in the range of 3240..3600 seconds for servers, or just 3600 for clients. When using dual\-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.src/openvpn/init.c +6
-1@@ -2693,7 +2693,20 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.packet_timeout = options->tls_timeout; to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; -to.renegotiate_seconds = options->renegotiate_seconds; +if (options->renegotiate_seconds_min <0 ) + { +/* Add 10% jitter to the reneg-sec of each connection by default */ +int auto_jitter = options->mode !=MODE_SERVER ?0 : +get_random () %max_int (options->renegotiate_seconds /10 ,1 ); + to.renegotiate_seconds = options->renegotiate_seconds -
auto_jitter;src/openvpn/init.c +4
-0+ } +else + { +/* Add user-specific jitter to the renge-sec of each connection */
src/openvpn/init.c +3
-0+ to.renegotiate_seconds = options->renegotiate_seconds - + (get_random() % max_int(options->renegotiate_seconds + -
options->renegotiate_seconds_min, 1));src/openvpn/init.c +1
-0+ } to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;src/openvpn/options.c +0
-0@@ -603,7 +603,9 @@ static const char usage_message[] = " if no ACK from remote within n seconds(default=%d).\n"
"--reneg-bytes n : Renegotiate data chan. key after n bytes sent and
recvd.\n"
"--reneg-pkts n : Renegotiate data chan. key after n packets sent
and recvd.\n"
- "--reneg-sec n : Renegotiate data chan. key after n seconds
(default=%d).\n"
+ "--reneg-sec max [min] : Renegotiate data chan. key after at most max
(default=%d)\n"
+ " and at least min (defaults to 90%% of max on
servers and equal\n"
+ " to max on clients).\n"
"--hand-window n : Data channel key exchange must finalize within n
seconds\n"
" of handshake initiation by any peer
(default=%d).\n"
"--tran-window n : Transition window -- old key can live this many
seconds\n"src/openvpn/options.c +6
-1@@ -870,6 +872,7 @@ init_options(struct options *o, const bool init_gc) o->tls_timeout =2 ; o->renegotiate_bytes =-1 ; o->renegotiate_seconds =3600 ; + o->renegotiate_seconds_min =-1 ; o->handshake_window =60 ; o->transition_window =3600 ; o->ecdh_curve =NULL ;@@ -7999,10 +8002,14 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_packets =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[2 ]) +else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[3 ]) {VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_seconds =positive_atoi (p[1 ]); +if (p[2 ]) + { + options->renegotiate_seconds_min =positive_atoi (p[2 ]); + } }else if (streq (p[0 ],"hand-window" ) && p[1 ] && !p[2 ]) {src/openvpn/options.h +1
-0@@ -548,6 +548,7 @@ struct optionsint renegotiate_bytes;int renegotiate_packets;int renegotiate_seconds; +int renegotiate_seconds_min;/* Data channel key handshake must finalize * within n seconds of handshake initiation. */ src/openvpn/ssl.c +1
-3@@ -2732,9 +2732,9 @@ tls_process(struct tls_multi *multi, && ks->n_packets >= session->opt->renegotiate_packets) || (packet_id_close_to_wrapping(&ks->crypto_options.packet_id.send)))) { - msg(D_TLS_DEBUG_LOW, - "TLS: soft reset sec=%d bytes=" counter_format "/%d pkts=" counter_format "/%d", - (int)(ks->established + session->opt->renegotiate_seconds - now), + msg(D_TLS_DEBUG_LOW, "TLS: soft reset sec=%lld/%d bytes="
counter_formatsrc/openvpn/ssl.c +2
-1+"/%d pkts=" counter_format"/%d" , + (now - ks->established), session->opt->renegotiate_seconds, ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session); --2.14.1
Re: [Openvpn-devel] [PATCH v3] Add per session pseudo-random jitter to --reneg-sec intervals
In reply to Steffan KargerHi Steffan,
While running your v3 version of the patch I found an issue with the modified logging. It gives the following error while building
gcc -DHAVE_CONFIG_H -I. -I../.. -I../../include -I../../include
-I../../src/compat -DPLUGIN_LIBDIR=\"/usr/lib64/openvpn/plugins\"
-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -std=c99 -c -o ssl.o ssl.cssl.c: In function 'tls_process':
ssl.c:2735:9: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'time_t' [-Wformat=]
msg(D_TLS_DEBUG_LOW, "TLS: soft reset sec=%lld/%d bytes="counter_format
^
and the log output is also corrupted
TLS: soft reset sec=14774687501680/336605974 bytes=18446744069414584320/581335 pkts=0/0
TLS: soft reset sec=14787572403571/77375 bytes=18446744069414584320/885 pkts=0/-1080308296
TLS: soft reset sec=14164802145506/6746662 bytes=18446744069414584320/86778 pkts=0/0
TLS: soft reset sec=15264313773538/186529 bytes=18446744069414584320/1108 pkts=0/13935244
Please have a look at the attached v4 patch which fixes it for me. The output is now
TLS: soft reset sec=3474/3474 bytes=8470454/-1 pkts=108673/0
TLS: soft reset sec=3489/3489 bytes=429623769/-1 pkts=656033/0
TLS: soft reset sec=3517/3517 bytes=89365/-1 pkts=877/0
TLS: soft reset sec=3537/3537 bytes=206142/-1 pkts=1123/0
which seems reasonable to me.
In the patch I've modified the lines below:
msg(D_TLS_DEBUG_LOW,
- "TLS: soft reset sec=%d bytes=" counter_format "/%d pkts="counter_format "/%d",
- (int)(ks->established + session->opt->renegotiate_seconds -
now),
+ "TLS: soft reset sec=%d/%d bytes=" counter_format "/%d pkts="counter_format "/%d",
+ (int)(now - ks->established), session->opt->renegotiate_seconds,
ks->n_bytes, session->opt->renegotiate_bytes,
I'm not a developer and not a git user, so please accept my hand crafted patch work :-)
Thanks and regards,
Simon
Quoted 208 lines
From: Simon Matter <[email protected]...>
While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is still room for improvement in our use case.It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things worse, we realized that most renegotiation procedures took place at almost the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.
I've created attached patch to add a per session pseudo-random component to
the --reneg-sec intervals so that renegotiation is evenly spread over time.
It is configured by simply adding a second value to --reneg-sec as described in the --help text:--reneg-sec max [min] : Renegotiate data chan. key after at most max
(default=3600) and at least min (default 90% of max on servers and equal to max on clients).The jitter is only enabled by default on servers, because the actual reneg time is
min(reneg_server, reneg_client). Introducing jitter at both ends would bias the actual reneg time to the min value.Note that the patch also slightly changes the log output to show the sec value in the same way as the bytes/pkts values:
TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0
The idea and first versions of this patch are from Simon Matter. Steffan Karger later incorporated the mailing list comments into this patch. So credits go to Simon, and all bugs are Steffan's fault ;-)
Signed-off-by Simon Matter <[email protected]...>Signed-off-by Steffan Karger <[email protected]...>---
v3: incorporate comments from openvpn-devel@, don't add jitter by
default on the client side.doc/openvpn.8 | 26 +++++++++++++++++++++----- src/openvpn/init.c | 15 ++++++++++++++- src/openvpn/options.c | 11 +++++++++-- src/openvpn/options.h | 1 + src/openvpn/ssl.c | 6 +++--- 5 files changed, 48 insertions(+), 11 deletions(-)doc/openvpn.8 +20
-5@@ -33,7 +33,7 @@ .\" .ft -- normal face .\" .in +|-{n} -- indent .\" -.TH openvpn 8 "25 August 2016" +.TH openvpn 8 "04 April 2017" .\"********************************************************* .SH NAME openvpn \- secure IP tunnel daemon.@@ -4957,10 +4957,26 @@ Renegotiate data channel key after packets sent and received (disabled by default). .\"********************************************************* .TP -.B \-\-reneg\-sec n -Renegotiate data channel key after -.B n -seconds (default=3600). +.B \-\-reneg\-sec max [min] +Renegotiate data channel key after at most +.B max +seconds (default=3600) and at least +.B min +seconds (default is 90% of +.B max +for servers, and equal to +.B max +for clients). + +The effective +.B reneg\-sec +value used is per session pseudo-uniform-randomized between +.B min +and +.B max\fR. + +With the default value of 3600 this results in an effective per sessionvalue
doc/openvpn.8 +1
-0+in the range of 3240..3600 seconds for servers, or just 3600 for clients. When using dual\-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.src/openvpn/init.c +6
-1@@ -2693,7 +2693,20 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.packet_timeout = options->tls_timeout; to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; -to.renegotiate_seconds = options->renegotiate_seconds; +if (options->renegotiate_seconds_min <0 ) + { +/* Add 10% jitter to the reneg-sec of each connection by default */ +int auto_jitter = options->mode !=MODE_SERVER ?0 : +get_random () %max_int (options->renegotiate_seconds /10 ,1 ); + to.renegotiate_seconds = options->renegotiate_seconds -
auto_jitter;src/openvpn/init.c +4
-0+ } +else + { +/* Add user-specific jitter to the renge-sec of each connection */
src/openvpn/init.c +3
-0+ to.renegotiate_seconds = options->renegotiate_seconds - + (get_random() % max_int(options->renegotiate_seconds + -
options->renegotiate_seconds_min, 1));src/openvpn/init.c +1
-0+ } to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;src/openvpn/options.c +0
-0@@ -603,7 +603,9 @@ static const char usage_message[] = " if no ACK from remote within n seconds(default=%d).\n"
"--reneg-bytes n : Renegotiate data chan. key after n bytes sent and
recvd.\n"
"--reneg-pkts n : Renegotiate data chan. key after n packets sent
and recvd.\n"
- "--reneg-sec n : Renegotiate data chan. key after n seconds
(default=%d).\n"
+ "--reneg-sec max [min] : Renegotiate data chan. key after at most max
(default=%d)\n"
+ " and at least min (defaults to 90%% of max on
servers and equal\n"
+ " to max on clients).\n"
"--hand-window n : Data channel key exchange must finalize within n
seconds\n"
" of handshake initiation by any peer
(default=%d).\n"
"--tran-window n : Transition window -- old key can live this many
seconds\n"src/openvpn/options.c +6
-1@@ -870,6 +872,7 @@ init_options(struct options *o, const bool init_gc) o->tls_timeout =2 ; o->renegotiate_bytes =-1 ; o->renegotiate_seconds =3600 ; + o->renegotiate_seconds_min =-1 ; o->handshake_window =60 ; o->transition_window =3600 ; o->ecdh_curve =NULL ;@@ -7999,10 +8002,14 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_packets =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[2 ]) +else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[3 ]) {VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_seconds =positive_atoi (p[1 ]); +if (p[2 ]) + { + options->renegotiate_seconds_min =positive_atoi (p[2 ]); + } }else if (streq (p[0 ],"hand-window" ) && p[1 ] && !p[2 ]) {src/openvpn/options.h +1
-0@@ -548,6 +548,7 @@ struct optionsint renegotiate_bytes;int renegotiate_packets;int renegotiate_seconds; +int renegotiate_seconds_min;/* Data channel key handshake must finalize * within n seconds of handshake initiation. */ src/openvpn/ssl.c +1
-3@@ -2732,9 +2732,9 @@ tls_process(struct tls_multi *multi, && ks->n_packets >= session->opt->renegotiate_packets) || (packet_id_close_to_wrapping(&ks->crypto_options.packet_id.send)))) { - msg(D_TLS_DEBUG_LOW, - "TLS: soft reset sec=%d bytes=" counter_format "/%d pkts=" counter_format "/%d", - (int)(ks->established + session->opt->renegotiate_seconds - now), + msg(D_TLS_DEBUG_LOW, "TLS: soft reset sec=%lld/%d bytes="
counter_formatsrc/openvpn/ssl.c +2
-1+"/%d pkts=" counter_format"/%d" , + (now - ks->established), session->opt->renegotiate_seconds, ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session); --
Quoted 2 lines
2.14.1
doc/openvpn.8 +21 -5
@@ -33,7 +33,7 @@ .\" .ft -- normal face .\" .in +|-{n} -- indent .\" -.TH openvpn 8 "25 August 2016" +.TH openvpn 8 "04 April 2017" .\"********************************************************* .SH NAME openvpn \- secure IP tunnel daemon.
@@ -4958,10 +4958,26 @@ packets sent and received (disabled by default). .\"********************************************************* .TP -.B \-\-reneg\-sec n -Renegotiate data channel key after -.B n -seconds (default=3600). +.B \-\-reneg\-sec max [min] +Renegotiate data channel key after at most +.B max +seconds (default=3600) and at least +.B min +seconds (default is 90% of +.B max +for servers, and equal to +.B max +for clients). + +The effective +.B reneg\-sec +value used is per session pseudo-uniform-randomized between +.B min +and +.B max\fR. + +With the default value of 3600 this results in an effective per session value +in the range of 3240..3600 seconds for servers, or just 3600 for clients. When using dual\-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.
src/openvpn/init.c +14 -1
@@ -2706,7 +2706,20 @@ to.packet_timeout = options->tls_timeout; to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; - to.renegotiate_seconds = options->renegotiate_seconds; +if (options->renegotiate_seconds_min <0 ) + { +/* Add 10% jitter to the reneg-sec of each server connection by default */ +int auto_jitter = options->mode !=MODE_SERVER ?0 : +get_random () %max_int (options->renegotiate_seconds /10 ,1 ); + to.renegotiate_seconds = options->renegotiate_seconds - auto_jitter; + } +else + { +/* Add user-specific jitter to the reneg-sec of each connection */ + to.renegotiate_seconds = options->renegotiate_seconds - + (get_random () %max_int (options->renegotiate_seconds + - options->renegotiate_seconds_min,1 )); + } to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;
src/openvpn/options.c +9 -2
@@ -604,7 +604,9 @@" if no ACK from remote within n seconds (default=%d).\n" "--reneg-bytes n : Renegotiate data chan. key after n bytes sent and recvd.\n" "--reneg-pkts n : Renegotiate data chan. key after n packets sent and recvd.\n" -"--reneg-sec n : Renegotiate data chan. key after n seconds (default=%d).\n" +"--reneg-sec max [min] : Renegotiate data chan. key after at most max (default=%d)\n" +" and at least min (defaults to 90%% of max on servers and equal\n" +" to max on clients).\n" "--hand-window n : Data channel key exchange must finalize within n seconds\n" " of handshake initiation by any peer (default=%d).\n" "--tran-window n : Transition window -- old key can live this many seconds\n"
@@ -872,6 +874,7 @@ o->tls_timeout =2 ; o->renegotiate_bytes =-1 ; o->renegotiate_seconds =3600 ; + o->renegotiate_seconds_min =-1 ; o->handshake_window =60 ; o->transition_window =3600 ; o->ecdh_curve =NULL ;
@@ -8018,10 +8021,14 @@VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_packets =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[2 ]) +else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[3 ]) {VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_seconds =positive_atoi (p[1 ]); +if (p[2 ]) + { + options->renegotiate_seconds_min =positive_atoi (p[2 ]); + } }else if (streq (p[0 ],"hand-window" ) && p[1 ] && !p[2 ]) {
src/openvpn/options.h +1 -0
@@ -549,6 +549,7 @@int renegotiate_bytes;int renegotiate_packets;int renegotiate_seconds; +int renegotiate_seconds_min;/* Data channel key handshake must finalize * within n seconds of handshake initiation. */
src/openvpn/ssl.c +2 -2
@@ -2733,8 +2733,8 @@ || (packet_id_close_to_wrapping(&ks->crypto_options.packet_id.send)))) {msg (D_TLS_DEBUG_LOW , -"TLS: soft reset sec=%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , - (int )(ks->established + session->opt->renegotiate_seconds - now), +"TLS: soft reset sec=%d/%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , + (int )(now - ks->established), session->opt->renegotiate_seconds, ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session);
Re: [Openvpn-devel] [PATCH v3] Add per session pseudo-random jitter to --reneg-sec intervals
Hi,
Quoted 46 lines · Simon Matter
Hi Steffan,
While running your v3 version of the patch I found an issue with the modified logging. It gives the following error while building
gcc -DHAVE_CONFIG_H -I. -I../.. -I../../include -I../../include
(quoted diff) +0
-4-I../../src/compat -DPLUGIN_LIBDIR=\"/usr/lib64/openvpn/plugins\" -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -std=c99 -c -o ssl.o ssl.c
ssl.c: In function 'tls_process':
ssl.c:2735:9: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'time_t' [-Wformat=]
msg(D_TLS_DEBUG_LOW, "TLS: soft reset sec=%lld/%d bytes="counter_format^and the log output is also corrupted
TLS: soft reset sec=14774687501680/336605974 bytes=18446744069414584320/581335 pkts=0/0
TLS: soft reset sec=14787572403571/77375 bytes=18446744069414584320/885 pkts=0/-1080308296
TLS: soft reset sec=14164802145506/6746662 bytes=18446744069414584320/86778 pkts=0/0
TLS: soft reset sec=15264313773538/186529 bytes=18446744069414584320/1108 pkts=0/13935244Please have a look at the attached v4 patch which fixes it for me. The output is now
TLS: soft reset sec=3474/3474 bytes=8470454/-1 pkts=108673/0
TLS: soft reset sec=3489/3489 bytes=429623769/-1 pkts=656033/0
TLS: soft reset sec=3517/3517 bytes=89365/-1 pkts=877/0
TLS: soft reset sec=3537/3537 bytes=206142/-1 pkts=1123/0which seems reasonable to me.
In the patch I've modified the lines below:msg(D_TLS_DEBUG_LOW,
- "TLS: soft reset sec=%d bytes="counter_format"/%d pkts="counter_format"/%d",
- (int)(ks->established +session->opt->renegotiate_seconds-
now),
+ "TLS: soft reset sec=%d/%d bytes="counter_format"/%d pkts="counter_format"/%d",
+ (int)(now -ks->established),session->opt->renegotiate_seconds,
Quoted 4 lines
ks->n_bytes, session->opt->renegotiate_bytes,I'm not a developer and not a git user, so please accept my hand crafted patch work :-)
Uch. Good find. Since we recently decided that the right way to print a time_t is to cast to long long and use the %lld format specifier, I wanted to do that here too. I did the latter, but forgot the first and didn't notice because on my x64 system time_t actually *is* a long long (so no compiler warnings).
I'll send a follow-up version that incorporates the comments of both Simon's, probably tomorrow.
-Steffan
PATCH v4 1/1 Add per session pseudo-random jitter to --reneg-sec intervals
In reply to Simon MatterFrom: Simon Matter <[email protected]...>
While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is still room for improvement in our use case.
It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things worse, we realized that most renegotiation procedures took place at almost the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.
I've created attached patch to add a per session pseudo-random component to the --reneg-sec intervals so that renegotiation is evenly spread over time. It is configured by simply adding a second value to --reneg-sec as described in the --help text:
--reneg-sec max [min] : Renegotiate data chan. key after at most max
(default=3600) and at least min (default 90% of max on servers and equal to max on clients).
The jitter is only enabled by default on servers, because the actual reneg time is min(reneg_server, reneg_client). Introducing jitter at both ends would bias the actual reneg time to the min value.
Note that the patch also slightly changes the log output to show the sec value in the same way as the bytes/pkts values:
TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0
The idea and first versions of this patch are from Simon Matter. Steffan Karger later incorporated the mailing list comments into this patch. So credits go to Simon, and all bugs are Steffan's fault ;-)
---
v3: incorporate comments from openvpn-devel@, don't add jitter by
default on the client side.
v4: fix printing of reneg interval, clarify/typofix comments
doc/openvpn.8 | 26 +++++++++++++++++++++----- src/openvpn/init.c | 15 ++++++++++++++- src/openvpn/options.c | 11 +++++++++-- src/openvpn/options.h | 1 + src/openvpn/ssl.c | 6 +++--- 5 files changed, 48 insertions(+), 11 deletions(-)
doc/openvpn.8 +21 -5
@@ -33,7 +33,7 @@ .\" .ft -- normal face .\" .in +|-{n} -- indent .\" -.TH openvpn 8 "25 August 2016" +.TH openvpn 8 "04 April 2017" .\"********************************************************* .SH NAME openvpn \- secure IP tunnel daemon.
@@ -4957,10 +4957,26 @@ Renegotiate data channel key after packets sent and received (disabled by default). .\"********************************************************* .TP -.B \-\-reneg\-sec n -Renegotiate data channel key after -.B n -seconds (default=3600). +.B \-\-reneg\-sec max [min] +Renegotiate data channel key after at most +.B max +seconds (default=3600) and at least +.B min +seconds (default is 90% of +.B max +for servers, and equal to +.B max +for clients). + +The effective +.B reneg\-sec +value used is per session pseudo-uniform-randomized between +.B min +and +.B max\fR. + +With the default value of 3600 this results in an effective per session value +in the range of 3240..3600 seconds for servers, or just 3600 for clients. When using dual\-factor authentication, note that this default value may cause the end user to be challenged to reauthorize once per hour.
src/openvpn/init.c +14 -1
@@ -2693,7 +2693,20 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.packet_timeout = options->tls_timeout; to.renegotiate_bytes = options->renegotiate_bytes; to.renegotiate_packets = options->renegotiate_packets; - to.renegotiate_seconds = options->renegotiate_seconds; +if (options->renegotiate_seconds_min <0 ) + { +/* Add 10% jitter to reneg-sec by default (server side only) */ +int auto_jitter = options->mode !=MODE_SERVER ?0 : +get_random () %max_int (options->renegotiate_seconds /10 ,1 ); + to.renegotiate_seconds = options->renegotiate_seconds - auto_jitter; + } +else + { +/* Add user-specified jitter to reneg-sec */ + to.renegotiate_seconds = options->renegotiate_seconds - + (get_random () %max_int (options->renegotiate_seconds + - options->renegotiate_seconds_min,1 )); + } to.single_session = options->single_session; to.mode = options->mode; to.pull = options->pull;
src/openvpn/options.c +9 -2
@@ -603,7 +603,9 @@ static const char usage_message[] =" if no ACK from remote within n seconds (default=%d).\n" "--reneg-bytes n : Renegotiate data chan. key after n bytes sent and recvd.\n" "--reneg-pkts n : Renegotiate data chan. key after n packets sent and recvd.\n" -"--reneg-sec n : Renegotiate data chan. key after n seconds (default=%d).\n" +"--reneg-sec max [min] : Renegotiate data chan. key after at most max (default=%d)\n" +" and at least min (defaults to 90%% of max on servers and equal\n" +" to max on clients).\n" "--hand-window n : Data channel key exchange must finalize within n seconds\n" " of handshake initiation by any peer (default=%d).\n" "--tran-window n : Transition window -- old key can live this many seconds\n"
@@ -870,6 +872,7 @@ init_options(struct options *o, const bool init_gc) o->tls_timeout =2 ; o->renegotiate_bytes =-1 ; o->renegotiate_seconds =3600 ; + o->renegotiate_seconds_min =-1 ; o->handshake_window =60 ; o->transition_window =3600 ; o->ecdh_curve =NULL ;
@@ -8001,10 +8004,14 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_packets =positive_atoi (p[1 ]); } -else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[2 ]) +else if (streq (p[0 ],"reneg-sec" ) && p[1 ] && !p[3 ]) {VERIFY_PERMISSION (OPT_P_TLS_PARMS ); options->renegotiate_seconds =positive_atoi (p[1 ]); +if (p[2 ]) + { + options->renegotiate_seconds_min =positive_atoi (p[2 ]); + } }else if (streq (p[0 ],"hand-window" ) && p[1 ] && !p[2 ]) {
src/openvpn/options.h +1 -0
@@ -548,6 +548,7 @@ struct optionsint renegotiate_bytes;int renegotiate_packets;int renegotiate_seconds; +int renegotiate_seconds_min;/* Data channel key handshake must finalize * within n seconds of handshake initiation. */
src/openvpn/ssl.c +3 -3
@@ -2732,9 +2732,9 @@ tls_process(struct tls_multi *multi, && ks->n_packets >= session->opt->renegotiate_packets) || (packet_id_close_to_wrapping(&ks->crypto_options.packet_id.send)))) { -msg (D_TLS_DEBUG_LOW , -"TLS: soft reset sec=%d bytes=" counter_format"/%d pkts=" counter_format"/%d" , - (int )(ks->established + session->opt->renegotiate_seconds - now), +msg (D_TLS_DEBUG_LOW ,"TLS: soft reset sec=%d/%d bytes=" counter_format +"/%d pkts=" counter_format"/%d" , + (int ) (now - ks->established), session->opt->renegotiate_seconds, ks->n_bytes, session->opt->renegotiate_bytes, ks->n_packets, session->opt->renegotiate_packets);key_state_soft_reset (session);
Signature · 1 line
2.14.1
Re: [Openvpn-devel] [PATCH v4] Add per session pseudo-random jitter to --reneg-sec intervals
Hi,
Quoted 36 lines
From: Simon Matter <[email protected]...>
While we were suffering from the "TLS Renegotiation Slowdown" bug here
https://community.openvpn.net/openvpn/ticket/854 we realized that there is still room for improvement in our use case.It appears that TLS renegotiation is getting more and more expensive in terms of CPU cycles with recent changes for more security. To make things worse, we realized that most renegotiation procedures took place at almost the same time and increased the CPU load too much during these periods. That's especially true on large, multi-instance openvpn setups.
I've created attached patch to add a per session pseudo-random component to
the --reneg-sec intervals so that renegotiation is evenly spread over time.
It is configured by simply adding a second value to --reneg-sec as described in the --help text:--reneg-sec max [min] : Renegotiate data chan. key after at most max
(default=3600) and at least min (default 90% of max on servers and equal to max on clients).The jitter is only enabled by default on servers, because the actual reneg time is
min(reneg_server, reneg_client). Introducing jitter at both ends would bias the actual reneg time to the min value.Note that the patch also slightly changes the log output to show the sec value in the same way as the bytes/pkts values:
TLS: soft reset sec=3084/3084 bytes=279897/-1 pkts=1370/0
The idea and first versions of this patch are from Simon Matter. Steffan Karger later incorporated the mailing list comments into this patch. So credits go to Simon, and all bugs are Steffan's fault ;-)
Quoted 6 lines
Signed-off-by Simon Matter <[email protected]...>Signed-off-by Steffan Karger <[email protected]...>---
v3: incorporate comments from openvpn-devel@, don't add jitter by
default on the client side.
v4: fix printing of reneg interval, clarify/typofix comments
I've tested it and it works as expected, thanks!
Regards,
Simon
[Openvpn-devel] [PATCH applied] Re: Add per session pseudo-random jitter to --reneg-sec intervals
In reply to Steffan KargerACK. The change makes sense, the actual functionality is what the discussion converged to, and the code looks sane (no long long, but it isn't printing a time_t either :-) ).
Your patch has been applied to the master branch.
commit dd99646347bc5461fa83b0e62114550504bb128f
Author: Simon Matter Date: Thu Nov 16 15:09:58 2017 +0100
Add per session pseudo-random jitter to --reneg-sec intervals
Signed-off-by: Simon Matter <[email protected]...>
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg15888.html
Signed-off-by: Gert Doering <[email protected]...>for patchwork:
--
kind regards,
Gert Doering