Server: Fix issue when GSSAPI SessionKey is null (#182)

This commit is contained in:
Gabe Kirkpatrick 2023-05-18 23:20:34 -07:00 committed by GitHub
parent 23fbe4feca
commit 4c59c21670
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -38,7 +38,7 @@ namespace SMBLibrary.Server.SMB1
object accessToken = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.AccessToken); object accessToken = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.AccessToken);
bool? isGuest = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.IsGuest) as bool?; bool? isGuest = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.IsGuest) as bool?;
if (sessionKey.Length > 16) if (sessionKey != null && sessionKey.Length > 16)
{ {
// [MS-CIFS] 3.3.5.43 If the session key is equal to or longer than 16 bytes, only the least significant 16 bytes MUST be stored in Server.Session.SessionKey // [MS-CIFS] 3.3.5.43 If the session key is equal to or longer than 16 bytes, only the least significant 16 bytes MUST be stored in Server.Session.SessionKey
sessionKey = ByteReader.ReadBytes(sessionKey, 0, 16); sessionKey = ByteReader.ReadBytes(sessionKey, 0, 16);
@ -128,7 +128,7 @@ namespace SMBLibrary.Server.SMB1
object accessToken = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.AccessToken); object accessToken = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.AccessToken);
bool? isGuest = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.IsGuest) as bool?; bool? isGuest = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.IsGuest) as bool?;
if (sessionKey.Length > 16) if (sessionKey != null && sessionKey.Length > 16)
{ {
// [MS-CIFS] 3.3.5.43 If the session key is equal to or longer than 16 bytes, only the least significant 16 bytes MUST be stored in Server.Session.SessionKey // [MS-CIFS] 3.3.5.43 If the session key is equal to or longer than 16 bytes, only the least significant 16 bytes MUST be stored in Server.Session.SessionKey
sessionKey = ByteReader.ReadBytes(sessionKey, 0, 16); sessionKey = ByteReader.ReadBytes(sessionKey, 0, 16);

View file

@ -71,7 +71,7 @@ namespace SMBLibrary.Server.SMB2
object accessToken = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.AccessToken); object accessToken = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.AccessToken);
bool? isGuest = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.IsGuest) as bool?; bool? isGuest = securityProvider.GetContextAttribute(state.AuthenticationContext, GSSAttributeName.IsGuest) as bool?;
if (sessionKey.Length > 16) if (sessionKey != null && sessionKey.Length > 16)
{ {
// [MS-SMB2] 3.3.1.8 SessionKey MUST be set to the first 16 bytes of the cryptographic key queried from the GSS protocol for this authenticated context. // [MS-SMB2] 3.3.1.8 SessionKey MUST be set to the first 16 bytes of the cryptographic key queried from the GSS protocol for this authenticated context.
sessionKey = ByteReader.ReadBytes(sessionKey, 0, 16); sessionKey = ByteReader.ReadBytes(sessionKey, 0, 16);