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.main
parent
b2c009e61c
commit
39816f2756
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue