filepath-clean-misuse
Clean
is not intended to sanitize against path traversal attacks. This function is for finding the shortest path name equivalent to the given input. Using Clean
to sanitize file reads may expose this application to path traversal attacks, where an attacker could access arbitrary files on the server. To fix this easily, write this: filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))
However, a better solution is using the SecureJoin
function in the package filepath-securejoin
. See https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme.path-traversal-inside-zip-extraction
bad-tmp-file-creation
potential-dos-via-decompression-bomb
io.CopyN()
can specify a size.