-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility of directory traversal vulnerability on Static File delivery #44
Comments
Addressed, need to make a release of |
You are correct that http.Dir is safe, but only if the usage itself is safe and the prior use was not. You must have a http.Dir that was created with trusted input, but you passed it the result of a filepath.Join that come from a user request as mentioned in my post. I.E.: static.go starts like: func (e *engine) serveStatic(ctx *Context) error {
// TODO static assets Dynamic minify for JS and CSS for non-dev profile
dir, file := filepath.Split(getFilepath(ctx))
...
fs := ahttp.Dir(dir, ctx.route.ListDir)
// you use http.Dir but your use is incorrect, because the "dir" value comes from user input
// created by getFilePath which is created like:
filepath.Join(AppBaseDir(), ctx.route.Dir, ctx.Req.PathValue("filepath"))
// Which will take the filepath from the request and join it to to AppBaseDir and ctx.route.Dir. But
// this join is relative and traversal is possible, for example if I request ../../../../. I replied to you with what I would do. I'm not sure about the "static" routes.conf stuff, if you are saying |
Yes, I will be making a release tomorrow. |
@cstockton I have read your latest reply, I will update it with clear flow. |
@cstockton using |
@cstockton |
Wow, fantastic job @jeevatkm static.go is concise and secure. I like that you even jail the ctx.route.File despite your earlier reservations due to it being from a config file. Good stuff. |
@cstockton Actually with the latest change I have revisited, both scenario is protected by Would you like to give github star for aah framework? |
@jeevatkm Yep! I noticed and was complimenting the initiative, good job. Have a ⭐ :) |
@cstockton Thank you :) |
On Reddit user epiris reported the possibility of directory traversal vulnerability on Static File delivery.
I have analyzed the issue and pointers from
epiris
. aah framework useshttp.Dir
internally for serving directory listing.http.Dir
has checks forDot-Dot
,\
path separator and\x00
char to preventdirectory traversal vulnerability
.However it is good to place the check at framework before processing an incoming directory listing request.
Thanks to epiris for taking out his time.
Note: Static file/directory delivery scenario's protected by
http.Dir
.Note: As per framework design, this issue possibility is only applicable to directory listing, not for static file serve. Since static file config is defined by application user in theroutes.conf
. aah framework will not entertaint any request if the definition doesn't match from routes.conf.The text was updated successfully, but these errors were encountered: