From: "reynir (Code Review)" Date: Thu, 16 May 2024 08:36:51 +0000 In-Reply-To: References: Reply-To: reynir@...2756..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="od/iRT8xvZQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Only schedule_exit() once List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --od/iRT8xvZQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos, reynir. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=3Demail to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos The change is no longer submittable: Code-Review and checks~ChecksSubmitRul= e are unsatisfied now. Change subject: Only schedule_exit() once ...................................................................... Only schedule_exit() once If an exit has already been scheduled we should not schedule it again. Otherwise, the exit signal is never emitted if the peer reschedules the exit before the timeout occurs. schedule_exit() now only takes the context as argument. The signal is hard coded to SIGTERM, and the interval is read directly from the context options. Furthermore, schedule_exit() now returns a bool signifying whether an exit was scheduled; false if exit is already scheduled. The call sites are updated accordingly. A notable difference is that management is only notified *once* when an exit is scheduled - we no longer notify management on redundant exit. This patch was assigned a CVE number after already reviewed and ACKed, because it was discovered that a misbehaving client can use the (now fixed) server behaviour to avoid being disconnected by means of a managment interface "client-kill" command - the security issue here is "client can circumvent security policy set by management interface". This only affects previously authenticated clients, and only management client-kill, so normal renegotion / AUTH_FAIL ("your session ends") is not affected. CVE: 2024-28882 Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661 Signed-off-by: Reynir Bj=C3=B6rnsson --- M src/openvpn/forward.c M src/openvpn/forward.h M src/openvpn/push.c 3 files changed, 19 insertions(+), 10 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/555/3 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 8d10f25..01165b2 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -514,17 +514,24 @@ } /* - * Schedule a signal n_seconds from now. + * Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds fr= om now. */ -void -schedule_exit(struct context *c, const int n_seconds, const int signal) +bool +schedule_exit(struct context *c) { + const int n_seconds =3D c->options.scheduled_exit_interval; + /* don't reschedule if already scheduled. */ + if (event_timeout_defined(&c->c2.scheduled_exit)) + { + return false; + } tls_set_single_session(c->c2.tls_multi); update_time(); reset_coarse_timers(c); event_timeout_init(&c->c2.scheduled_exit, n_seconds, now); - c->c2.scheduled_exit_signal =3D signal; + c->c2.scheduled_exit_signal =3D SIGTERM; msg(D_SCHED_EXIT, "Delayed exit in %d seconds", n_seconds); + return true; } /* diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index 6fb5a18..422c591 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -303,7 +303,7 @@ void process_ip_header(struct context *c, unsigned int flags, struct buffe= r *buf); -void schedule_exit(struct context *c, const int n_seconds, const int signa= l); +bool schedule_exit(struct context *c); static inline struct link_socket_info * get_link_socket_info(struct context *c) diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 1b406b9..17e7e80 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -204,7 +204,11 @@ * */ if (c->options.mode =3D=3D MODE_SERVER) { - schedule_exit(c, c->options.scheduled_exit_interval, SIGTERM); + if (!schedule_exit(c)) + { + /* Return early when we don't need to notify management */ + return; + } } else { @@ -391,7 +395,7 @@ void send_auth_failed(struct context *c, const char *client_reason) { - if (event_timeout_defined(&c->c2.scheduled_exit)) + if (!schedule_exit(c)) { msg(D_TLS_DEBUG, "exit already scheduled for context"); return; @@ -401,8 +405,6 @@ static const char auth_failed[] =3D "AUTH_FAILED"; size_t len; - schedule_exit(c, c->options.scheduled_exit_interval, SIGTERM); - len =3D (client_reason ? strlen(client_reason)+1 : 0) + sizeof(auth_fa= iled); if (len > PUSH_BUNDLE_SIZE) { @@ -492,7 +494,7 @@ void send_restart(struct context *c, const char *kill_msg) { - schedule_exit(c, c->options.scheduled_exit_interval, SIGTERM); + schedule_exit(c); send_control_channel_string(c, kill_msg ? kill_msg : "RESTART", D_PUSH= ); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/555?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I9457f005f4ba970502e6b667d9dc4299a588d661 Gerrit-Change-Number: 555 Gerrit-PatchSet: 3 Gerrit-Owner: reynir Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-Reviewer: reynir Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: reynir Gerrit-MessageType: newpatchset --od/iRT8xvZQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos, reynir. =

reynir uploaded patch set #3 to this change.

View Change

The following approvals got outdated and were removed: Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos

The change = is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsat= isfied now.

Only schedule_exit() once

If an exit has already been sc= heduled we should not schedule it again.
Otherwise, the exit signal is n= ever emitted if the peer reschedules the
exit before the timeout occurs.=

schedule_exit() now only takes the context as argument. The signal = is
hard coded to SIGTERM, and the interval is read directly from the
= context options.

