Skip to contentSkip to conversation

Make auth-nocache cooperate with auth-token

PATCH In review [email protected]... 2 participants 5 messages Feb 8, 2017 – Feb 9, 2017 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make auth-nocache cooperate with auth-token

From: Selva Nair <[email protected]...>

- Keep the username even if auth-nocache is specified so that any auth_token pushed by the server could be utilized
- When auth-token is received, set nocache = false in user_pass

Note: When handling of auth failure due to token expiry is fixed, remember to re-instate nocache after clearing the token

Trac: #840

---
 src/openvpn/misc.c | 6 ++++--
 src/openvpn/ssl.c  | 4 ++++
 2 files changed, 8 insertions(+), 2 deletions(-)
src/openvpn/misc.c +4 -2
index a2f45b6..5954eea 100644
@@ -1490,10 +1490,12 @@ purge_user_pass(struct user_pass *up, const bool force)
 void
 set_auth_token(struct user_pass *up, const char *token)
 {
-    if (token && strlen(token) && up && up->defined && !up->nocache)
+    if (token && strlen(token) && up && strlen(up->username))
     {
-        CLEAR(up->password);
+        secure_memzero(up->password, sizeof(up->password));
         strncpynt(up->password, token, USER_PASS_LEN);
+        up->nocache = false;
+        up->defined = true;
     }
 }
 
src/openvpn/ssl.c +4 -0
index 86450fe..e25e99d 100644
@@ -2383,7 +2383,11 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)
         {
             goto error;
         }
+        /* keep username for use with any auth-token pushed by the server */
+        char username[USER_PASS_LEN];
+        strncpynt(username, auth_user_pass.username, sizeof(username));
         purge_user_pass(&auth_user_pass, false);
+        strncpynt(auth_user_pass.username, username, sizeof(auth_user_pass.username));
     }
     else
     {
Signature · 1 line
2.1.4
#1 lore raw
Quoted 4 lines · On Wed, Feb 08, 2017 at 02:25:44PM -0500, [email protected]... wrote:

From: Selva Nair <[email protected]...>

- Keep the username even if auth-nocache is specified so that any auth_token pushed by the server could be utilized

This means that even when using no auth-token the username will be cached. Can this be a security concern? Maybe not because the username is already cached in the terminal? (Somebody had to type it)

Cheers,

Signature · 1 line
Antonio Quartulli
author
#2 lore raw

Hi,

Quoted 9 lines · Antonio Quartulli
Quoted 4 lines · On Wed, Feb 08, 2017 at 02:25:44PM -0500, [email protected]... wrote:

From: Selva Nair <[email protected]...>

- Keep the username even if auth-nocache is specified so that any auth_token pushed by the server could be utilized

This means that even when using no auth-token the username will be cached. Can this be a security concern?

I would consider username as not sensitive material although not sure everyone would agree. Unfortunately there is no way to know in advance that auth-token may get pushed so I can't think of a good way of avoiding this. A not so secure approach (I considered this first) would be to delay clearing the username/password to post pushed-options processing, but then one has to handle cases like what if the push reply never arrives and so on.. In general its always better to clear sensitive data at the earliest.

The way out would be to do one more purge_user_pass(.., false) after push processing.. sigh.. will go there only if absolutely necessary.

Selva

#3 lore raw
Quoted 22 lines · Selva Nair

Hi,

Quoted 9 lines · Antonio Quartulli
Quoted 4 lines · On Wed, Feb 08, 2017 at 02:25:44PM -0500, [email protected]... wrote:

From: Selva Nair <[email protected]...>

- Keep the username even if auth-nocache is specified so that any auth_token pushed by the server could be utilized

This means that even when using no auth-token the username will be cached. Can this be a security concern?

I would consider username as not sensitive material although not sure everyone would agree. Unfortunately there is no way to know in advance that auth-token may get pushed so I can't think of a good way of avoiding this. A not so secure approach (I considered this first) would be to delay clearing the username/password to post pushed-options processing, but then one has to handle cases like what if the push reply never arrives and so on.. In general its always better to clear sensitive data at the earliest.

Quoted 2 lines

The way out would be to do one more purge_user_pass(.., false) after push processing.. sigh.. will go there only if absolutely necessary.

Yesterday, while discussing the same issue on IRC, I came up with this patch:

http://bpaste.net/show/153e8d51c02d

It does indeed wait for the push-reply to come back before making a decision about wiping the user_pass object or not.
This way also the user is wiped when nocache remains true.

Not sure which approach is better though.

Cheers,

Signature · 1 line
Antonio Quartulli

A message that is not in the archive (sent off-list or not yet received): [email protected]...

#5 lore raw
Quoted 31 lines · Selva Nair

Hi,

Quoted 19 lines · Antonio Quartulli
Quoted 3 lines

I would consider username as not sensitive material although not sure everyone would agree. Unfortunately there is no way to know in advance

that

Quoted 1 line

auth-token may get pushed so I can't think of a good way of avoiding

this.

Quoted 2 lines

A not so secure approach (I considered this first) would be to delay clearing the username/password to post pushed-options processing, but

then

Quoted 2 lines

one has to handle cases like what if the push reply never arrives and so on.. In general its always better to clear sensitive data at the

earliest.

Quoted 3 lines

The way out would be to do one more purge_user_pass(.., false) after push processing.. sigh.. will go there only if absolutely necessary.

Yesterday, while discussing the same issue on IRC, I came up with this patch:

Quoted 6 lines

http://bpaste.net/show/153e8d51c02d

It does indeed wait for the push-reply to come back before making a decision
about wiping the user_pass object or not.
This way also the user is wiped when nocache remains true.

Quoted 5 lines

Very interesting! I know, all that complexity can't be helped when purged from push.c. That apart, imo, delaying purge_user_pass() until push processing is not a good idea as I wrote above. What if push reply does not arrive? It does happen and then the password will never get securely wiped from memory.

Yeah, good point. I thought that openvpn would just exit/fail if no push reply is provided, that is why I did not consider this case.

Then, the purge could be hooked at a later stage, i.e. when the interface has been setup.

Postponing the purge still sounds less hackish to me, but I am not the one deciding :)

Cheers,

Signature · 1 line
Antonio Quartulli