Skip to content

Add confine option that confines file responses#47

Merged
kanongil merged 2 commits intohapijs:masterfrom
kanongil:confine-file-path
May 9, 2016
Merged

Add confine option that confines file responses#47
kanongil merged 2 commits intohapijs:masterfrom
kanongil:confine-file-path

Conversation

@kanongil
Copy link
Copy Markdown
Contributor

The is a breaking change, since I decided to use true as the default value.

@kanongil kanongil added feature New functionality or improvement breaking changes Change that can breaking existing code labels Oct 24, 2015
@kanongil
Copy link
Copy Markdown
Contributor Author

The baseDir option should probably also apply to the directory handler, to prevent serving files outside of relativeTo by default.

I plan to amend the PR with this feature.

@kanongil kanongil force-pushed the confine-file-path branch 2 times, most recently from eed1994 to 6468c7e Compare November 8, 2015 23:24
@kanongil
Copy link
Copy Markdown
Contributor Author

kanongil commented Nov 8, 2015

Rebased patch and split into sub patches, renaming the option to confine.

I decided not to include any confine option for the directory handler, as I think it will be more of a nuisance than an actual security feature.

I plan to merge this soon unless there are any objections or concerns?

@kanongil kanongil changed the title Add baseDir option that confines file responses Add confine option that confines file responses Nov 8, 2015
@hueniverse hueniverse added the security Issue with security impact label Nov 9, 2015
@hueniverse
Copy link
Copy Markdown
Contributor

I don't get it.

I understand how this can be useful in a directory handler where you are serving content based on the request, but is there a real use case for file when you specify the file you want?

Also, directory already have this: https://github.com/hapijs/inert/blob/master/lib/directory.js#L81-L83
Is that not enough?

Seems like an odd feature for the file handler. I can see how it might be useful for the reply.file() method in case you pass it a runtime filename.

@kanongil
Copy link
Copy Markdown
Contributor Author

Yeah, it is primarily targeted at reply.file() but also the plain file handler with a function based path.

The other target is the directory handler, where it allows me to remove the hack you mention and fix #5.

I am definitely open to change the defaults for the file handler if you think it will cause issues?

@hueniverse
Copy link
Copy Markdown
Contributor

Ok. We can give this a try. See how many people report issues. But need to apply to directory.

@chrisisbeef
Copy link
Copy Markdown

@hueniverse / @kanongil - I am curious why this PR hasn't been merged in and pushed yet? This seems to resolve this particular issue, and more importantly is solves a very real security issue. Can you guys provide us with an update on this PR?

@kanongil kanongil force-pushed the confine-file-path branch from 41732aa to 98b502c Compare May 9, 2016 09:42
@kanongil kanongil force-pushed the confine-file-path branch from 98b502c to 7251728 Compare May 9, 2016 09:46
@kanongil kanongil merged commit d53a0ec into hapijs:master May 9, 2016
@kanongil kanongil added this to the 4.0.0 milestone May 9, 2016
@kanongil kanongil self-assigned this May 9, 2016
@lock
Copy link
Copy Markdown

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

breaking changes Change that can breaking existing code feature New functionality or improvement security Issue with security impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants