match mount points on a segment boundary in handle_file_request - #2529
Merged
Conversation
Owner
|
@metsw24-max thanks for the excellent contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mount point matched mid-segment in handle_file_request
The mount point is compared as a plain byte prefix, so a mount of
/mountalso serves/mountdir/...out of the same directory; with the pairing the ServerTest fixture already uses (/on./www,/mounton./www2),GET /mountdir/test.htmlanswers 200 with the contents of./www2/dir/test.html. Nothing escapes the base directory sinceis_valid_pathstill rejects traversal, but the mounted tree becomes reachable under URLs outside the prefix the mount declares, so a reverse proxy location, auth filter or cache rule keyed on/mount/quietly stops covering files it was meant to guard.Matching now has to land on a segment boundary. A mount point that already ends in
/, the root mount included, keeps its current behaviour, andset_mount_pointguarantees the value is non-empty and starts with/.