From: "Bluca (Code Review)" Date: Wed, 25 Mar 2026 22:31:14 +0000 References: Reply-To: luca.boccassi@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <1d6c3e9d295104bc4ebae06fb0bde6a37d6519f7-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="bJwtOixZJEA="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: management: add password-base64 multi-line input for passwords List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --bJwtOixZJEA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1593?usp=3Demail to review the following change. Change subject: management: add password-base64 multi-line input for passwo= rds ...................................................................... management: add password-base64 multi-line input for passwords Allow management clients to send long passwords via the usual multi-line base64 encoded protocol. A client sends a 'password-base64 ' line, followed by as many lines (each up to 1024 bytes) as needed, in base64 encoded format, terminated by 'END'. This is useful when a password is a JIT-generated use-once token. Change-Id: Ib99f171fb69d51f2260b44edf8ebe21ac958f233 Signed-off-by: Luca Boccassi --- M doc/management-notes.txt M src/openvpn/manage.c M src/openvpn/manage.h 3 files changed, 88 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1593/1 diff --git a/doc/management-notes.txt b/doc/management-notes.txt index 41e2a91..f3373d4 100644 --- a/doc/management-notes.txt +++ b/doc/management-notes.txt @@ -313,6 +313,21 @@ The escaping rules are the same as for the config file. See the "Command Parsing" section below for more info. + If the password is too long to fit in a single command line + (longer than 256 bytes), the management interface client should + use the password-base64 command with multi-line base64 format + instead: + + password-base64 "Auth" + [BASE64_PASSWORD_LINE] + ... + END + + In this format, the password is base64-encoded and split across + multiple lines, followed by END. Each line can be at most 1024 + bytes. This is the same format used by pk-sig and certificate + commands. + The PASSWORD real-time message type can also be used to indicate password or other types of authentication failure: diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index df72f15..c4db3b0 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -31,6 +31,7 @@ #include "error.h" #include "fdmisc.h" #include "options.h" +#include "base64.h" #include "sig.h" #include "event.h" #include "otime.h" @@ -107,6 +108,8 @@ msg(M_CLIENT, " where action is reply string."= ); msg(M_CLIENT, "net : (Windows only) Show network in= fo and routing table."); msg(M_CLIENT, "password type p : Enter password p for a queried= OpenVPN password."); + msg(M_CLIENT, "password-base64 type : Enter password for a queried O= penVPN password"); + msg(M_CLIENT, " base64-encoded on subsequent l= ines followed by END."); msg(M_CLIENT, "remote type [host port] : Override remote directive, ty= pe=3DACCEPT|MOD|SKIP."); msg(M_CLIENT, "remote-entry-count : Get number of available remote= entries."); msg(M_CLIENT, "remote-entry-get i|all [j]: Get remote entry at index = =3D i to to j-1 or all."); @@ -1012,6 +1015,41 @@ } } +/** + * Enter multi-line base64 mode for receiving a password that exceeds the + * single-line parameter size limit. The management client sends: + * + * password TYPE + * + * + * ... + * END + * + * @param man The management interface struct + * @param type The type of password being entered (e.g. "Auth", "= TLS-Auth", etc) + */ +static void +man_query_password_base64(struct management *man, const char *type) +{ + const bool needed =3D ((man->connection.up_query_mode =3D=3D UP_QUERY_= PASS + || man->connection.up_query_mode =3D=3D UP_QUERY= _USER_PASS) + && man->connection.up_query_type); + if (!needed) + { + msg(M_CLIENT, "ERROR: no password is currently needed at this time= "); + return; + } + if (!man->connection.up_query_type || !streq(man->connection.up_query_= type, type)) + { + msg(M_CLIENT, "ERROR: password of type '%s' entered, but we need o= ne of type '%s'", + type, man->connection.up_query_type); + return; + } + struct man_connection *mc =3D &man->connection; + mc->in_extra_cmd =3D IEC_PASSWORD; + in_extra_reset(mc, IER_NEW); +} + static void in_extra_dispatch(struct management *man) { @@ -1045,6 +1083,33 @@ man->connection.ext_cert_input =3D man->connection.in_extra; man->connection.in_extra =3D NULL; return; + + case IEC_PASSWORD: + { + char decoded[USER_PASS_LEN]; + CLEAR(decoded); + + buffer_list_aggregate(man->connection.in_extra, + OPENVPN_BASE64_LENGTH(USER_PASS_LEN)); + struct buffer *buf =3D buffer_list_peek(man->connection.in_ext= ra); + + if (buf && BLEN(buf) > 0) + { + int len =3D openvpn_base64_decode(BSTR(buf), decoded, + USER_PASS_LEN - 1); + if (len < 0) + { + msg(M_CLIENT, "ERROR: could not base64-decode password= "); + break; + } + decoded[len] =3D '\0'; + } + + man_query_password(man, man->connection.up_query_type, + decoded); + secure_memzero(decoded, sizeof(decoded)); + break; + } } in_extra_reset(&man->connection, IER_RESET); } @@ -1596,6 +1661,13 @@ man_query_password(man, p[1], p[2]); } } + else if (streq(p[0], "password-base64")) + { + if (man_need(man, p, 1, 0)) + { + man_query_password_base64(man, p[1]); + } + } else if (streq(p[0], "forget-passwords")) { man_forget_passwords(man); diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 38f437f..797021d 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -296,6 +296,7 @@ #define IEC_RSA_SIGN 3 #define IEC_CERTIFICATE 4 #define IEC_PK_SIGN 5 +#define IEC_PASSWORD 6 int in_extra_cmd; struct buffer_list *in_extra; unsigned long in_extra_cid; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1593?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ib99f171fb69d51f2260b44edf8ebe21ac958f233 Gerrit-Change-Number: 1593 Gerrit-PatchSet: 1 Gerrit-Owner: Bluca Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --bJwtOixZJEA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

