Ignore auth-nocache for auth-user-pass if auth-token is pushed
PATCH 1/1 Ignore auth-nocache for auth-user-pass if auth-token is pushed
When the auth-token option is pushed from the server to the client, the latter has to ignore the auth-nocache directive (if specified).
The password will now be substituted by the unique token, therefore it can't be wiped out, otherwise the next renegotiation will fail.
Trac: #840
--- src/openvpn/init.c | 12 ++++++++++++ src/openvpn/misc.c | 7 ++++++- src/openvpn/misc.h | 2 ++ src/openvpn/ssl.c | 33 ++++++++++++++++++++++++++++++++- src/openvpn/ssl.h | 2 ++ 5 files changed, 54 insertions(+), 2 deletions(-)
src/openvpn/init.c +12 -0
@@ -1383,6 +1383,18 @@ initialization_sequence_completed(struct context *c, const unsigned int flags)/* If we delayed UID/GID downgrade or chroot, do it now */ do_uid_gid_chroot (c, true); +/* +* In some cases (i.e. when receiving auth-token via +* push-reply) the auth-nocache option configured on the +* client is overridden; for this reason we have to wait +* for the push-reply message before attempting to wipe +* the user/pass entered by the user +*/ +if (c->options.mode ==MODE_POINT_TO_POINT ) + { +delayed_auth_pass_purge (); + } +/* Test if errors */ if (flags &ISC_ERRORS ) {
src/openvpn/misc.c +6 -1
@@ -1480,7 +1480,11 @@ purge_user_pass(struct user_pass *up, const bool force)secure_memzero (up,sizeof (*up)); up->nocache = nocache; } -else if (!warn_shown) +/* +* don't show warning if the pass has been replaced by a token: this is an +* artificial "auth-nocache" +*/ +else if (!warn_shown && (!up->tokenized)) {msg (M_WARN ,"WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this" ); warn_shown = true;
@@ -1494,6 +1498,7 @@ set_auth_token(struct user_pass *up, const char *token) {CLEAR (up->password);strncpynt (up->password, token,USER_PASS_LEN ); + up->tokenized = true; } }
src/openvpn/misc.h +2 -0
@@ -206,6 +206,8 @@ struct user_pass {bool defined;bool nocache; +bool tokenized;/* true if password has been substituted by a token */ +bool wait_for_push;/* true if this object is waiting for a push-reply */ /* max length of username/password */ #ifdef ENABLE_PKCS11
src/openvpn/ssl.c +32 -1
@@ -452,6 +452,8 @@ ssl_set_auth_nocache(void) { passbuf.nocache = true; auth_user_pass.nocache = true; +/* wait for push-reply, because auth-token may invert nocache */ + auth_user_pass.wait_for_push = true; }/*
@@ -460,6 +462,14 @@ ssl_set_auth_nocache(void)void ssl_set_auth_token (const char *token) { +if (auth_user_pass.nocache) + { +msg (M_INFO , +"auth-token received, disabling auth-nocache for the " +"authentication token" ); + auth_user_pass.nocache = false; + } +set_auth_token (&auth_user_pass, token); }
@@ -2383,7 +2393,21 @@ key_method_2_write(struct buffer *buf, struct tls_session *session) { goto error; } -purge_user_pass (&auth_user_pass, false); +/* if auth-nocache was specified, the auth_user_pass object reaches +* a "complete" state only after having received the push-reply +* message. +* This is the case because auth-token statement in a push-reply would +* invert its nocache. +* +* For this reason, skip the purge operation here if no push-reply +* message has been received yet. +* +* This normally happens upon first negotiation only. +*/ +if (!auth_user_pass.wait_for_push) + { +purge_user_pass (&auth_user_pass, false); + } }else {
@@ -4214,6 +4238,13 @@ done: return BSTR(&out); } +void +delayed_auth_pass_purge (void ) +{ + auth_user_pass.wait_for_push = false; +purge_user_pass (&auth_user_pass, false); +} +#else /* if defined(ENABLE_CRYPTO) */ static void dummy (void )
src/openvpn/ssl.h +2 -0
@@ -591,6 +591,8 @@ void show_tls_performance_stats(void);/*#define EXTRACT_X509_FIELD_TEST*/ void extract_x509_field_test (void ); +void delayed_auth_pass_purge (void ); +#endif /* ENABLE_CRYPTO */ #endif /* ifndef OPENVPN_SSL_H */
Signature · 1 line
2.11.1
Hi,
Quoted 5 lines · Antonio Quartulli
When the auth-token option is pushed from the server to the client, the latter has to ignore the auth-nocache directive (if specified).
The password will now be substituted by the unique token, therefore it can't be wiped out, otherwise the next renegotiation will fail.
Without looking at the patch itself - is this suitable material for inclusion in 2.3? We do have quite a few "slow adopters" - and this is a very useful feature to mitigate SWEET32 in 2FA environments...
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Quoted 6 lines · Gert Doering
Hi,
Quoted 3 lines · Antonio Quartulli
When the auth-token option is pushed from the server to the client, the latter has to ignore the auth-nocache directive (if specified).
Quoted 6 lines
Quoted 2 lines
The password will now be substituted by the unique token, therefore it can't be wiped out, otherwise the next renegotiation will fail.
Without looking at the patch itself - is this suitable material for inclusion in 2.3? We do have quite a few "slow adopters" - and this is a very useful feature to mitigate SWEET32 in 2FA environments...
The code paths involved shouldn't be very differ too much between v2.3 and v2.4. So I would say this should go into v2.3 as well.
Attached is a very preliminary (and only compile and 'make check' tested) patch of a backport to v2.3. This needs to get a thorough test as well before we'll send an official patch to this ML.
Btw. since I have worked closely with Antonio on this patch, testing and debugging and discussing it for some time, I think it would be good if someone else than me does the final code review and ACK/NAK it. I'm not able to be objective on this patch.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Technologies, Inc
src/openvpn/init.c +12 -0
@@ -1253,6 +1253,18 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)/* If we delayed UID/GID downgrade or chroot, do it now */ do_uid_gid_chroot (c, true); +/* +* In some cases (i.e. when receiving auth-token via +* push-reply) the auth-nocache option configured on the +* client is overridden; for this reason we have to wait +* for the push-reply message before attempting to wipe +* the user/pass entered by the user +*/ +if (c->options.mode ==MODE_POINT_TO_POINT ) + { +delayed_auth_pass_purge (); + } +/* Test if errors */ if (flags &ISC_ERRORS ) {
src/openvpn/misc.c +6 -1
@@ -1343,7 +1343,11 @@ purge_user_pass (struct user_pass *up, const bool force)CLEAR (*up); up->nocache = nocache; } -else if (!warn_shown) +/* +* don't show warning if the pass has been replaced by a token: this is an +* artificial "auth-nocache" +*/ +else if (!warn_shown && (!up->tokenized)) {msg (M_WARN ,"WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this" ); warn_shown = true;
@@ -1357,6 +1361,7 @@ set_auth_token (struct user_pass *up, const char *token) {CLEAR (up->password);strncpynt (up->password, token,USER_PASS_LEN ); + up->tokenized = true; } }
src/openvpn/misc.h +2 -0
@@ -196,6 +196,8 @@ struct user_pass {bool defined;bool nocache; +bool tokenized;/* true if password has been substituted by a token */ +bool wait_for_push;/* true if this object is waiting for a push-reply */ /* max length of username/password */ # ifdef ENABLE_PKCS11
src/openvpn/ssl.c +31 -1
@@ -430,6 +430,8 @@ ssl_set_auth_nocache (void) { passbuf.nocache = true; auth_user_pass.nocache = true; +/* wait for push-reply, because auth-token may invert nocache */ + auth_user_pass.wait_for_push = true; }/*
@@ -438,6 +440,13 @@ ssl_set_auth_nocache (void)void ssl_set_auth_token (const char *token) { +if (auth_user_pass.nocache) + { +msg (M_INFO , +"auth-token received, disabling auth-nocache for the " +"authentication token" ); + auth_user_pass.nocache = false; + }set_auth_token (&auth_user_pass, token); }
@@ -1944,7 +1953,21 @@ key_method_2_write (struct buffer *buf, struct tls_session *session) goto error;if (!write_string (buf, auth_user_pass.password,-1 )) goto error; -purge_user_pass (&auth_user_pass, false); +/* if auth-nocache was specified, the auth_user_pass object reaches +* a "complete" state only after having received the push-reply +* message. +* This is the case because auth-token statement in a push-reply would +* invert its nocache. +* +* For this reason, skip the purge operation here if no push-reply +* message has been received yet. +* +* This normally happens upon first negotiation only. +*/ +if (!auth_user_pass.wait_for_push) + { +purge_user_pass (&auth_user_pass, false); + } }else {
@@ -3620,6 +3643,13 @@ done: return BSTR (&out); } +void +delayed_auth_pass_purge (void ) +{ + auth_user_pass.wait_for_push = false; +purge_user_pass (&auth_user_pass, false); +} +#else static void dummy (void ) {}#endif /* ENABLE_CRYPTO && ENABLE_SSL*/
src/openvpn/ssl.h +2 -0
@@ -503,6 +503,8 @@ void show_tls_performance_stats(void);/*#define EXTRACT_X509_FIELD_TEST*/ void extract_x509_field_test (void ); +void delayed_auth_pass_purge (void ); +#endif /* ENABLE_CRYPTO && ENABLE_SSL */ #endif
Am 25.02.17 um 14:10 schrieb David Sommerseth:
Quoted 17 lines · Gert Doering
Quoted 6 lines
Hi,
Quoted 3 lines · Antonio Quartulli
When the auth-token option is pushed from the server to the client, the latter has to ignore the auth-nocache directive (if specified).
Quoted 6 lines
Quoted 2 lines
The password will now be substituted by the unique token, therefore it can't be wiped out, otherwise the next renegotiation will fail.
Without looking at the patch itself - is this suitable material for inclusion in 2.3? We do have quite a few "slow adopters" - and this is a very useful feature to mitigate SWEET32 in 2FA environments...
The code paths involved shouldn't be very differ too much between v2.3 and v2.4. So I would say this should go into v2.3 as well.
Quoted 9 lines
Attached is a very preliminary (and only compile and 'make check' tested) patch of a backport to v2.3. This needs to get a thorough test as well before we'll send an official patch to this ML.
Btw. since I have worked closely with Antonio on this patch, testing and debugging and discussing it for some time, I think it would be good if someone else than me does the final code review and ACK/NAK it. I'm not able to be objective on this patch.
Code looks good. So ACK. We probably need another revision on this auth-token client support (for reconnects) but this is going in the right direction.
Arne
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Your patch has been applied to the following branches
commit 571165360db0392fa83ec8e6f8de145f623c53fe (master) commit e4b0600c990b06ef4c94856e12b24a37110e0860 (release/2.4)
Author: Antonio Quartulli Date: Sat Feb 25 08:40:14 2017 +0800
Ignore auth-nocache for auth-user-pass if auth-token is pushed
Trac: #840
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg14194.html
Signed-off-by: David Sommerseth <[email protected]...>- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBCAAGBQJZR7CbAAoJEIbPlEyWcf3yD3kP/0UYeVTOU55Yr//+vHKFEGHK Ncw5CQ1KQuefGHZrNATlN1GlZUpg2BAXuUVUHg/LM5fv2PX2xOhSQxmL4gIJkTrp JytLaZEuzj50kxP92BSP57u8VktrX/MIlu6Qi9+wiUR4VI6t2+KpUO0m7e33ojV/ JLO7svccNpmAz6IVoHd0+y0ZXzdxVw2lGSrcnaLkk8JKj1hLXHfkNlNp7USN6LpO 17sOZD1Iyxr4UAdZXDkJtqt3MaeKisZ6lQZbHfcspJl++2dmzIkAPirnyLkgfvrs 4ksv59Al03YNOlwHMbwXS1eacD3cobioxAfqyH1/cISc/G/XZqZjsJt5HWBELc5M di35lOaTDymTGw+s3uTSKuo0V1CHLcRj+bpo2m+pgjlT7nzecHq79fUYmZXH6Axs ABGL7DflcKGo+radf+YSXVVv5XrDj4B1T2Pl7Fx+4e3HlTsJMDAHUL5IHmEWkQRa NWg6FCtZUjjBEg19NFua6vJSWwZ2IeW+G5mlt5zrTyCJONtzxz4zIjdwT++zfDgP DkjZ3WH08KON0H5VOqERvMoGm7Q9UycA72DJjU8pPGbI53ROYoI2CKmYCFFofNoL 0oUy6gmaBdO0Vvr1xINVLK0yZCoZuzjP/hGQV8nK4bPHNsVLhNiyL0Yee2U0zDtg szDR4Rnz530S9yGT1tR5
=QgGQ
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH applied] backport: Ignore auth-nocache for auth-user-pass if auth-token is pushed
In reply to David Sommerseth-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Your patch has been applied to the release/2.3 branch
commit 199ef1321c77c43ca5151119bef65c7a3d8b716f
Author: David Sommerseth Date: Sat Feb 25 14:10:29 2017 +0100
backport: Ignore auth-nocache for auth-user-pass if auth-token is pushed
Trac: #840
Signed-off-by: Antonio Quartulli
Acked-by: Arne Schwabe
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg14194.html
Signed-off-by: David Sommerseth
Message-Id: <[email protected]...>
Acked-by: Arne Schwabe
URL: https://www.mail-archive.com/[email protected]/msg14201.html
- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBCAAGBQJZR7FkAAoJEIbPlEyWcf3yikEP/2hNM6ZrkrG+dPO2wDc1zJVl 3radjwCBMWJmXaBIEDMr7c/qauAlThUJSqYtAsWD4Gb1yNxyxm2XzJ/T/DvduWAF p/pXl/9y6ZeWSxTbmUlyLJmgV4G6wV7X+InztvY6ewTe78JWRN3qf/NPHaO46VlK vCiB01d3YBRmIaflvhm3/JVWCsiQ22i4VTzdhJ+1hFe8u+QmqW5RRDzI97+RvOlz qdQJP48DZF80JDgLv+ZshqZF9CfjhaG6c3xj/8kzmExrY1VvLl0HaohHEVlO8NJ3 hqVsgOESy0WzvnPt7uP2o8+Emy3eY6m3qz6Kw75mppU/1Ts0XH7JT3hOQn3OUjE5 hGDv4FvtEoUnw5SjZllvJmghJF17siqfijsT4OdWbPwtgi5FOuva18EjeIHhnxlm EXDZwld69daLtluKfSW+lmtDrjjgHXyC3jQxjzUJ2z4bav+ZoEMG67WBHphpSbVY QdIqpKzuqXjdJrNNeIKOQXtlzAzQAlyvW916YK1DVwTFnb8X87Fi2vxbPKqq1i2E zQVAz+YEnc/oXGbODFA2yB/5udOpTTNFdxrDQ79gKBYwlrpJyo/9/IUv62lE8LdT oq5YTMeQ/n++peKVrYEjKa7737Q+jsybc51liD4eywjKiIrxvnVLiHdztp2/qBpU qHg9V6wdtnEhrd2vwcld
=I6qm
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH applied] backport: Ignore auth-nocache for auth-user-pass if auth-token is pushed
Hi,
Quoted 1 line · David Sommerseth
Your patch has been applied to the release/2.3 branch
Uh? We were talking master and release/2.4, not release/2.3...
But anyway: whatever that patch does, buildbot does not like the result
- all builds have exploded, and as far as I can see, with the same error:
init.o(.text+0x2625): In function `initialization_sequence_completed':/home/buildbot/build-openvpn/build-cron2-freebsd-74-amd64-stable-master--disable-crypto/build/src/openvpn/init.c:1394: undefined reference to `delayed_auth_pass_purge'
What did happen here?
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi,
Quoted 9 lines · Antonio Quartulli
When the auth-token option is pushed from the server to the client, the latter has to ignore the auth-nocache directive (if specified).
The password will now be substituted by the unique token, therefore it can't be wiped out, otherwise the next renegotiation will fail.
Trac: #840
Cc David Sommerseth <[email protected]...>Signed-off-by Antonio Quartulli <[email protected]...>
This patch was still sitting "unanswered" in the list archives (though it never landed in patchwork, as far as I can see).
NAK :-) - on the basis of "multiple rounds of patches from Arne related to auth-nocache and/or auth-token have landed in 2.4 and 2.5, so I think the underlying problem has been fixed for good, AND this patch won't apply anymore anyway".
(Going through my "open issues" mail heap for all that has auth-user-pass in the subject, since we finally have inline auth-user-passed done... :-) )
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]...Hi,
Quoted 2 lines · Gert Doering
This patch was still sitting "unanswered" in the list archives (though it never landed in patchwork, as far as I can see).
*sigh*
More coffee on a sunday morning, it seems - this was actually merged just fine, just never recorded in the referenced trac ticket.
So, just ignore me :-)
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]...