mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-11-04 03:17:00 -05:00 
			
		
		
		
	Fix filesystem pathexists path join
This commit is contained in:
		
							parent
							
								
									6968a5c02a
								
							
						
					
					
						commit
						0135b3560c
					
				@ -89,7 +89,6 @@ class FileSystemController {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const { directory, folderPath } = req.body
 | 
					    const { directory, folderPath } = req.body
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!directory?.length || typeof directory !== 'string' || !folderPath?.length || typeof folderPath !== 'string') {
 | 
					    if (!directory?.length || typeof directory !== 'string' || !folderPath?.length || typeof folderPath !== 'string') {
 | 
				
			||||||
      Logger.error(`[FileSystemController] Invalid request body: ${JSON.stringify(req.body)}`)
 | 
					      Logger.error(`[FileSystemController] Invalid request body: ${JSON.stringify(req.body)}`)
 | 
				
			||||||
      return res.status(400).json({
 | 
					      return res.status(400).json({
 | 
				
			||||||
@ -109,7 +108,8 @@ class FileSystemController {
 | 
				
			|||||||
      return res.sendStatus(404)
 | 
					      return res.sendStatus(404)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const filepath = Path.posix.join(libraryFolder.path, directory)
 | 
					    const filepath = Path.join(libraryFolder.path, directory)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Ensure filepath is inside library folder (prevents directory traversal)
 | 
					    // Ensure filepath is inside library folder (prevents directory traversal)
 | 
				
			||||||
    if (!filepath.startsWith(libraryFolder.path)) {
 | 
					    if (!filepath.startsWith(libraryFolder.path)) {
 | 
				
			||||||
      Logger.error(`[FileSystemController] Filepath is not inside library folder: ${filepath}`)
 | 
					      Logger.error(`[FileSystemController] Filepath is not inside library folder: ${filepath}`)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user