mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-06-04 13:30:32 +08:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user