Furthermore, schedule_exit() now returns a bool sig= nifying whether an
exit was scheduled; false if exit is already schedule= d. The call sites
are updated accordingly. A notable difference is that = management is only
notified *once* when an exit is scheduled - we no lon= ger notify
management on redundant exit.

This patch was assigned = a CVE number after already reviewed and ACKed,
because it was discovered= that a misbehaving client can use the (now
fixed) server behaviour to a= void being disconnected by means of a
managment interface "client-k= ill" command - the security issue here is
"client can circumve= nt security policy set by management interface".

This only affe= cts previously authenticated clients, and only management
client-kill, s= o normal renegotion / AUTH_FAIL ("your session ends") is not
a= ffected.

CVE: 2024-28882

Change-Id: I9457f005f4ba970502e6b667= d9dc4299a588d661
Signed-off-by: Reynir Bj=C3=B6rnsson <reynir@...2800...= ...>
---
M src/openvpn/forward.c
M src/openvpn/forward.h
M s= rc/openvpn/push.c
3 files changed, 19 insertions(+), 10 deletions(-)
=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/555/=
3
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c=

index 8d10f25..01165b2 100644
--- a/src/openvpn/f= orward.c
+++ b/src/openvpn/forward.c
@@ -51= 4,17 +514,24 @@
}

/*
- * Schedule a signal n_s= econds from now.
+ * = Schedule a SIGTERM signal c->options.scheduled_exit_interval seconds fro= m now.
*/
-void
-schedule_ex= it(struct context *c, const int n_seconds, const int signal)
+bool

+schedule_exit(struct context *c)
= {
+ const int n_s= econds =3D c->options.scheduled_exit_interval;
+ /* don't reschedule if already schedu= led. */
+ if (even= t_timeout_defined(&c->c2.scheduled_exit))
+ {
+ return false;
+ }
tls_set_single_session(c->c2= .tls_multi);
update_time();
reset= _coarse_timers(c);
event_timeout_init(&c->c2.sc= heduled_exit, n_seconds, now);
- c->c2.scheduled_exit_signal =3D signal;
+ c->c2.scheduled_exit_signal =3D = SIGTERM;
msg(D_SCHED_EXIT, "Delayed exit in %d se= conds", n_seconds);
+ return true;
}

= /*
diff --git a/src/openvpn/forward.h b/src/openvpn/forwar= d.h
index 6fb5a18..422c591 100644
--- a/src= /openvpn/forward.h
+++ b/src/openvpn/forward.h
@@ -303,7 +303,7 @@

void process_ip_= header(struct context *c, unsigned int flags, struct buffer *buf);
-void schedul= e_exit(struct context *c, const int n_seconds, const int signal);+bool schedule_exit(struct con= text *c);

static inline struct link_sock= et_info *
get_link_socket_info(struct context *c)diff --git a/src/openvpn/push.c b/src/openvpn/push.c
index 1b406b9..17e7e80 100644
--- a/src/openvpn/push.c

+++ b/src/openvpn/push.c
@@ -204,7 +204,11 @@=
* */
if (c->options.mode =3D= =3D MODE_SERVER)
{
- schedule_exit(c, c->options.scheduled_exit_int= erval, SIGTERM);
+ = if (!schedule_exit(c))
+ {
+ /* Retu= rn early when we don't need to notify management */
+ return;
+ }
}
el= se
{
@@ -391,7 +395,7 @@
void
send_auth_failed(struct context *c, const char *c= lient_reason)
{
- if (event_timeout_defined(&c->c2.scheduled_exit))

+ if (!schedule_exit(= c))
{
msg(D_TLS_DEBUG, "= exit already scheduled for context");
return;=
@@ -401,8 +405,6 @@
static const char= auth_failed[] =3D "AUTH_FAILED";
size_t len= ;

- = schedule_exit(c, c->options.scheduled_exit_interval, SIGTERM);<= br>-
len =3D= (client_reason ? strlen(client_reason)+1 : 0) + sizeof(auth_failed);
if (len > PUSH_BUNDLE_SIZE)
{
@@ -492,7 +494,7 @@
void
send_= restart(struct context *c, const char *kill_msg)
{<= br>- schedule_exit(c, c->op= tions.scheduled_exit_interval, SIGTERM);
+ schedule_exit(c);
send_contro= l_channel_string(c, kill_msg ? kill_msg : "RESTART", D_PUSH);
}


To vi= ew, visit change 555. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9457f005f4ba970502e6b667d9d= c4299a588d661
Gerrit-Change-Number: 555
Gerrit-PatchSet: 3
Gerrit-Owner: reynir <reynir@...2756...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-Reviewer: reynir <reynir@...2756...&= gt;
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: reynir <reynir@...2756...= >
Gerrit-MessageType: newpatchset
--od/iRT8xvZQ=--