-
Notifications
You must be signed in to change notification settings - Fork 134
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
Odd behaviour with static policy using addBase #63
Comments
Actually, come to think of it, maybe it would work better to redo policies so that they expect the request URI as a
Then wai-middleware-static could do |
addBase is insecure, if you do: My version of this code is: import System.FilePath (isAbsolute) addSecureBase :: String -> Policy But addBase may be usefull for some cases. |
I worked out why my code wasn't working; you just need to not include the leading slash in the
@daapp raises a good point. I've just reproduced it locally:
Then |
@daapp wow, this is really bad. I think your |
@xich, what do you think about that? |
@co-dan I also recommend to add noDots to default implementation too. But also leave the way to ignore all these security locks. |
Ugh, thanks for pointing this out... I'll work on fixing this, though patches are welcome! ;-) |
These changes affect the security defaults and will definitely provide better behaviour for the existing users. Issue scotty-web#64 - Implementating noDots by default. Issue scotty-web#63 - Implementating isNotAbsolute by default tightens up the security to a normal standard.
These changes affect the security defaults and will definitely provide better behaviour for the existing users. Issue scotty-web#64 - Implementating noDots by default. Issue scotty-web#63 - Implementating isNotAbsolute by default tightens up the security to a normal standard. Previous request on `localhost:3000//etc/passwd` would print out the contents of `/etc/passwd`. With the added security, the request will now return 404.
Merged and released as wai-middleware-static 0.5.0.0. Thanks for the patch @nhibberd This should fix the absolute path issue (to /etc/passwd for example), but I'm leaving this issue open for now because I think @hdgarrood was right in that policies should work over Also, if anyone finds other gaping security problems, with wai-middleware-static or scotty itself, please let me know! |
Still to do: * Make available versions for a package available as JSON * Amend the version selector so that available versions are loaded via AJAX (so that the HTML doesn't need to change) * Do something about the message for successfully uploaded packages
These changes affect the security defaults and will definitely provide better behaviour for the existing users. Issue #64 - Implementating noDots by default. Issue #63 - Implementating isNotAbsolute by default tightens up the security to a normal standard. Previous request on `localhost:3000//etc/passwd` would print out the contents of `/etc/passwd`. With the added security, the request will now return 404.
I wanted to serve static files from
src/static
, under/static
(soGET /static/some-file
would look forsrc/static/some-file
), so I did this:This didn't quite do what I expected:
I think it's because of
</>
in System.FilePath; it seems it just returns the second argument if it starts with a slash:However curl and firefox both seem to always add this leading slash in the request URI.
Should
addBase
use++
rather thanFP.</>
?The text was updated successfully, but these errors were encountered: