Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

feat(security): add validation for file path to prevent path traversal attacks

wizardchen39816f2756d0
diff --git a/internal/router/router.go b/internal/router/router.go
index a6b267683..780f259fc 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -676,6 +676,10 @@ func serveFiles(r *gin.Engine) {
c.JSON(http.StatusBadRequest, gin.H{"error": "missing required parameter: file_path"})
return
}
+ if strings.Contains(filePath, "..") {
+ c.JSON(http.StatusBadRequest, gin.H{"error": "invalid file path"})
+ return
+ }
provider := types.ParseProviderScheme(filePath)