Skip to content
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

This should fix a path enumeration issue #70

Closed
wants to merge 4 commits into from

Conversation

dxa4481
Copy link

@dxa4481 dxa4481 commented Jan 20, 2015

I got rid of normilize here because join normilizes, and I added this to resolve the issue found here TeamMentor/TM_4_0_Design#206

@dougwilson
Copy link
Contributor

Great! I can look into why the changes are making the tests fail.

@dougwilson
Copy link
Contributor

The change also seems to make pretty much every single test fail on Windows.

@dougwilson dougwilson self-assigned this Jan 20, 2015
@dougwilson
Copy link
Contributor

The change also seems to make pretty much every single test fail on Windows.

Looks like the main reason for the Windows failures is because join(root, path) will never equal root + path under any circumstance because of the fact that URLs have forward slashes and Windows uses backslashes in file paths.

@dxa4481
Copy link
Author

dxa4481 commented Jan 20, 2015

Ahh, gotcha. Sorry I didn't run the tests; I set up the test suite now and am having another go at it.

@dougwilson
Copy link
Contributor

No problem :) I just haven't yet gotten to a machine to be able to look into anything yet. Your effort is greatly appreciated!

@dougwilson
Copy link
Contributor

Oh, and I think if I were to give the fix a goal, it would be that "at no point, should the path ever descend below the root".

@dougwilson
Copy link
Contributor

Ok, I got back and I have a perfect solution :)! Basically, just normalize the rhs first, then there is a simple check for a leading up directive.

@dxa4481
Copy link
Author

dxa4481 commented Jan 20, 2015

Oh man! That's probably simpler than what I ended up doing, but the tests pass with my latest commit

root = normalize(root + sep)

// check for exiting current dir
var traversalCheck = rawPath.split(sep);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't work on Windows ;) sep === '\\' on there, and path will just contain forward slashes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think eventually in the far distant future we'll finally have path.split in Node.js core, haha.

@dougwilson dougwilson added the bug label Jan 20, 2015
dougwilson added a commit that referenced this pull request Jan 20, 2015
@dougwilson
Copy link
Contributor

Ok, @dxa4481 @DinisCruz if you guys want to confirm the current master (npm install tj/send) and poke at it, I would love a confirmation :) Then I'll roll it up into Express 4.11.1 and 3.19.1, and whatever else I can get my hands on.

@DinisCruz
Copy link

Great stuff, I'll take a look and its great to see such a fast fix.

I will try to also add a unit test that checks for the edge cases discovered

@dougwilson
Copy link
Contributor

Awesome, @DinisCruz :) The final commit does have one unit test (98a5b89), but if you want to add more, that would be great :)

@dougwilson
Copy link
Contributor

So far send has been published as 0.11.1

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

Successfully merging this pull request may close these issues.

3 participants