From: "Bluca (Code Review)" Date: Sat, 28 Mar 2026 16:30:58 +0000 In-Reply-To: References: Reply-To: luca.boccassi@...277..., arne-openvpn@...1227..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net Message-ID: <325ff3f2e16bb58c8da2311f1e4bd2991a2167c8-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="5PR9vfv3CvA="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: management: add base64 multi-line input for passwords List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , selvanair Cc: openvpn-devel --5PR9vfv3CvA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: Bluca, plaisthos. Hello plaisthos, selvanair, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1593?usp=3Demail to look at the new patch set (#2). Change subject: management: add base64 multi-line input for passwords ...................................................................... management: add base64 multi-line input for passwords Allow management clients to send long passwords via the usual multi-line base64 encoded protocol. A client declares MCV 4 support and sends a 'password ' 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. Declare management version 6 for this feature. 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, 104 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1593/2 diff --git a/doc/management-notes.txt b/doc/management-notes.txt index 41e2a91..ac7c608 100644 --- a/doc/management-notes.txt +++ b/doc/management-notes.txt @@ -313,6 +313,22 @@ 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 multi-line base64 format instead. This requires that + the management client has announced version > 3 via the + "version" command: + + password "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. Requires OpenVPN 2.6+ management version > 6. + 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..b0b528f 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" @@ -70,6 +71,7 @@ MCV_DEFAULT =3D 1, MCV_PKSIGN =3D 2, MCV_PKSIGN_ALG =3D 3, + MCV_MULTILINE_PASSWORD =3D 4, }; struct management *management; /* GLOBAL */ @@ -107,6 +109,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 type : (version >3) Enter password ba= se64-encoded on"); + msg(M_CLIENT, " subsequent lines followed by E= ND."); 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 +1016,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", "= Private Key", 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 +1084,40 @@ 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) + 1= 024); + struct buffer *buf =3D buffer_list_peek(man->connection.in_ext= ra); + + if (buf && BLEN(buf) > 0) + { + if (OPENVPN_BASE64_DECODED_LENGTH(BLEN(buf)) >=3D USER_PAS= S_LEN) + { + msg(M_CLIENT, "ERROR: password too long"); + break; + } + 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= "); + buf_clear(buf); + break; + } + decoded[len] =3D '\0'; + buf_clear(buf); + } + + man_query_password(man, man->connection.up_query_type, + decoded); + secure_memzero(decoded, sizeof(decoded)); + break; + } } in_extra_reset(&man->connection, IER_RESET); } @@ -1591,9 +1664,20 @@ } else if (streq(p[0], "password")) { - if (man_need(man, p, 2, 0)) + if (man_need(man, p, 1, MN_AT_LEAST)) { - man_query_password(man, p[1], p[2]); + if (p[2]) + { + man_query_password(man, p[1], p[2]); + } + else if (man->connection.client_version >=3D MCV_MULTILINE_PAS= SWORD) + { + man_query_password_base64(man, p[1]); + } + else + { + msg(M_CLIENT, "ERROR: the 'password' command requires 2 pa= rameters"); + } } } else if (streq(p[0], "forget-passwords")) diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 38f437f..c446913 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -50,7 +50,7 @@ #include "socket_util.h" #include "mroute.h" -#define MANAGEMENT_VERSION 5 +#define MANAGEMENT_VERSION 6 #define MANAGEMENT_N_PASSWORD_RETRIES 3 #define MANAGEMENT_LOG_HISTORY_INITIAL_SIZE 100 #define MANAGEMENT_ECHO_BUFFER_SIZE 100 @@ -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: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ib99f171fb69d51f2260b44edf8ebe21ac958f233 Gerrit-Change-Number: 1593 Gerrit-PatchSet: 2 Gerrit-Owner: Bluca Gerrit-Reviewer: plaisthos Gerrit-Reviewer: selvanair Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: Bluca --5PR9vfv3CvA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: Bluca, plaisthos.

Bluca uploaded patch set #2 to this change.

View Change

management: add base64 multi-line input for passwords
Allow management clients to send long passwords via the
usual mult= i-line base64 encoded protocol.

A client declares MCV 4 support and = sends a 'password <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.

Declare management version 6 for this feature.
Change-Id: Ib99f171fb69d51f2260b44edf8ebe21ac958f233
Signed-off-by:= Luca Boccassi <luca.boccassi@...277...>
---
M doc/management-n= otes.txt
M src/openvpn/manage.c
M src/openvpn/manage.h
3 files cha= nged, 104 insertions(+), 3 deletions(-)

git pull=
 ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1593/2
diff=
 --git a/doc/management-notes.txt b/doc/management-notes.txt
index 41e2a91..ac7c608 100644
--- a/doc/management-notes.= txt
+++ b/doc/management-notes.txt
@@ -313,= 6 +313,22 @@
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 comman= d line
+ (longer tha= n 256 bytes), the management interface client should
+ use the multi-line base64 format instea= d. This requires that
+ "version" command:<= /span>
+
+ password "Auth"+ [BASE64_PASSWORD_LINE]
+ ...
+ END

+
+ In this format, the password is base64-encoded and split across=
+ multiple lines, f= ollowed by END. Each line can be at most 1024
+ bytes. This is the same format used by pk-sig= and certificate
+ c= ommands. Requires OpenVPN 2.6+ management version > 6.
+
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..b0b528f 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -31,6 +31,7 @@<= /span>
#include "error.h"
#include &qu= ot;fdmisc.h"
#include "options.h"+#include "base64.h"=
#include "sig.h"
#include &quo= t;event.h"
#include "otime.h"
@@ -70,6 +71,7 @@

MCV_DEFAULT =3D 1,
MCV_PKSIGN =3D 2,

MCV_PKSIGN_ALG =3D 3,<= br>+ MCV_MULTILINE_PASSWORD = =3D 4,
};

struct manage= ment *management; /* GLOBAL */
@@ -107,6 +109,8 @@ msg(M_CLIENT, " where action is r= eply string.");
msg(M_CLIENT, "net = : (Windows only) Show network info and routing table.");
msg(M_CLIENT, "password type p : Enter passwo= rd p for a queried OpenVPN password.");
+ msg(M_CLIENT, "password type : (= version >3) Enter password base64-encoded on");
+ msg(M_CLIENT, " = subsequent lines followed by END.");
ms= g(M_CLIENT, "remote type [host port] : Override remote directive, type= =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 en= try at index =3D i to to j-1 or all.");
@@ -1012,6 +10= 16,41 @@
}
}
=
+/**
+ * Enter multi-line base64 mode for recei= ving a password that exceeds the
+ * single-line parameter size limit. The management client sen= ds:
+ *
+ * password TYPE

+ * <base64-encoded password lin= e 1>
+ * <base= 64-encoded password line 2>
+ * ...
+ = * END
+ *
= + * @param man The ma= nagement interface struct
+ * @param type The type of password being entered (e.g. &quo= t;Auth", "Private Key", etc)
+ */
+static void
+= man_query_password_base64(struct management *man, const char *type)<= br>+{
+ const bool needed =3D ((man->connectio= n.up_query_mode =3D=3D UP_QUERY_PASS
+ || man->connection.up_query_m= ode =3D=3D UP_QUERY_USER_PASS)
+ && man->connection.up_query_= type);
+ if (!need= ed)
+ {
= + msg(M_CLIENT, "ER= ROR: 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' entere= d, but we need one of type '%s'",
+ type, man->connection.up_query_ty= pe);
+ return;=
+ }
+ struct man_connection *mc =3D= &man->connection;
+ mc->in_extra_cmd =3D IEC_PASSWORD;
+ in_extra_reset(mc, IER_NEW);
+}
+
static void
in_ex= tra_dispatch(struct management *man)
{
@@ = -1045,6 +1084,40 @@
man->connection.ext_cer= t_input =3D man->connection.in_extra;
man-&= gt;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= ) + 1024);
+ = struct buffer *buf =3D buffer_list_peek(man->connection.in_extra);
+
+ if (buf && BLEN(buf) = > 0)
+ = {
+ if= (OPENVPN_BASE64_DECODED_LENGTH(BLEN(buf)) >=3D USER_PASS_LEN)+ {
<= span style=3D"color: hsl(120, 100%, 40%);">+ msg(M_CLIEN= T, "ERROR: password too long");

+ break;
+ }
+ int len =3D openvpn_base64_decod= e(BSTR(buf), decoded,
+ USER_PASS_LEN - 1);
+ if (len &= lt; 0)
+ = {
+ = msg(M_CLIENT, "ERROR: could not base64-decode password");
+ bu= f_clear(buf);
+ = break;
= + }
+ = decoded[len] =3D '\0';
+ buf_clear(buf);
+ }
+
+ man_query_password(man, man->connection.up_qu= ery_type,
+ = decoded);
+ secure_memzero(decoded, sizeof(decoded));
= + break;
<= span style=3D"color: hsl(120, 100%, 40%);">+ }

= }
in_extra_reset(&man->connection, IER_RESET);<= /span>
}
@@ -1591,9 +1664,20 @@
= }
else if (streq(p[0], "password"))

{
- = if (man_need(man, p, 2, 0))
+ if (man_need(man, p, 1, MN_AT_LEAST))
= {
- = man_query_password(man, p[1], p[2]);
+ if (p[2])
+ {
+ man_query_password(man, p[1], p[2]);+ }
+ else if (man->conne= ction.client_version >=3D MCV_MULTILINE_PASSWORD)
+ {
+ man_query_password_base64(man, = p[1]);
+ }=
+ else
+ {+ msg(M_CLIENT= , "ERROR: the 'password' command requires 2 parameters");=
+ }
}
}
else if (= streq(p[0], "forget-passwords"))
diff --git a/src= /openvpn/manage.h b/src/openvpn/manage.h
index 38f437f..c44= 6913 100644
--- a/src/openvpn/manage.h
+++ = b/src/openvpn/manage.h
@@ -50,7 +50,7 @@
#= include "socket_util.h"
#include "mroute.h&= quot;

-#define MANAGEMENT_VERSION 5
+#define MANAGEMENT_VERSION 6
#define MANAGEMENT_N_PASSWORD_RETRIES 3
#define MANAGEMENT_LOG_HISTORY_INITIAL_SIZE 100

#defin= e MANAGEMENT_ECHO_BUFFER_SIZE 100
@@ -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_extr= a;
unsigned long in_extra_cid;
=

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib99f171fb69d51f2260b44edf8e= be21ac958f233
Gerrit-Change-Number: 1593
Gerrit-PatchSet: 2
Gerrit-Owner: Bluca <luca.boccassi@...1663...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-Reviewer: selvanair <selva.nair@...1665...= 77...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: Bluca <luca.boccassi@...1665...= 77...>
= --5PR9vfv3CvA=--