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"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "missing required parameter: file_path"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if strings.Contains(filePath, "..") {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid file path"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
provider := types.ParseProviderScheme(filePath)
|
provider := types.ParseProviderScheme(filePath)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user