mirror of
				https://github.com/axllent/mailpit.git
				synced 2025-10-31 00:07:43 +02:00 
			
		
		
		
	Security: Don't allow tar files containing a ".."
This commit is contained in:
		| @@ -8,6 +8,7 @@ import ( | ||||
| 	"io" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 	"syscall" | ||||
| ) | ||||
|  | ||||
| @@ -184,6 +185,10 @@ func extract(filePath string, directory string) error { | ||||
| 		} | ||||
|  | ||||
| 		fileInfo := header.FileInfo() | ||||
| 		// paths could contain a '..', is used in a file system operations | ||||
| 		if strings.Contains(fileInfo.Name(), "..") { | ||||
| 			continue | ||||
| 		} | ||||
| 		dir := filepath.Join(directory, filepath.Dir(header.Name)) | ||||
| 		filename := filepath.Join(dir, fileInfo.Name()) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user