goshs: goshs PUT 上传中路径名到受限目录的不正确限制(“路径遍历”)
平台
go
组件
github.com/patrickhener/goshs
已修复版本
1.1.5-0.20260401172448-237f3af891a9
### 摘要 * PUT 上传没有路径清理 | `httpserver/updown.go:20-69` 此发现影响默认配置,不需要标志或身份验证。 ### 详情 **文件:** `httpserver/updown.go:20-69` **触发:** `PUT /<path>` (server.go:57-59 直接路由到 `put()`) 处理程序使用原始的 `req.URL.Path` 来构建保存路径。没有 `filepath.Clean`,没有 `..` 检查,没有 webroot 包含。 ```go func (fs *FileServer) put(w http.ResponseWriter, req *http.Request) { upath := req.URL.Path // unsanitized filename := strings.Split(upath, "/") outName := filename[len(filename)-1] targetpath := strings.Split(upath, "/") targetpath = targetpath[:len(targetpath)-1] target := strings.Join(targetpath, "/") savepath := fmt.Sprintf("%s%s/%s", fs.UploadFolder, target, outName) // ... os.Create(savepath) // arbitrary path write ``` `UploadFolder` 默认为 `Webroot` (main.go:386-388)。该路径是纯字符串连接,没有验证。 **影响:** 未经身份验证的任意文件写入文件系统上的任何位置。 **PoCs:** ```bash #!/usr/bin/env bash # Write an arbitrar
修复方法
暂无官方补丁。请查找临时解决方案或持续关注更新。