Browse Source

修正path中目录穿越漏洞

master
xyiege 5 months ago
parent
commit
ee55db8deb
  1. 11
      aufs/core/AuFile.go

11
aufs/core/AuFile.go

@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"net/rpc/jsonrpc"
"strings"
)
type AuResp struct {
@ -18,6 +19,16 @@ type AuResp struct {
func Flist(w http.ResponseWriter, r *http.Request) {
// 监视运行目录
wdir := r.URL.Query().Get("path")
// 如果请求的path中有 ../ 需要删除
wdir = strings.Replace(wdir, "../", "", -1)
// 如果请求的path中以 / 结尾需要删除
if wdir[len(wdir)-1] == '/' {
wdir = wdir[:len(wdir)-1]
}
// 如果请求的path中以 / 开头需要删除
if wdir[0] == '/' {
wdir = wdir[1:]
}
// 主机
srcip := r.URL.Query().Get("srcip")
srcip = util.Base64dec(srcip)

Loading…
Cancel
Save