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

- Implemented a check to reject file paths containing "..", enhancing security against path traversal vulnerabilities in the file serving functionality.
This commit is contained in:
wizardchen
2026-03-23 13:12:56 +08:00
committed by lyingbug
parent b2c009e61c
commit 39816f2756

View File

@@ -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)