Skip to content

Commit 87c0b05

Browse files
ejohnstownpadelsbach
authored andcommitted
Userauth none bypasses wolfSSHd credential check
When wolfsshd is built with WOLFSSH_ALLOW_USERAUTH_NONE, the DefaultUserAuth() function accepted WOLFSSH_USERAUTH_NONE as a valid auth type and forwarded it to RequestAuthentication(). Since RequestAuthentication() only gates credential checks on PASSWORD and PUBLICKEY types, a none request for any existing system user returned success without verifying any credential. Removed USERAUTH_NONE as an accepted auth type in DefaultUserAuth() so it is treated as an invalid auth type for wolfsshd. Affected function: DefaultUserAuth. Issue: F-3215
1 parent 2568b26 commit 87c0b05

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

apps/wolfsshd/auth.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,8 +1078,11 @@ static int DoCheckUser(const char* usr, WOLFSSHD_AUTH* auth)
10781078
}
10791079

10801080

1081-
/* @TODO this will take in a pipe or equivalent to talk to a privileged thread
1082-
* rather than having WOLFSSHD_AUTH directly with privilege separation */
1081+
/*
1082+
* @TODO this will take a pipe or equivalent to talk to a privileged thread
1083+
* rather than having WOLFSSHD_AUTH directly with privilege separation.
1084+
* Note: authData->type of WOLFSSH_USERAUTH_NONE is not valid for wolfsshd.
1085+
*/
10831086
static int RequestAuthentication(WS_UserAuthData* authData,
10841087
WOLFSSHD_AUTH* authCtx)
10851088
{
@@ -1091,6 +1094,12 @@ static int RequestAuthentication(WS_UserAuthData* authData,
10911094
return WOLFSSH_USERAUTH_FAILURE;
10921095
}
10931096

1097+
if (authData->type == WOLFSSH_USERAUTH_NONE) {
1098+
wolfSSH_Log(WS_LOG_ERROR,
1099+
"[SSHD] Auth type NONE invalid.");
1100+
return WOLFSSH_USERAUTH_INVALID_AUTHTYPE;
1101+
}
1102+
10941103
usr = (const char*)authData->username;
10951104
ret = DoCheckUser(usr, authCtx);
10961105
/* temporarily elevate permissions */
@@ -1291,9 +1300,6 @@ int DefaultUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
12911300
}
12921301

12931302
if (authType != WOLFSSH_USERAUTH_PASSWORD &&
1294-
#ifdef WOLFSSH_ALLOW_USERAUTH_NONE
1295-
authType != WOLFSSH_USERAUTH_NONE &&
1296-
#endif
12971303
authType != WOLFSSH_USERAUTH_PUBLICKEY) {
12981304

12991305
ret = WOLFSSH_USERAUTH_INVALID_AUTHTYPE;

0 commit comments

Comments
 (0)