Purge auth-token as well while purging passwords
PATCH 1/1 Purge auth-token as well while purging passwords
From: Selva Nair <[email protected]...>
Starting from commit e61b401a auth-token is saved in a separate struct from auth-user-pass and is not cleared when ssl_purge_auth() is called. This makes "forget-passwords" sent to the management interface or "--management-forget-disconnect" option not to work as expected.
Purging caused by --auth-nocache is not affected (auth-token is retained in that case as it should be).
Use case:
For Pre-Logon access and persistent connections on Windows, use of "forget-passwords" before disconnect is probably the only way to ensure that no credentials are left behind. Note that openvpn.exe continues to run after disconnect in these cases.
Also, the original intent of "forget-passwords" appears to be to clear all "passwords" that can be used to reconnect.
--- src/openvpn/ssl.c | 1 + 1 file changed, 1 insertion(+)
src/openvpn/ssl.c +1 -0
@@ -492,6 +492,7 @@ ssl_purge_auth(const bool auth_user_pass_only)purge_user_pass (&passbuf, true); }purge_user_pass (&auth_user_pass, true); +purge_user_pass (&auth_token, true);#ifdef ENABLE_MANAGEMENT ssl_purge_auth_challenge ();#endif
Signature · 1 line
2.30.2
Am 20.10.22 um 00:46 schrieb [email protected]...:
Quoted 11 lines
From: Selva Nair <[email protected]...>
Starting from commit
e61b401aauth-token is saved in a separate struct from auth-user-pass and is not cleared whenssl_purge_auth()is called. This makes "forget-passwords" sent to the management interface or "--management-forget-disconnect" option not to work as expected.Purging caused by --auth-nocache is not affected (auth-token is retained in that case as it should be).
Quoted 8 lines
Use case:
For Pre-Logon access and persistent connections on Windows, use of "forget-passwords" before disconnect is probably the only way to ensure that no credentials are left behind. Note that openvpn.exe continues to run after disconnect in these cases.Also, the original intent of "forget-passwords" appears to be to clear all "passwords" that can be used to reconnect.
I had to first figure out what forget-password actually but yes this commit is correct for that obscure feature.
Hi,
Quoted 7 lines · On Wed, Oct 19, 2022 at 06:46:42PM -0400, [email protected]... wrote:
From: Selva Nair <[email protected]...>
Starting from commit
e61b401aauth-token is saved in a separate struct from auth-user-pass and is not cleared whenssl_purge_auth()is called. This makes "forget-passwords" sent to the management interface or "--management-forget-disconnect" option not to work as expected.
I am not sure I can go along with Arne's ACK here - the reason is that ssl_purge_auth() is not only called from man_forget_passwords() (where I'm totally fine with the change) but also on received EEN from the server ("RESTART"), and this patch changes behaviour here.
Without patch:
- server pushes token (secret-based --auth-gen-token)
- server is ctrl-c'ed by admin, sends RESTART
- client calls server_pushed_signal() -> ssl_purge_auth() forgets username + password, but not token
- server is restarted, same token secret
- client reconnects, sends token, is allowed in
With patch:
- server pushes token (secret-based --auth-gen-token)
- server is ctrl-c'ed by admin, sends RESTART
- client calls server_pushed_signal() -> ssl_purge_auth() forgets username + password, but not token
- server is restarted, same token secret
- client reconnects...
2022-10-26 14:38:58 SIGUSR1[soft,server-pushed-connection-reset] received, process restarting 2022-10-26 14:38:58 Restart pause, 5 second(s) ... Enter Auth Username:
... and asks for a username.
I think this is not what this patch is expected to do, and would irk a lot of my 2FA users (that are currently happy that I can restart the openvpn server without them all having to do 2FA again).
There is a theoretical way to avoid this (server needs to send RESTART,P), but the --explicit-exit-notify code on the server has no way to trigger this, so it's not helping.
This also affects --management-forget-disconnect (obscure option of the day), which, I think, should not forget tokens either - but I do not have a strong opinion here. I think OpenVPN should retain tokens on disconnect due to "network change" or whatever, but then, I have no idea when we'd want to use this option in the first place.
The two other places where this is called (SIGUSR1 AUTH FAIL with "auth-retry interact" and man_forget_passwords() should be fine with forgetting tokens - I think "AUTH FAIL" already does this (in some other code path).
I agree with the intent on the patch (Feature-ACK), and would suggest to call "ssl_clean_auth_token()" directly from "man_forget_passwords()" instead. This will catch your (valid) use-case without impacting other users of ssl_purge_auth().
May I also suggest to add a comment to ssl_purge_auth() to clearly state that "this function never clears auth tokens" so we remember next time?
thanks,
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,
Thanks for the detailed analysis!
Quoted 40 lines · Gert Doering
Hi,
Quoted 7 lines · On Wed, Oct 19, 2022 at 06:46:42PM -0400, [email protected]... wrote:
From: Selva Nair <[email protected]...>
Starting from commit
e61b401aauth-token is saved in a separate struct from auth-user-pass and is not cleared whenssl_purge_auth()is called. This makes "forget-passwords" sent to the management interface or "--management-forget-disconnect" option not to work as expected.I am not sure I can go along with Arne's ACK here - the reason is that
ssl_purge_auth()is not only called fromman_forget_passwords()(where I'm totally fine with the change) but also on received EEN from the server ("RESTART"), and this patch changes behaviour here.Without patch:
- server pushes token (secret-based --auth-gen-token)
- server is ctrl-c'ed by admin, sends RESTART
- client callsserver_pushed_signal()->ssl_purge_auth()forgets username + password, but not token
- server is restarted, same token secret
- client reconnects, sends token, is allowed inWith patch:
- server pushes token (secret-based --auth-gen-token)
- server is ctrl-c'ed by admin, sends RESTART
- client callsserver_pushed_signal()->ssl_purge_auth()forgets username + password, but not token
- server is restarted, same token secret
- client reconnects...2022-10-26 14:38:58 SIGUSR1[soft,server-pushed-connection-reset] received, process restarting 2022-10-26 14:38:58 Restart pause, 5 second(s) ... Enter Auth Username:
Quoted 6 lines
... and asks for a username.
I think this is not what this patch is expected to do, and would irk a lot of my 2FA users (that are currently happy that I can restart the openvpn server without them all having to do 2FA again).
I think the intent of the original code is to purge all credentials by default in case of RESTART --- [RESTART,P] was required to preserve credentials as you note below. But somehow we did not keep that behaviour when auth-token was introduced.
But, I agree it may be useful to preserve the token in this case, though it will fail if restart moves to the next server, isn't it?
Quoted 10 lines
There is a theoretical way to avoid this (server needs to send RESTART,P), but the --explicit-exit-notify code on the server has no way to trigger this, so it's not helping.
This also affects --management-forget-disconnect (obscure option of the day), which, I think, should not forget tokens either - but I do not have a strong opinion here. I think OpenVPN should retain tokens on disconnect due to "network change" or whatever, but then, I have no idea when we'd want to use this option in the first place.
IMO, management-forget-disconnect should forget the token along with passwords. The patch is meant to address this option and "forget-passwords". The use case: if you stop the tunnel and put the connection on management-hold and then detach from the management interface, another user connecting to it would be able to connect to it without entering a password. --management-forget-disconnect can protect against this.
Quoted 11 lines
The two other places where this is called (SIGUSR1 AUTH FAIL with "auth-retry interact" and
man_forget_passwords()should be fine with forgetting tokens - I think "AUTH FAIL" already does this (in some other code path).I agree with the intent on the patch (Feature-ACK), and would suggest to call "
ssl_clean_auth_token()" directly from "man_forget_passwords()" instead. This will catch your (valid) use-case without impacting other users ofssl_purge_auth().
I'm okay with this. Will send an amended patch.
Selva
Hi,
Quoted 11 lines · Selva Nair
Quoted 3 lines
I think this is not what this patch is expected to do, and would irk a lot of my 2FA users (that are currently happy that I can restart the openvpn server without them all having to do 2FA again).
I think the intent of the original code is to purge all credentials by default in case of RESTART --- [RESTART,P] was required to preserve credentials as you note below. But somehow we did not keep that behaviour when auth-token was introduced.
But, I agree it may be useful to preserve the token in this case, though it will fail if restart moves to the next server, isn't it?
If you have a number of servers under common management, and they share the auth-token secret key, a token received from "server A" will be valid on "server B". I'd consider that a feature :-)
If the token is refused on server B, the client will come back and look at user+password credentials (which are now flushed, so will ask).
Quoted 10 lines
Quoted 9 lines
There is a theoretical way to avoid this (server needs to send RESTART,P), but the --explicit-exit-notify code on the server has no way to trigger this, so it's not helping.
This also affects --management-forget-disconnect (obscure option of the day), which, I think, should not forget tokens either - but I do not have a strong opinion here. I think OpenVPN should retain tokens on disconnect due to "network change" or whatever, but then, I have no idea when we'd want to use this option in the first place.
Quoted 7 lines
IMO, management-forget-disconnect should forget the token along with passwords. The patch is meant to address this option and "forget-passwords". The use case: if you stop the tunnel and put the connection on management-hold and then detach from the management interface, another user connecting to it would be able to connect to it without entering a password. --management-forget-disconnect can protect against this.
I can see the reasoning for "forget-passwords".
I'm not sure I understand what the intended use of --management-forget-disconnect *is* - if it's "disconnected by a button press", the GUI can send "forget-passwords", and we do not need this option in the first place.
If it's "disconnected by a network hickup", why would one want to flush the token here, which is intended to seamlessly reconnect after the hickup?
Is anyone actually *using* --management-forget-disconnect? Just asking :-)
(This whole token thing is really great when it works, but it is obvious that it wasn't there from day one, and not all combinations of use cases, options and "events" seemt o really make sense)
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 10 lines
I'm not sure I understand what the intended use of --management-forget-disconnect *is* - if it's "disconnected by a button press", the GUI can send "forget-passwords", and we do not need this option in the first place.
If it's "disconnected by a network hickup", why would one want to flush the token here, which is intended to seamlessly reconnect after the hickup?
Here "disconnect" does not mean disconnect from the server, but disconnect the management client from the daemon. I like to refer to it as "detach" from the management interface. When the client detaches it allows another "client" (may be an interactive telnet session) to connect.
So the use case I have is this: the daemon is started by automatic service and is kept running all the time. But the connection requires interactive password entry so the daemon is waiting for password via management i/f. A user connects to the management i/f, say, via telnet, enters password, and completes the connection. When done, the user can stop the tunnel using management-hold and SIGHUP and detach from the management.
A second user can now connect to the management interface and restart the tunnel. --management-forget-disconnect is a safety feature in such cases to ensure the password entered by the first user was forgotten when the user detached from the interface. Including any cached token. Sending "forget-passwords" would also work in this case, but then the user has to remember each time to send it before detaching.
The actual use case is for the GUI handling persistent connections. In this case, you are right, we can send forget-passwords whenever we detach from a persistent or PLAP connection. If users do not want that behaviour by default, we can make it a configurable option in the GUI. But then --management-forget-passwords is such a "user-configurable forget-passwords on detach".
Still not convincing?
Selva
Hi,
Quoted 5 lines · Selva Nair
Quoted 5 lines
I'm not sure I understand what the intended use of --management-forget-disconnect *is* - if it's "disconnected by a button press", the GUI can send "forget-passwords", and we do not need this option in the first place.
Quoted 8 lines
Quoted 3 lines
If it's "disconnected by a network hickup", why would one want to flush the token here, which is intended to seamlessly reconnect after the hickup?
Here "disconnect" does not mean disconnect from the server, but disconnect the management client from the daemon. I like to refer to it as "detach" from the management interface. When the client detaches it allows another "client" (may be an interactive telnet session) to connect.
Ah! I was misunderstanding this option. Yes, in that case, "forget everything, including tokens" seems reasonable.
Quoted 1 line
Still not convincing?
Now it is, thanks :-) - wrong "disconnect".
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/1 Purge auth-token as well while purging passwords
In reply to [email protected]...From: Selva Nair <[email protected]...>
Starting from commit e61b401a auth-token is saved in a separate struct from auth-user-pass and is not cleared when ssl_purge_auth() is called. This makes "forget-passwords" sent to the management interface or "--management-forget-disconnect" option not to work as expected.
Purging caused by --auth-nocache is not affected (auth-token is retained in that case as it should be).
Use case:
For Pre-Logon access and persistent connections on Windows, use of "forget-passwords" before disconnect is probably the only way to ensure that no credentials are left behind. Note that openvpn.exe continues to run after disconnect in these cases.
Also, the original intent of "forget-passwords" appears to be to clear all "passwords" that can be used to reconnect.
v2:
- call ssl_clean_auth_token() directly from manage.c instead of amending ssl_purge_auth()
- Add a comment that ssl_purge_auth() does not clear auth-token
--- src/openvpn/manage.c | 2 ++ src/openvpn/ssl.h | 1 + 2 files changed, 3 insertions(+)
src/openvpn/manage.c +2 -0
@@ -762,6 +762,7 @@ static void man_forget_passwords(struct management *man) {ssl_purge_auth (false); + (void )ssl_clean_auth_token ();msg (M_CLIENT ,"SUCCESS: Passwords were forgotten" ); }
@@ -1922,6 +1923,7 @@ man_reset_client_socket(struct management *man, const bool exiting)if (man->settings.flags &MF_FORGET_DISCONNECT ) {ssl_purge_auth (false); + (void )ssl_clean_auth_token (); }if (man->settings.flags &MF_SIGNAL )
src/openvpn/ssl.h +1 -0
@@ -390,6 +390,7 @@ void ssl_set_auth_nocache(void);/* * Purge any stored authentication information, both for key files and tunnel * authentication. If PCKS #11 is enabled, purge authentication for that too. +* Note that auth_token is not cleared. */ void ssl_purge_auth (const bool auth_user_pass_only);
Signature · 1 line
2.30.2
Thanks. Based on our mail thread on v1, this now clears the token on "management related events" (forget-password, management disconnect) and does not affect other code paths. I have not submitted this to extremely thorough testing, just basic t_client tests for 2.5 and master (which do not exercise these code paths at all).
Your patch has been applied to the master and release/2.5 branch.
commit ecad4839caf4c2fab9c6627ceeca9b9cb32e8929 (master) commit 3d792ae9557b959e796710cf903866d205d979da (release/2.5)
Author: Selva Nair Date: Wed Oct 26 14:55:43 2022 -0400
Purge auth-token as well while purging passwords
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25460.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering