Skip to contentSkip to conversation

Two small fixes for auth via tokens

PATCH Superseded [email protected]... 2 participants 21 messages Mar 15 – Mar 16

lore
Share & tools
lore
#0 lore raw

cover Two small fixes for auth via tokens

From: Luca Boccassi <[email protected]...>

When JWT (json web tokens) are used by a server to authenticate the client, the default TLS channel buffer size and password length are too small.
In my local case connecting to an Azure VPN server, the Entra ID token is ~2100 bytes.

With these two small changes, it is possible to successfully connect to an Azure VPN endpoint using the OpenVPN 2.7 client, using a dummy username, an Entra token as password and the server-secret from the azvpn XML config that users get as tls-auth key.

Luca Boccassi (2):
Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192
Unconditionally set USER_PASS_LEN to 4096

 src/openvpn/common.h | 2 +-
 src/openvpn/misc.h   | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/2 Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

From: Luca Boccassi <[email protected]...>

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

---
 src/openvpn/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/common.h +1 -1
index aa7b7217..fbe6239a 100644
@@ -67,7 +67,7 @@ typedef unsigned long ptr_type;
  * maximum size of a single TLS message (cleartext).
  * This parameter must be >= PUSH_BUNDLE_SIZE
  */
-#define TLS_CHANNEL_BUF_SIZE 2048
+#define TLS_CHANNEL_BUF_SIZE 8192
 
 /* TLS control buffer minimum size
  *
Signature · 1 line
2.47.3
#2 lore raw

Re: [Openvpn-devel] [PATCH 1/2] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Am 15.03.26 um 19:39 schrieb [email protected]...:

Quoted 5 lines

From: Luca Boccassi <[email protected]...>

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

This is a change that can break compability. The normal limit is only 128 bw.

#define USER_PASS_LEN 128

Overall things like such big data should really be implemented via auth-pending method or similar.

Arne

#3 lore raw

Re: [Openvpn-devel] [PATCH 1/2] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 4 lines · Arne Schwabe

Am 15.03.26 um 19:39 schrieb [email protected]...:

Quoted 2 lines

From: Luca Boccassi <[email protected]...>

Quoted 8 lines
Quoted 3 lines

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

This is a change that can break compability. The normal limit is only 128 bw.

#define USER_PASS_LEN 128

The length is actually 4K when PKCS11 is enabled, which is the case in most distros:

/* max length of username/password */
#ifdef ENABLE_PKCS11
#define USER_PASS_LEN 4096
#else
#define USER_PASS_LEN 128
#endif

Could you please clarify how bumping this buffer max size could break compatibility? Thanks

Quoted 2 lines

Overall things like such big data should really be implemented via auth-pending method or similar.

Do you have more references available for this, please? Thanks

#4 lore raw

Re: [Openvpn-devel] [PATCH 1/2] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Am 16.03.26 um 13:00 schrieb Luca Boccassi:

Quoted 24 lines · Arne Schwabe
Quoted 4 lines

Am 15.03.26 um 19:39 schrieb [email protected]...:

Quoted 2 lines

From: Luca Boccassi <[email protected]...>

Quoted 8 lines
Quoted 3 lines

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

This is a change that can break compability. The normal limit is only 128 bw.

#define USER_PASS_LEN 128

The length is actually 4K when PKCS11 is enabled, which is the case in most distros:

/* max length of username/password */
#ifdef ENABLE_PKCS11
#define USER_PASS_LEN 4096
#else
#define USER_PASS_LEN 128
#endif

Quoted 2 lines

Could you please clarify how bumping this buffer max size could break compatibility? Thanks

The 128 vs 4096 is already problematic at times. Adding a third size does not help. Also the real password size that is useable in user/pass is not 4k either. Even with the 2048 that you want, you will run into problem because of other limitations, e.g. that the packet that user+pass and peer info variables a bit of other stuff needs to be is limited to 2048 bytes in total.

If we really want to support longer username and password authentication, this needs to be implemented in a different way that is not so problematic. E.g. client indicating its support for the extended password+username stuff (e.g. via IV_SSO) and then switching to that method.

Quoted 4 lines
Quoted 2 lines

Overall things like such big data should really be implemented via auth-pending method or similar.

Do you have more references available for this, please? Thanks

See management.txt as a start.

Arne

#5 lore raw

Re: [Openvpn-devel] [PATCH 1/2] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 29 lines · Arne Schwabe

Am 16.03.26 um 13:00 schrieb Luca Boccassi:

Quoted 24 lines · Arne Schwabe
Quoted 4 lines

Am 15.03.26 um 19:39 schrieb [email protected]...:

Quoted 2 lines

From: Luca Boccassi <[email protected]...>

Quoted 8 lines
Quoted 3 lines

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

This is a change that can break compability. The normal limit is only 128 bw.

#define USER_PASS_LEN 128

The length is actually 4K when PKCS11 is enabled, which is the case in most distros:

/* max length of username/password */
#ifdef ENABLE_PKCS11
#define USER_PASS_LEN 4096
#else
#define USER_PASS_LEN 128
#endif

Quoted 2 lines

Could you please clarify how bumping this buffer max size could break compatibility? Thanks

Quoted 6 lines

The 128 vs 4096 is already problematic at times. Adding a third size does not help. Also the real password size that is useable in user/pass is not 4k either. Even with the 2048 that you want, you will run into problem because of other limitations, e.g. that the packet that user+pass and peer info variables a bit of other stuff needs to be is limited to 2048 bytes in total.

Please note that this patch does not add a third password size? It removes the second one, leaving the existing 4096 as the sole option one, by dropping the ifdef. I don't strictly need this, as all distros build with PKCS11 support enabled anyway so this works fine for my use case too out of the box, but I thought it would have been nice to reduce the variance.

#6 lore raw

PATCH 2/2 Unconditionally set USER_PASS_LEN to 4096

In reply to [email protected]...

From: Luca Boccassi <[email protected]...>

When authenticating via a JWT token 128 bytes are not enough, which breaks the auth process. Currently the hardcoded password limit is increased to 4k when PKCS11 is enabled, for similar reasons. Remove the compile time conditional and always set the limit to 4k.

---
 src/openvpn/misc.h | 4 ----
 1 file changed, 4 deletions(-)
src/openvpn/misc.h +0 -4
index e9cfadba..2c495d41 100644
@@ -58,11 +58,7 @@ struct user_pass
     bool protected;
 
 /* max length of username/password */
-#ifdef ENABLE_PKCS11
 #define USER_PASS_LEN 4096
-#else
-#define USER_PASS_LEN 128
-#endif
     /* Note that username and password are expected to be null-terminated */
     char username[USER_PASS_LEN];
     char password[USER_PASS_LEN];
Signature · 1 line
2.47.3
#7 lore raw

v2 cover Two small fixes for auth via tokens

In reply to [email protected]...

From: Luca Boccassi <[email protected]...>

When JWT (json web tokens) are used by a server to authenticate the client, the default TLS channel buffer size and password length are too small.
In my local case connecting to an Azure VPN server, the Entra ID token is ~2100 bytes.

With these small changes, it is possible to successfully connect to an Azure VPN endpoint using the OpenVPN 2.7 client, using a dummy username, an Entra token as password and the server-secret from the azvpn XML config that users get as tls-auth key.

v2: also use the USER_PASS_LEN macro in the management channel params.

Luca Boccassi (3):
Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192 Unconditionally set USER_PASS_LEN to 4096
Ensure the management channel can take passwords up to the max length

 src/openvpn/common.h  | 2 +-
 src/openvpn/manage.c  | 4 ++--
 src/openvpn/misc.h    | 4 ----
 src/openvpn/options.h | 6 +++---
 4 files changed, 6 insertions(+), 10 deletions(-)
Signature · 1 line
2.47.3
#8 lore raw

PATCH v2 1/3 Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

From: Luca Boccassi <[email protected]...>

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

---
 src/openvpn/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/common.h +1 -1
index aa7b7217..fbe6239a 100644
@@ -67,7 +67,7 @@ typedef unsigned long ptr_type;
  * maximum size of a single TLS message (cleartext).
  * This parameter must be >= PUSH_BUNDLE_SIZE
  */
-#define TLS_CHANNEL_BUF_SIZE 2048
+#define TLS_CHANNEL_BUF_SIZE 8192
 
 /* TLS control buffer minimum size
  *
Signature · 1 line
2.47.3
#9 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Am 16.03.26 um 00:05 schrieb [email protected]...:

Quoted 16 lines

From: Luca Boccassi <[email protected]...>

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

---
  src/openvpn/common.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/common.h +0 -0
index aa7b7217..fbe6239a 100644

src/openvpn/common.h typedef unsigned long ptr_type; · line 73

Quoted 8 lines
src/openvpn/common.h +1 -1
@@ -67,7 +67,7 @@ typedef unsigned long ptr_type;
   * maximum size of a single TLS message (cleartext).
   * This parameter must be >= PUSH_BUNDLE_SIZE
   */
-#define TLS_CHANNEL_BUF_SIZE 2048
+#define TLS_CHANNEL_BUF_SIZE 8192
 
  /* TLS control buffer minimum size
   *

This gets a definitive NACK from me. This will cause compatibility problems. It might work for your small setup where you can easily patch both sides but it is not a good when compatibility with other clients is important.

We understand that user+pass is limited but this is not the right approach to overcome this limitation.

Arne

#10 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 32 lines · Arne Schwabe

Am 16.03.26 um 00:05 schrieb [email protected]...:

Quoted 16 lines

From: Luca Boccassi <[email protected]...>

When authenticating via a JWT token 2048 bytes are not enough, which breaks the auth process. In my local case the token is ~2100 bytes. Bump the maximum harcoded size from 2k to 8k to leave some headroom.

---
  src/openvpn/common.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/common.h +0 -0
index aa7b7217..fbe6239a 100644

src/openvpn/common.h typedef unsigned long ptr_type; · line 73

Quoted 8 lines
src/openvpn/common.h +1 -1
@@ -67,7 +67,7 @@ typedef unsigned long ptr_type;
   * maximum size of a single TLS message (cleartext).
   * This parameter must be >= PUSH_BUNDLE_SIZE
   */
-#define TLS_CHANNEL_BUF_SIZE 2048
+#define TLS_CHANNEL_BUF_SIZE 8192
 
  /* TLS control buffer minimum size
   *

This gets a definitive NACK from me. This will cause compatibility problems. It might work for your small setup where you can easily patch both sides but it is not a good when compatibility with other clients is important.

Quoted 2 lines

We understand that user+pass is limited but this is not the right approach to overcome this limitation.

Hi,

Could you please clarify what you mean by compatibility problems? And what would be the right approach instead to let the client process larger passwords? Thanks

#11 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 5 lines

Could you please clarify what you mean by compatibility problems? And what would be the right approach instead to let the client process larger passwords? Thanks

By compatibility problem I mean that a peer that is modified like you are suggesting will not be able to communicate to other peers without that patch.

This should be pretty obvious from the way you are changing the code that you allow a send buffer of 8k but do not take into account that peers without that patch only have 2k to receive.

Arne

#12 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 11 lines · Arne Schwabe
Quoted 3 lines

Could you please clarify what you mean by compatibility problems? And what would be the right approach instead to let the client process larger passwords? Thanks

By compatibility problem I mean that a peer that is modified like you are suggesting will not be able to communicate to other peers without that patch.

This should be pretty obvious from the way you are changing the code that you allow a send buffer of 8k but do not take into account that peers without that patch only have 2k to receive.

Thanks, first time I work on this repo so trying to get familiar with these details, I'll look into it.

The issue here is that the handshake fails, as the azvpn server expects a full token to be received, but it gets truncated. I have no control over the server, just the client. Do you have a suggestion on how to solve this in a way that would be acceptable?

#13 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 6 lines

The issue here is that the handshake fails, as the azvpn server expects a full token to be received, but it gets truncated. I have no control over the server, just the client. Do you have a suggestion on how to solve this in a way that would be acceptable?

I have no Idea what the azvpn server is and what they are doing but it looks like they are using some hacks that were never submitted upstream and also had no communication with our project. So it is not surprising that this does not work with the normal open source client.

Arne

#14 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 9 lines · Arne Schwabe
Quoted 4 lines

The issue here is that the handshake fails, as the azvpn server expects a full token to be received, but it gets truncated. I have no control over the server, just the client. Do you have a suggestion on how to solve this in a way that would be acceptable?

I have no Idea what the azvpn server is and what they are doing but it looks like they are using some hacks that were never submitted upstream and also had no communication with our project. So it is not surprising that this does not work with the normal open source client.

Oh it's even worse than that, I assure you :-) It's an internal reimplementation, it does not use the open source server sadly. But it is the openvpn protocol, and it works once the allowance for a large password is made.

I am trying to get the standard network-manager + openvpn setup to work with it, to at least be spared from having to use the absolutely horrendous proprietary client that comes with it.
In case you are curious, the network-manager-openvpn side is here:
https://gitlab.gnome.org/bluca/NetworkManager-openvpn/-/commits/entra_auth?ref_type=heads
With these changes, it works nicely.

Of course I'm more than happy to get the client changes here in a form that is acceptable to you, but would really appreciate guidance, as you can tell I am completely new to this project. The only limitation I have is that I can't change how the server works (I wish...), but on the client side I am open to anything that works.

Thanks for the feedback!

#15 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Am 16.03.26 um 13:17 schrieb Luca Boccassi:

Quoted 13 lines

Oh it's even worse than that, I assure you :-) It's an internal reimplementation, it does not use the open source server sadly. But it is the openvpn protocol, and it works once the allowance for a large password is made.

I am trying to get the standard network-manager + openvpn setup to work with it, to at least be spared from having to use the absolutely horrendous proprietary client that comes with it.
In case you are curious, the network-manager-openvpn side is here:
https://gitlab.gnome.org/bluca/NetworkManager-openvpn/-/commits/entra_auth?ref_type=heads
With these changes, it works nicely.

Quoted 5 lines

Of course I'm more than happy to get the client changes here in a form that is acceptable to you, but would really appreciate guidance, as you can tell I am completely new to this project. The only limitation I have is that I can't change how the server works (I wish...), but on the client side I am open to anything that works.

Yeah the problem is that they made changes that are not really acceptable in general for our project. You basically would need a special azvpn mode in OpenVPN that is only activated via a configuration option or similar and that would also have a lot of code overhead to enable/disable this mode in various parts of OpenVPN. And we need some strong reason to include such a hack mode that we need to maintain then forever in our code base.

I am afraid that for now using a specially patched version is probably easier/better to do.

Arne

#16 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 29 lines · Arne Schwabe

Am 16.03.26 um 13:17 schrieb Luca Boccassi:

Quoted 13 lines

Oh it's even worse than that, I assure you :-) It's an internal reimplementation, it does not use the open source server sadly. But it is the openvpn protocol, and it works once the allowance for a large password is made.

I am trying to get the standard network-manager + openvpn setup to work with it, to at least be spared from having to use the absolutely horrendous proprietary client that comes with it.
In case you are curious, the network-manager-openvpn side is here:
https://gitlab.gnome.org/bluca/NetworkManager-openvpn/-/commits/entra_auth?ref_type=heads
With these changes, it works nicely.

Quoted 5 lines

Of course I'm more than happy to get the client changes here in a form that is acceptable to you, but would really appreciate guidance, as you can tell I am completely new to this project. The only limitation I have is that I can't change how the server works (I wish...), but on the client side I am open to anything that works.

Yeah the problem is that they made changes that are not really acceptable in general for our project. You basically would need a special azvpn mode in OpenVPN that is only activated via a configuration option or similar and that would also have a lot of code overhead to enable/disable this mode in various parts of OpenVPN. And we need some strong reason to include such a hack mode that we need to maintain then forever in our code base.

Quoted 2 lines

I am afraid that for now using a specially patched version is probably easier/better to do.

Unfortunately a specially patched version cannot really work, as this really needs to work with the packaged client in normal distros. Can't tell other people to do their own building and patching and security maintenance and so on...

But I'm not sure why a special mode would be needed in the first place, with additional burden to support?

There are only 2 changes needed, and both have to do with ensuring the password size that can already be supported (4096) actually works through the stack. Right now the client you can install on Ubuntu or Fedora or any other distro, where it is built with PKCS11 enabled, takes 4k passwords already, so that part works, as the second patch of the series is really a cleanup. The issue is that there are 2 places in the client where this breaks:

1) The TLS buffer as per the first patch, as the client doesn't do multiple passes, but instead expect a single write to the TLS layer to be sufficient, but it supports 2k instead of the 4k that is the max password size
2) The management protocol that network-manager uses to configure the password at runtime, which takes 256 bytes at most in a command, as per the third patch

So the goal here would be simply to ensure the client works with the existing max password size.

Please let me know if I am missing something, but as far as I can tell, I have tried to check for compatibility issues, but I could not see one with the TLS buffer increase. I ran an unmodified 2.7.0 server, and a modified client, using TLS, and the client could connect just fine to the unmodified server, even if the TLS buffer is larger - it's just a buffer after all.

The only scenario I can think of that won't be compatible, is if someone tries to send a password larger than 2K - but that is already broken today? So in what way would that be a compatibility issue, given it already doesn't work, despite the max password size already being 4K? Is there a situation in which this would be a problem in a way that it isn't today that I am missing?

This is the config I tested with, server:

dev tun
topology subnet
server 10.99.99.0 255.255.255.0
proto tcp-server
port 11940
ca /tmp/ovpn-compat-test/ca.crt
cert /tmp/ovpn-compat-test/server.crt
key /tmp/ovpn-compat-test/server.key
tls-auth /tmp/ovpn-compat-test/ta.key 0
cipher AES-256-GCM
auth SHA256
verb 4
keepalive 10 60
script-security 2
auth-user-pass-verify /bin/true via-env
username-as-common-name
verify-client-cert none

client:

client
dev tun
proto tcp-client
remote 127.0.0.1 11940
ca /tmp/ovpn-compat-test/ca.crt
cert /tmp/ovpn-compat-test/client.crt
key /tmp/ovpn-compat-test/client.key
tls-auth /tmp/ovpn-compat-test/ta.key 1
cipher AES-256-GCM
auth SHA256
auth-user-pass /tmp/ovpn-compat-test/userpass.txt
verb 4
nobind
connect-timeout 10

For the management protocol, if increasing the options size is not ok, how about adding a new 'password-long' or somesuch option to the protocol, that allows receiving a password that is up to the current max of 4k?
Happy to work on this if it is preferable.

Thanks for your feedback!

#17 lore raw

Re: [Openvpn-devel] [PATCH v2 1/3] Increase TLS_CHANNEL_BUF_SIZE from 2048 to 8192

Quoted 112 lines · Luca Boccassi
Quoted 29 lines · Arne Schwabe

Am 16.03.26 um 13:17 schrieb Luca Boccassi:

Quoted 13 lines

Oh it's even worse than that, I assure you :-) It's an internal reimplementation, it does not use the open source server sadly. But it is the openvpn protocol, and it works once the allowance for a large password is made.

I am trying to get the standard network-manager + openvpn setup to work with it, to at least be spared from having to use the absolutely horrendous proprietary client that comes with it.
In case you are curious, the network-manager-openvpn side is here:
https://gitlab.gnome.org/bluca/NetworkManager-openvpn/-/commits/entra_auth?ref_type=heads
With these changes, it works nicely.

Quoted 5 lines

Of course I'm more than happy to get the client changes here in a form that is acceptable to you, but would really appreciate guidance, as you can tell I am completely new to this project. The only limitation I have is that I can't change how the server works (I wish...), but on the client side I am open to anything that works.

Yeah the problem is that they made changes that are not really acceptable in general for our project. You basically would need a special azvpn mode in OpenVPN that is only activated via a configuration option or similar and that would also have a lot of code overhead to enable/disable this mode in various parts of OpenVPN. And we need some strong reason to include such a hack mode that we need to maintain then forever in our code base.

Quoted 2 lines

I am afraid that for now using a specially patched version is probably easier/better to do.

Unfortunately a specially patched version cannot really work, as this really needs to work with the packaged client in normal distros. Can't tell other people to do their own building and patching and security maintenance and so on...

But I'm not sure why a special mode would be needed in the first place, with additional burden to support?

There are only 2 changes needed, and both have to do with ensuring the password size that can already be supported (4096) actually works through the stack. Right now the client you can install on Ubuntu or Fedora or any other distro, where it is built with PKCS11 enabled, takes 4k passwords already, so that part works, as the second patch of the series is really a cleanup. The issue is that there are 2 places in the client where this breaks:

1) The TLS buffer as per the first patch, as the client doesn't do multiple passes, but instead expect a single write to the TLS layer to be sufficient, but it supports 2k instead of the 4k that is the max password size
2) The management protocol that network-manager uses to configure the password at runtime, which takes 256 bytes at most in a command, as per the third patch

So the goal here would be simply to ensure the client works with the existing max password size.

Please let me know if I am missing something, but as far as I can tell, I have tried to check for compatibility issues, but I could not see one with the TLS buffer increase. I ran an unmodified 2.7.0 server, and a modified client, using TLS, and the client could connect just fine to the unmodified server, even if the TLS buffer is larger - it's just a buffer after all.

The only scenario I can think of that won't be compatible, is if someone tries to send a password larger than 2K - but that is already broken today? So in what way would that be a compatibility issue, given it already doesn't work, despite the max password size already being 4K? Is there a situation in which this would be a problem in a way that it isn't today that I am missing?

This is the config I tested with, server:

dev tun
topology subnet
server 10.99.99.0 255.255.255.0
proto tcp-server
port 11940
ca /tmp/ovpn-compat-test/ca.crt
cert /tmp/ovpn-compat-test/server.crt
key /tmp/ovpn-compat-test/server.key
tls-auth /tmp/ovpn-compat-test/ta.key 0
cipher AES-256-GCM
auth SHA256
verb 4
keepalive 10 60
script-security 2
auth-user-pass-verify /bin/true via-env
username-as-common-name
verify-client-cert none

client:

client
dev tun
proto tcp-client
remote 127.0.0.1 11940
ca /tmp/ovpn-compat-test/ca.crt
cert /tmp/ovpn-compat-test/client.crt
key /tmp/ovpn-compat-test/client.key
tls-auth /tmp/ovpn-compat-test/ta.key 1
cipher AES-256-GCM
auth SHA256
auth-user-pass /tmp/ovpn-compat-test/userpass.txt
verb 4
nobind
connect-timeout 10

Quoted 7 lines

For the management protocol, if increasing the options size is not ok, how about adding a new 'password-long' or somesuch option to the protocol, that allows receiving a password that is up to the current max of 4k?
Happy to work on this if it is preferable.

Thanks for your feedback!

I've sent a simplified and reduced revision that instead of hardcoding new sizes, simply uses the existing max(<existing>, USER_PASS_LEN) (without changing it) itself to define those 3 buffers. That way there are no changes unless USER_PASS_LEN is set to a large value.

Hopefully this is more palatable - but as before, I am more than happy to work on alternative implementations, as mentioned above, if there are any suggestions.

Thanks!

#18 lore raw

PATCH v2 2/3 Unconditionally set USER_PASS_LEN to 4096

In reply to [email protected]...

From: Luca Boccassi <[email protected]...>

When authenticating via a JWT token 128 bytes are not enough, which breaks the auth process. Currently the hardcoded password limit is increased to 4k when PKCS11 is enabled, for similar reasons. Remove the compile time conditional and always set the limit to 4k.

---
 src/openvpn/misc.h | 4 ----
 1 file changed, 4 deletions(-)
src/openvpn/misc.h +0 -4
index e9cfadba..2c495d41 100644
@@ -58,11 +58,7 @@ struct user_pass
     bool protected;
 
 /* max length of username/password */
-#ifdef ENABLE_PKCS11
 #define USER_PASS_LEN 4096
-#else
-#define USER_PASS_LEN 128
-#endif
     /* Note that username and password are expected to be null-terminated */
     char username[USER_PASS_LEN];
     char password[USER_PASS_LEN];
Signature · 1 line
2.47.3
#19 lore raw

PATCH v2 3/3 Ensure the management channel can take passwords up to the max length

In reply to [email protected]...

From: Luca Boccassi <[email protected]...>

These hardcoded limits are different than the password size limit. Use the macro to ensure a password can always fit via the management channel, otherwise when long passwords are used (e.g.: tokens) they will be silently dropped.

---
 src/openvpn/manage.c  | 4 ++--
 src/openvpn/options.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
src/openvpn/manage.c +2 -2
index df72f15f..5cb25107 100644
@@ -2653,9 +2653,9 @@ man_connection_init(struct management *man)
 
         /*
          * Allocate helper objects for command line input and
-         * command output from/to the socket.
+         * command output from/to the socket. Ensure a password cat fit.
          */
-        man->connection.in = command_line_new(1024);
+        man->connection.in = command_line_new(USER_PASS_LEN);
         man->connection.out = buffer_list_new();
 
         /*
src/openvpn/options.h +3 -3
index 3d8b5059..4fafdc52 100644
@@ -51,10 +51,10 @@
 #define MAX_PARMS 16
 
 /*
- * Max size of options line and parameter.
+ * Max size of options line and parameter. Ensure a password can fit.
  */
-#define OPTION_PARM_SIZE 256
-#define OPTION_LINE_SIZE 256
+#define OPTION_PARM_SIZE USER_PASS_LEN
+#define OPTION_LINE_SIZE USER_PASS_LEN
 
 extern const char title_string[];
 
Signature · 1 line
2.47.3
#20 lore raw

Re: [Openvpn-devel] [PATCH v2 3/3] Ensure the management channel can take passwords up to the max length

Am 16.03.26 um 00:05 schrieb [email protected]...:

Quoted 14 lines

From: Luca Boccassi <[email protected]...>

These hardcoded limits are different than the password size limit. Use the macro to ensure a password can always fit via the management channel, otherwise when long passwords are used (e.g.: tokens) they will be silently dropped.

index 3d8b5059..4fafdc52 100644

src/openvpn/options.h +0 -0
@@ -51,10 +51,10 @@
  #define MAX_PARMS 16
 
  /*

src/openvpn/options.h line 60

Quoted 10 lines
src/openvpn/options.h +3 -3
- * Max size of options line and parameter.
+ * Max size of options line and parameter. Ensure a password can fit.
   */
-#define OPTION_PARM_SIZE 256
-#define OPTION_LINE_SIZE 256
+#define OPTION_PARM_SIZE USER_PASS_LEN
+#define OPTION_LINE_SIZE USER_PASS_LEN
 
  extern const char title_string[];
 

You are changing quite fundamental limit in the parser without any regards to anything outside your own use case. You will need a lot more convincing to get something like that accepted.

Arne