Преглед на файлове

Bugfix: Check share-level write access on the new file name before sending FileRenameInformation to the object store

Tal Aloni преди 7 години
родител
ревизия
7ef87b3cd6
променени са 1 файла, в които са добавени 14 реда и са изтрити 0 реда
  1. 14 0
      SMBLibrary/Server/SMB2/SetInfoHelper.cs

+ 14 - 0
SMBLibrary/Server/SMB2/SetInfoHelper.cs

@@ -56,6 +56,20 @@ namespace SMBLibrary.Server.SMB2
                     return new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_PARAMETER);
                 }
 
+                if ((share is FileSystemShare) && (information is FileRenameInformationType2))
+                {
+                    string newFileName = ((FileRenameInformationType2)information).FileName;
+                    if (!newFileName.StartsWith(@"\"))
+                    {
+                        newFileName = @"\" + newFileName;
+                    }
+                    if (!((FileSystemShare)share).HasWriteAccess(session.SecurityContext, newFileName))
+                    {
+                        state.LogToServer(Severity.Verbose, "SetFileInformation: Rename '{0}{1}' to '{0}{2}' failed. User '{3}' was denied access.", share.Name, openFile.Path, newFileName, session.UserName);
+                        return new ErrorResponse(request.CommandName, NTStatus.STATUS_ACCESS_DENIED);
+                    }
+                }
+
                 NTStatus status = share.FileStore.SetFileInformation(openFile.Handle, information);
                 if (status != NTStatus.STATUS_SUCCESS)
                 {