Improvement/fixes based on Trail of Bits audit
cover Improvement/fixes based on Trail of Bits audit
This patch set addresses some issues found by Trail of Bits in an audit of OpenVPN 2.x. This audit is currently not public but the intention is to publish it.
The audit contained no vulnerability or problem that was deemed a vulnerability that needed a CVE or coordinated release. Therefore, this patch set is send to the public mailing list instead of going through a closed review only on the [email protected]... list that we would have done otherwise.
This patch set also includes another security patch that is unrelated to the audit (Make management password check constant time) that was reported by Connor Edwards <[email protected]...>.
Arne Schwabe (7):
Make management password check constant time
Ensure that argument to parse_line has always space for final sentinel Improve documentation on user/password requirement and unicodize
function
Eliminate or comment empty blocks and switch fallthrough Remove unused gc_arena
Fix corner case that might lead to leaked file descriptor Deprecate NTLMv1 proxy auth method.
David Sommerseth (1):
ssl_verify: Fix memleak if creating deferred auth control files fails
src/openvpn/comp-lz4.c | 1 + src/openvpn/crypto.c | 1 + src/openvpn/forward.c | 3 -- src/openvpn/init.c | 1 + src/openvpn/lzo.c | 1 + src/openvpn/manage.c | 6 +++- src/openvpn/misc.c | 1 + src/openvpn/misc.h | 1 + src/openvpn/multi.c | 2 -- src/openvpn/ntlm.c | 13 ++++++++ src/openvpn/options.c | 14 +++----- src/openvpn/proxy.c | 2 ++ src/openvpn/push.c | 4 +-- src/openvpn/ssl_openssl.c | 68 ++++++++++++++++++--------------------- src/openvpn/ssl_verify.c | 6 ++-- 15 files changed, 68 insertions(+), 56 deletions(-)
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 1/8 Make management password check constant time
This changes the password check on the management interface to be constant time. Normally the management port should not be exposed in a way that allows an attacker to even interact with it but making the check constant time as an additional layer of security is always good.
--- src/openvpn/manage.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
src/openvpn/manage.c +5 -1
@@ -198,7 +198,11 @@ man_check_password(struct management *man, const char *line) {if (man_password_needed (man)) { -if (streq (line, man->settings.up.password)) +/* This comparison is not fixed time but since strlen(time) is based on +* the attacker choice, it should not give any indication of the real +* password length */ +if (memcmp_constant_time (line, man->settings.up.password, +min_uint (strlen (line),sizeof (man->settings.up.password))) ==0 ) { man->connection.password_verified = true;msg (M_CLIENT ,"SUCCESS: password is correct" );
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 2/8 ssl_verify: Fix memleak if creating deferred auth control files fails
In reply to Arne SchwabeFrom: David Sommerseth <[email protected]...>
If the key_state_gen_auth_control_files() call fails, the code would just return without freeing the argv container. Instead the code should jump to an appropriate exit point where memory is being released.
Also adjust the related comment, to indicate that these deferred auth control files are really pre-created.
--- src/openvpn/ssl_verify.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
src/openvpn/ssl_verify.c +4 -2
@@ -1358,12 +1358,13 @@ verify_user_pass_script(struct tls_session *session, struct tls_multi *multi,setenv_str (session->opt->es,"password" , up->password); } -/* generate filename for deferred auth control file */ +/* pre-create files for deferred auth control */ if (!key_state_gen_auth_control_files (&ks->script_auth, session->opt)) {msg (D_TLS_ERRORS ,"TLS Auth Error (%s): " "could not create deferred auth control file" , __func__); -return OPENVPN_PLUGIN_FUNC_ERROR ; + retval =OPENVPN_PLUGIN_FUNC_ERROR ; + goto error; }/* call command */
@@ -1412,6 +1413,7 @@ done:platform_unlink (tmp_file); } +error:argv_free (&argv);gc_free (&gc);return retval;
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 3/8 Ensure that argument to parse_line has always space for final sentinel
In reply to Arne SchwabeThis fixes two places were we do not have enough space in the array of parameters given to parse_line for the final NULL parameter that signal the end of the parsed argument errors.
Both these cases can lead to a buffer overflow. But both of these cases require root/admin access to OpenVPN:
- parse_argv, only able to trigger if starting openvpn from the command line, at this point you cannot gain more privileges than you already have.
Way to reproduce, compile with ASAN and run:
openvpn --tls-verify a a a a a a a a a a a a a a a
- remove_iroutes_from_push_route_list
This operates on the list of pushed entries that is generated by the server itself. So trigger this, you need to have control over config, management interface, a plugin or cdd files.
The parse_argv problem was found by Trial of Bits. I found the remove_iroutes_from_push_route_list problem by looking for similar problems.
--- src/openvpn/options.c | 9 ++++----- src/openvpn/push.c | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-)
src/openvpn/options.c +4 -5
@@ -5310,8 +5310,6 @@ parse_argv(struct options *options, unsigned int *option_types_found, struct env_set *es) { - int i, j; -/* usage message */ if (argc <=1 ) {
@@ -5321,7 +5319,7 @@ parse_argv(struct options *options,/* config filename specified only? */ if (argc ==2 &&strncmp (argv[1 ],"--" ,2 )) { -char *p[MAX_PARMS ]; +char *p[MAX_PARMS +1 ];CLEAR (p); p[0 ] ="config" ; p[1 ] = argv[1 ];
@@ -5331,9 +5329,9 @@ parse_argv(struct options *options,else {/* parse command line */ -for (i =1 ; i < argc; ++i) +for (int i =1 ; i < argc; ++i) { -char *p[MAX_PARMS ]; +char *p[MAX_PARMS +1 ];CLEAR (p); p[0 ] = argv[i];if (strncmp (p[0 ],"--" ,2 ))
@@ -5345,6 +5343,7 @@ parse_argv(struct options *options, p[0 ] +=2 ; } +int j;for (j =1 ; j <MAX_PARMS ; ++j) {if (i + j < argc)
src/openvpn/push.c +2 -2
@@ -1096,13 +1096,13 @@ remove_iroutes_from_push_route_list(struct options *o)/* cycle through the push list */ while (e) { -char *p[MAX_PARMS ]; +char *p[MAX_PARMS +1 ];bool enable = true;/* parse the push item */ CLEAR (p);if (e->enable - &&parse_line (e->option, p,SIZE (p),"[PUSH_ROUTE_REMOVE]" ,1 ,D_ROUTE_DEBUG , &gc)) + &&parse_line (e->option, p,SIZE (p)-1 ,"[PUSH_ROUTE_REMOVE]" ,1 ,D_ROUTE_DEBUG , &gc)) {/* is the push item a route directive? */ if (p[0 ] && !strcmp (p[0 ],"route" ) && !p[3 ] && o->iroutes)
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 4/8 Improve documentation on user/password requirement and unicodize function
In reply to Arne Schwabe--- src/openvpn/misc.h | 1 + src/openvpn/ntlm.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
src/openvpn/misc.h +1 -0
@@ -67,6 +67,7 @@ struct user_pass#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 ]; };
src/openvpn/ntlm.c +13 -0
@@ -140,6 +140,19 @@ my_strupr(char *str) } } +/** +* This function expects a null-terminated string in src and will +* copy it (including the terminating NUL byte), +* alternating it with 0 to dst. +* +* This basically will transform a ASCII string into valid UTF-16. +* Characters that are 8bit in src, will get the same treatment, resulting in +* invalid or wrong unicode code points. +* +* @note the function will blindly assume that dst has double +* the space of src. +* @return the length of the number of bytes written to dst +*/ static int unicodize (char *dst,const char *src) {
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 5/8 Eliminate or comment empty blocks and switch fallthrough
In reply to Arne SchwabeThese empty blocks are intentional but trigger code checkers and were pointed out by Trail of Bits in the security audits. Add comments to them or eliminate them whatever makes more sense.
For fallthrough C23 [1] has a standard way to signal that but we not adding a C23 feature to our codebase, so use a comment for now.
[1] https://en.cppreference.com/w/c/language/attributes/fallthrough
--- src/openvpn/comp-lz4.c | 1 + src/openvpn/crypto.c | 1 + src/openvpn/init.c | 1 + src/openvpn/lzo.c | 1 + src/openvpn/options.c | 5 +-- src/openvpn/ssl_openssl.c | 68 ++++++++++++++++++--------------------- 6 files changed, 36 insertions(+), 41 deletions(-)
src/openvpn/comp-lz4.c +1 -0
@@ -237,6 +237,7 @@ lz4_decompress(struct buffer *buf, struct buffer work, }else if (c ==NO_COMPRESS_BYTE_SWAP )/* packet was not compressed */ { +/* nothing to do */ }else {
src/openvpn/crypto.c +1 -0
@@ -1300,6 +1300,7 @@ read_key_file(struct key2 *key2, const char *file, const unsigned int flags) }else if (isspace (c)) { +/* ignore white space characters */ }else {
src/openvpn/init.c +1 -0
@@ -2921,6 +2921,7 @@ do_init_crypto_tls_c1(struct context *c)case AR_INTERACT :ssl_purge_auth (false); +/* Intentional [[fallthrough]]; */ case AR_NOINTERACT : c->sig->signal_received =SIGUSR1 ;/* SOFT-SIGUSR1 -- Password failure error */
src/openvpn/lzo.c +1 -0
@@ -250,6 +250,7 @@ lzo_decompress(struct buffer *buf, struct buffer work, }else if (c ==NO_COMPRESS_BYTE )/* packet was not compressed */ { +/* nothing to do */ }else {
src/openvpn/options.c +1 -4
@@ -2973,10 +2973,7 @@ options_postprocess_verify_ce(const struct options *options, "--auth-user-pass"); } } -else if (sum ==2 ) - { - } -else +else if (sum !=2 ) {msg (M_USAGE ,"If you use one of --cert or --key, you must use them both" ); }
src/openvpn/ssl_openssl.c +31 -37
92 lines not on this page · raw message
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 6/8 Remove unused gc_arena
In reply to Arne Schwabe--- src/openvpn/forward.c | 3 --- src/openvpn/multi.c | 2 -- 2 files changed, 5 deletions(-)
src/openvpn/forward.c +0 -3
@@ -1869,8 +1869,6 @@ process_outgoing_link(struct context *c)void process_outgoing_tun (struct context *c) { -struct gc_arena gc =gc_new (); -/* * Set up for write() call to TUN/TAP * device.
@@ -1956,7 +1954,6 @@ process_outgoing_tun(struct context *c)buf_reset (&c->c2.to_tun);perf_pop (); -gc_free (&gc); }void
src/openvpn/multi.c +0 -2
@@ -3497,7 +3497,6 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *instbool multi_process_incoming_tun (struct multi_context *m,const unsigned int mpp_flags) { -struct gc_arena gc =gc_new ();bool ret = true;if (BLEN (&m->top.c2.buf) >0 )
@@ -3583,7 +3582,6 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags } } } -gc_free (&gc);return ret; }
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 7/8 Fix corner case that might lead to leaked file descriptor
In reply to Arne Schwabe--- src/openvpn/misc.c | 1 + 1 file changed, 1 insertion(+)
src/openvpn/misc.c +1 -0
@@ -258,6 +258,7 @@ get_user_pass_cr(struct user_pass *up,msg (D_LOW ,"No password found in %s authfile '%s'. Querying the management interface" , prefix, auth_file);if (!auth_user_pass_mgmt (up, prefix, flags, auth_challenge)) { +fclose (fp);return false; } }
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH 8/8 Deprecate NTLMv1 proxy auth method.
In reply to Arne SchwabeNTLMv1 is ancient and not considered secure anymore and we are not aware of any users or software still requiring this feature.
Additionally it currently depends on our "doing single DES using 3DES" workaround for OpenSSL (cipher_des_encrypt_ecb). So removing NTLMv1 will also allow us to remove that workaround.
--- src/openvpn/proxy.c | 2 ++ 1 file changed, 2 insertions(+)
src/openvpn/proxy.c +2 -0
@@ -519,6 +519,8 @@ http_proxy_new(const struct http_proxy_options *o)#if NTLM else if (!strcmp(o->auth_method_string, "ntlm")) { +msg (M_INFO ,"NTLM v1 authentication is deprecated and will be removed in " +"OpenVPN 2.7" ); p->auth_method =HTTP_AUTH_NTLM ; } else if (!strcmp(o->auth_method_string, "ntlm2"))
Signature · 1 line
2.37.1 (Apple Git-137.1)
Re: [Openvpn-devel] [PATCH 2/8] ssl_verify: Fix memleak if creating deferred auth control files fails
In reply to Arne SchwabeAm 15.12.2022 um 20:01 schrieb Arne Schwabe:
Quoted 6 lines
From: David Sommerseth <[email protected]...>
If the
key_state_gen_auth_control_files()call fails, the code would just return without freeing the argv container. Instead the code should jump to an appropriate exit point where memory is being released.
Quoted 6 lines
Also adjust the related comment, to indicate that these deferred auth control files are really pre-created.
Signed-off-by David Sommerseth <[email protected]...>Reported-by Trial of Bits (TOB-OVPN-2)
Typo here: Should be Trail of Bits (my mistake)
Re: [Openvpn-devel] [PATCH 1/8] Make management password check constant time
In reply to Arne SchwabeHi,
Quoted 4 lines · Arne Schwabe
This changes the password check on the management interface to be constant time. Normally the management port should not be exposed in a way that allows an attacker to even interact with it but making the check constant time as an additional layer of security is always good.
NAK on this, the min_int() logic is wrong. My fault, sorry.
With this, it will only compare "up the the number of bytes that the attacker has entered", and if he happens to catch the first character of the password, he's in...
Escape character is '^]'.
ENTER PASSWORD:f
SUCCESS: password is correct
... the password here is actually "foobar"...
Doing a "+1" on the compare length will include the 0-byte (which is different here, "o" vs. "0"), and that should cover all cases.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...[Openvpn-devel] [PATCH applied] Re: ssl_verify: Fix memleak if creating deferred auth control files fails
In reply to Arne SchwabeAs agreed on the security@ list - this covers all possible leaks, and is fully "normal OpenVPN style". I didn't test actual file creation failures, but I *did* test regular server operation with plugins and scripts, and that all still works fine.
As instructed, I've fixed the "Trial" to read "Trail of Bits" :-)
Your patch has been applied to the master and release/2.6 branch.
release/2.5 and older do not contain this code (no async/deferred --verify-auth-user-pass scripts yet) - that was only added in 2021 via commit 28e6103096ae8.
commit 0567da5377704cf64bd2599f2d49aa478d386941 (master) commit cdfdfb3da0ce714f43b23f679a8ef9b36ab9f370 (release/2.6)
Author: David Sommerseth Date: Thu Dec 15 20:01:37 2022 +0100
ssl_verify: Fix memleak if creating deferred auth control files fails
Signed-off-by: David Sommerseth <[email protected]...>
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25737.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Ensure that argument to parse_line has always space for final sentinel
In reply to Arne SchwabeStraightforward enough :-) - still, run through the test mill. I have no ASAN environment around right now, so couldn't verify the actual overflow "before" - but stare-at-code confirms the problem and the fix.
Your patch has been applied to the master, release/2.6, release/2.5 and release/2.4 branch (and has been t_client tested on 2.4+2.5)
commit 749beb6d0cb9f8628997bb656ba2f64e31cac377 (master) commit d75462fc70a2b0b26fb10063b15b6bfc5c8161db (release/2.6) commit 01bed788b0ec4007591b81398b56b5f9632ca33c (release/2.5) commit a12adfa01b2486bff32c9bb3aedf81716ad14c58 (release/2.4)
Author: Arne Schwabe Date: Thu Dec 15 20:01:38 2022 +0100
Ensure that argument to parse_line has always space for final sentinel
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25734.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Improve documentation on user/password requirement and unicodize function
In reply to Arne SchwabeHaven't tested anything :-) - but the documentation addition is useful.
Your patch has been applied to the master, release/2.6 and release/2.5 branch.
commit 4b6854881c36e16054878e0467ef87d925e20cae (master) commit d327476c35a3fe366c1d9155ccf24172c59bb60d (release/2.6) commit fad810fff33946e1b79d408e97ea8b7c017e9fb4 (release/2.5)
Author: Arne Schwabe Date: Thu Dec 15 20:01:39 2022 +0100
Improve documentation on user/password requirement and unicodize function
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25733.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Eliminate or comment empty blocks and switch fallthrough
In reply to Arne SchwabeThis doesn't change anything code wise (where it changes the if/else, it just gets rid of the second-to-last empty block, and by adding an early exit gets rid of an indentation level), but improves clarity, so very welcome. The diffs to bio_read() work better with "git show -w".
Client-side tested that things still work :-)
Your patch has been applied to the master and release/2.6 branch.
commit f2454ec6363d5578875d020179b38074b3c10964 (master) commit da747c3664d9330a1e38369aadddefb6ba5e8416 (release/2.6)
Author: Arne Schwabe Date: Thu Dec 15 20:01:40 2022 +0100
Eliminate or comment empty blocks and switch fallthrough
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25735.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Remove unused gc_arena
In reply to Arne SchwabeTrivial enough.
Client-side tested to see if the compiler agrees :-) (it does, but in release/2.5, *one* of these GCs is actually still used - 2.5 still has PF, and PF log calls mroute_addr_print_ex(..., &gc)... so the backport only removes the other gc)
Your patch has been applied to the master, release/2.6 and release/2.5 branch.
commit 97929d16a4eb05cb521a469ff4eaca32761699f3 (master) commit a873736483836a3c0574085712beeaea8bba30e9 (release/2.6) commit 5ca01c79bc3c972719e844b224dac981e128cbb6 (release/2.5)
Author: Arne Schwabe Date: Thu Dec 15 20:01:41 2022 +0100
Remove unused gc_arena
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25736.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Fix corner case that might lead to leaked file descriptor
In reply to Arne Schwabestare-at-code confirms that this is a simple-enough fix.
One could argue for moving the fclose(fp) up before the tangled if/else/... construct, but this one will do and is easy enough to review "it will not change anything except in case of error".
Your patch has been applied to the master, release/2.6 and release/2.5 branch.
commit a034dc8153522713c3cfda90b2cda114cea70e2d (master) commit 03f990b4df00bfb2cb9aa93155420efa935011b5 (release/2.6) commit 1ec71f4568e13f2876e6ec15f1efda530693d2e9 (release/2.5)
Author: Arne Schwabe Date: Thu Dec 15 20:01:42 2022 +0100
Fix corner case that might lead to leaked file descriptor
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25730.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Deprecate NTLMv1 proxy auth method.
In reply to Arne SchwabeHave not tested beyond "we agreed on that, message looks good, and it compiles".
Your patch has been applied to the master and release/2.6 branch.
commit e005b8d1fda1ad1e26fe0dbe7e09184a1f19b553 (master) commit f4f92cc589b5fc473b83c9e9e109a414fa6102ca (release/2.6)
Author: Arne Schwabe Date: Thu Dec 15 20:01:43 2022 +0100
Deprecate NTLMv1 proxy auth method.
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25731.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: Deprecate NTLMv1 proxy auth method.
Quoted 6 lines · Gert Doering
Acked-by Gert Doering <[email protected]...>Have not tested beyond "we agreed on that, message looks good, and it compiles".
Your patch has been applied to the master and release/2.6 branch.
Just noticed that this is missing a corresponding Changes.rst change. Should I send a patch for that?
Regards,
Signature · 1 line
Frank Lichtenheld
Re: [Openvpn-devel] [PATCH applied] Re: Deprecate NTLMv1 proxy auth method.
Hi,
Quoted 10 lines · Frank Lichtenheld
Quoted 6 lines · Gert Doering
Acked-by Gert Doering <[email protected]...>Have not tested beyond "we agreed on that, message looks good, and it compiles".
Your patch has been applied to the master and release/2.6 branch.
Just noticed that this is missing a corresponding
Changes.rstchange. Should I send a patch for that?
Our handling of Changes.rst is not always consistent - somtimes patches bring that along, for the rest I try to make sense of "git log" when preparing the next release and add what is missing to Changes.rst.
So, I don't think we need an extra patch for this, will cover when preparing _beta3 / _rc1, whatever and whenever it will be... :-)
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...PATCH v2 1/8 Make management password check constant time
In reply to Arne SchwabeThis changes the password check on the management interface to be constant time. Normally the management port should not be exposed in a way that allows an attacker to even interact with it but making the check constant time as an additional layer of security is always good.
Patch v2: include NUL byte in comparison
--- src/openvpn/manage.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/manage.c +6 -1
@@ -198,7 +198,12 @@ man_check_password(struct management *man, const char *line) {if (man_password_needed (man)) { -if (streq (line, man->settings.up.password)) +/* This comparison is not fixed time but since strlen(time) is based on +* the attacker choice, it should not give any indication of the real +* password length, use + 1 to include the NUL byte that terminates the +* string*/ +size_t compare_len =min_uint (strlen (line) +1 ,sizeof (man->settings.up.password)); +if (memcmp_constant_time (line, man->settings.up.password, compare_len) ==0 ) { man->connection.password_verified = true;msg (M_CLIENT ,"SUCCESS: password is correct" );
Signature · 1 line
2.37.1 (Apple Git-137.1)
[Openvpn-devel] [PATCH applied] Re: Make management password check constant time
Works. Password entered must be the right one now, not shorter or longer :-)
Your patch has been applied to the master and release/2.6 branch.
I think it would also be appropriate for 2.5, but there is no min_uint() (came as part of commit 3f8fb2b2c), so the patch "as is" breaks compilation on older branches.
commit e567f34262b0670fd51cbbcb6c6866b046454cee (master) commit 6a82929076ed97f6c37161de266d3dcbe14d55c8 (release/2.6)
Author: Arne Schwabe Date: Tue Dec 20 15:04:58 2022 +0100
Make management password check constant time
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25784.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering