An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: Fix path traversal vulnerability in /export/temp/ endpoint (#17656)
Qiaochu Hub763d787d1f2
diff --git a/kernel/server/serve.go b/kernel/server/serve.goindex 5ed8dc6d8f..477110d6af 100644--- a/kernel/server/serve.go+++ b/kernel/server/serve.go@@ -304,10 +304,21 @@ func serveExport(ginServer *gin.Engine) {exportGroup := ginServer.Group("/export/", model.CheckAuth)exportBaseDir := filepath.Join(util.TempDir, "export")- // 应下载而不是查看导出的文件exportGroup.GET("/*filepath", func(c *gin.Context) {if strings.HasPrefix(c.Request.URL.Path, "/export/temp/") {- c.File(filepath.Join(util.TempDir, c.Request.URL.Path))+ tempBaseDir := filepath.Join(util.TempDir, "export", "temp")+ relativePath := strings.TrimPrefix(c.Request.URL.Path, "/export/temp/")+ relativePath = filepath.Clean(relativePath)+ if strings.Contains(relativePath, "..") {+ c.Status(http.StatusUnauthorized)+ return+ }+ fullPath := filepath.Join(tempBaseDir, relativePath)+ if !gulu.File.IsSubPath(tempBaseDir, fullPath) {+ c.Status(http.StatusUnauthorized)+ return+ }+ c.File(fullPath)return}