goshs: goshs POST 多部分上传中路径名到受限目录的不正确限制(“路径遍历”)
平台
go
组件
github.com/patrickhener/goshs
已修复版本
1.1.5-0.20260401172448-237f3af891a9
### 摘要 * POST 多部分上传目录未清理 | `httpserver/updown.go:71-174` 此发现影响默认配置,不需要标志或身份验证。 ### 详情 **文件:** `httpserver/updown.go:71-174` **触发:** `POST /<path>/upload` (server.go:49-51 检查 `HasSuffix(r.URL.Path, "/upload")`) 文件名已清理(删除斜杠,第 105-106 行),但目标目录来自未经清理的 `req.URL.Path`: ```go upath := req.URL.Path // unsanitized targetpath := strings.Split(upath, "/") targetpath = targetpath[:len(targetpath)-1] // strips trailing "upload" target := strings.Join(targetpath, "/") filenameSlice := strings.Split(part.FileName(), "/") filenameClean := filenameSlice[len(filenameSlice)-1] // filename sanitized finalPath := fmt.Sprintf("%s%s/%s", fs.UploadFolder, target, filenameClean) ``` 该路由要求 URL 以 `/upload` 结尾。攻击者使用类似 `/../../target_dir/upload` 的路径,后缀满足路由,并且 `../..` 逃脱了 webroot。磁盘上的文件名由攻击者通过多部分 `filename` 字段控制(在 basename 提取之后)。 **影响:** U
修复方法
暂无官方补丁。请查找临时解决方案或持续关注更新。