Bluca would like plaisthos to review this change.

V= iew Change

management: add password-base64 multi-line =
input for passwords

Allow management clients to send long passwords = via the
usual multi-line base64 encoded protocol.

A client sends = a 'password-base64 <type>' line, followed by
as many lines= (each up to 1024 bytes) as needed, in base64
encoded format, terminated= by 'END'.

This is useful when a password is a JIT-generated= use-once
token.

Change-Id: Ib99f171fb69d51f2260b44edf8ebe21ac958= f233
Signed-off-by: Luca Boccassi <luca.boccassi@...277...>
---=
M doc/management-notes.txt
M src/openvpn/manage.c
M src/openvpn/m= anage.h
3 files changed, 88 insertions(+), 0 deletions(-)

<= pre class=3D"blocks" style=3D"font-family: monospace,monospace; white-space= : pre-wrap;">git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/9= 3/1593/1
diff --git a/doc/management-notes.txt b/doc/management-not=
es.txt
index 41e2a91..f3373d4 100644
--- a/= doc/management-notes.txt
+++ b/doc/management-notes.txt
@@ -313,6 +313,21 @@
The escaping rules are= the same as for the config file.
See the "Command = Parsing" section below for more info.

+ If the password is too long to f= it in a single command line

+ (longer than 256 bytes), the management interface client should
+ use the password-ba= se64 command with multi-line base64 format
+ instead:
+
+ p= assword-base64 "Auth"
+ [BASE64_PASSWORD_LINE]
+ ...
+ END
+
+ In this format, the pa= ssword is base64-encoded and split across
+ multiple lines, followed by END. Each line can be = at most 1024
+ bytes= . This is the same format used by pk-sig and certificate
+ commands.
+
The PASSWORD real-time me= ssage type can also be used to
indicate password or othe= r types of authentication failure:

diff -= -git a/src/openvpn/manage.c b/src/openvpn/manage.c
index df= 72f15..c4db3b0 100644
--- a/src/openvpn/manage.c
= +++ b/src/openvpn/manage.c
@@ -31,6 +31,7 @@ #include "error.h"
#include "fdmis= c.h"
#include "options.h"
+#include "base64.h"<= br> #include "sig.h"
#include "event.= h"
#include "otime.h"
@@ -1= 07,6 +108,8 @@
msg(M_CLIENT, " = where action is reply string.");
msg(M_CLIE= NT, "net : (Windows only) Show network info and rou= ting table.");
msg(M_CLIENT, "password type = p : Enter password p for a queried OpenVPN password.");<= br>+ msg(M_CLIENT, "pas= sword-base64 type : Enter password for a queried OpenVPN password");=
+ msg(M_CLIENT, &= quot; base64-encoded on subsequent lines followed b= y END.");
msg(M_CLIENT, "remote type [host p= ort] : Override remote directive, type=3DACCEPT|MOD|SKIP."); msg(M_CLIENT, "remote-entry-count : Get number of avai= lable remote entries.");
msg(M_CLIENT, "remo= te-entry-get i|all [j]: Get remote entry at index =3D i to to j-1 or all.&= quot;);
@@ -1012,6 +1015,41 @@
}
}

+/**
+ * E= nter multi-line base64 mode for receiving a password that exceeds the
+ * single-line parameter = size limit. The management client sends:
+ *
+ * password TYPE
+ * <base64-encoded password line 1>
+ * <base64-encoded password line 2><= br>+ * ...
+ * END
+ *
+ * @param man The management interface struct
+ * @param type The type= of password being entered (e.g. "Auth", "TLS-Auth", et= c)

+ */
+static void

+man_query_password_base64(struct manageme= nt *man, const char *type)
+{
+ const b= ool needed =3D ((man->connection.up_query_mode =3D=3D UP_QUERY_PASS
+ = || man->connection.up_query_mode =3D=3D UP_QUERY_USER_PASS)
= + &= & man->connection.up_query_type);
+ if (!needed)
+ {
+ msg(M_CLIENT, "ERROR: no password is currently needed at t= his time");
+ = return;
+ }
+ if (!man->conn= ection.up_query_type || !streq(man->connection.up_query_type, type))
+ {
+ msg(M_CLIENT, "ERROR: pa= ssword of type '%s' entered, but we need one of type '%s'&q= uot;,
+ ty= pe, man->connection.up_query_type);
+ return;
+ }
= + struct man_connection *mc =3D &man->connection;
+ mc->in_extra_cmd =3D IEC_PAS= SWORD;

+ in_extra_= reset(mc, IER_NEW);
+= }
+
= static void
in_extra_dispatch(struct management *man)
{
@@ -1045,6 +1083,33 @@
= man->connection.ext_cert_input =3D man->connection.in_extra;<= /span>
man->connection.in_extra =3D NULL; return;
+
+ ca= se IEC_PASSWORD:
+ = {
+ c= har decoded[USER_PASS_LEN];
+ CLEAR(decoded);
+
+ = buffer_list_aggregate(man->connection.in_extra,
+ O= PENVPN_BASE64_LENGTH(USER_PASS_LEN));

+ struct buffer *buf =3D buffer_list_peek(man-&= gt;connection.in_extra);
+
+ if= (buf && BLEN(buf) > 0)
+ {
+ int len =3D openvpn_base64_decode(BSTR(buf), decod= ed,
+ = USER_PASS_LEN - 1);
+ if (len < 0)+ {
<= span style=3D"color: hsl(120, 100%, 40%);">+ msg(M_CLIEN= T, "ERROR: could not base64-decode password");

+ break;
<= span style=3D"color: hsl(120, 100%, 40%);">+ }

+ decoded[len] =3D = '\0';

+ = }
+
<= span style=3D"color: hsl(120, 100%, 40%);">+ man_query_password(= man, man->connection.up_query_type,

+ decoded);
+ secure_memzero(decoded,= sizeof(decoded));

+ = break;
+ = }
}
in_extra_reset(&man= ->connection, IER_RESET);
}
@@ -1596,6 = +1661,13 @@
man_query_password(man, p[1], p[2]= );
}
}
+ else if (streq(p[0], "password-b= ase64"))
+ {<= /span>
+ if (man_need= (man, p, 1, 0))
+ = {
+ ma= n_query_password_base64(man, p[1]);
+ }
+ }
else if (streq(p[0], "forget-password= s"))
{
man_forget_passwo= rds(man);
diff --git a/src/openvpn/manage.h b/src/openvpn/m= anage.h
index 38f437f..797021d 100644
--- a= /src/openvpn/manage.h
+++ b/src/openvpn/manage.h
= @@ -296,6 +296,7 @@
#define IEC_RSA_SIGN 3=
#define IEC_CERTIFICATE 4
#define IEC_PK_SIGN = 5
+#define IEC_PAS= SWORD 6
int in_extra_cmd;
stru= ct buffer_list *in_extra;
unsigned long in_extra_cid;<= /span>

To view, visit change 1593. To unsubscribe,= or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib99f171fb69d51f2260b44edf8e= be21ac958f233
Gerrit-Change-Number: 1593
Gerrit-PatchSet: 1
Gerrit-Owner: Bluca <luca.boccassi@...1663...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --bJwtOixZJEA=--