Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix: ZIP Slip path traversal in CSV import (#3065)

Wang Jinsheng84a9a126378d
diff --git a/internal/subimporter/importer.go b/internal/subimporter/importer.go
index 88059eba..f3205044 100644
--- a/internal/subimporter/importer.go
+++ b/internal/subimporter/importer.go
@@ -17,6 +17,7 @@ import (
"io"
"log"
"os"
+ "path/filepath"
"regexp"
"strings"
"sync"
@@ -411,6 +412,9 @@ func (s *Session) ExtractZIP(srcPath string, maxCSVs int) (string, []string, err
continue
}
+ // Sanitize the file name to prevent ZIP slip path traversal.
+ fName = filepath.Base(fName)
+
s.log.Printf("extracting '%s'", fName)
src, err := f.Open()
if err != nil {