Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

Inconsistent handling of multiple slashes in path #147

Closed
mikeharder opened this issue Jul 20, 2016 · 8 comments
Closed

Inconsistent handling of multiple slashes in path #147

mikeharder opened this issue Jul 20, 2016 · 8 comments
Assignees

Comments

@mikeharder
Copy link
Contributor

mikeharder commented Jul 20, 2016

StaticFiles is inconsistent with handling of multiple slashes in a path. It appears to be allowed inside a path, but not at the start.

http://host/foo/bar.html  -> 200

http://host//foo/bar.html -> 404

http://host/foo//bar.html -> 200

It should be either allowed or disallowed in all parts of the path.

@Tratcher
Copy link
Member

Is this actually caused by static files logic, or is it physical file provider? Embedded file provider will be different.

@muratg muratg added this to the 1.1.0 milestone Jul 25, 2016
@muratg
Copy link

muratg commented Jul 25, 2016

@JunTaoLuo Could you investigate?

@JunTaoLuo
Copy link
Contributor

Our checks for rooted paths in the physical file provider is preventing the request from being resolved. https://github.com/aspnet/FileSystem/blob/dev/src/Microsoft.Extensions.FileProviders.Physical/PhysicalFileProvider.cs#L201
If we encounter a path that begins with a forward slash, we strip the first slash. However, if you have two, we only strip the first one and the rest is interpreted as an absolute path which we do not allow for security reasons. Maybe we can trim all leading forward slashes? Is there a reason we are not doing that?

@muratg
Copy link

muratg commented Jul 29, 2016

@JunTaoLuo I think that's a good idea. Would that break anything that you can think of?

@JunTaoLuo
Copy link
Contributor

I can't think of any breaks that would be caused by trimming multiple leading slashes. Any concerns @Tratcher? Security especially?

@Tratcher
Copy link
Member

Try it with the StaticFiles tests. Also try it on unix.
@blowdart?

@JunTaoLuo
Copy link
Contributor

Tests run fine and I've tested with the static files on core, full framework and core on osx.

@blowdart
Copy link
Member

What about trying to escape out of the static file root?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants