Merged
Conversation
If a caller-supplied document ID or path contains `..` or `.` segments, it's
possible to use this to traverse to a different path than intended. For example,
a document ID of `x/../../_all` would cause the request to be sent to
`/{index}/_doc/x/../../_all`, which is resolved to `/_all`.
Fix this in `Snap.Request` by validating the path before sending the request,
and rejecting any paths that contain traversal segments or are not absolute with
`Snap.InvalidPathError`.
Some upstream proxies might decode path segments before forwarding requests to Snap, which could allow directory-traversal attacks to bypass the existing validation. Handle this by decoding the path before validating it, so that encoded traversal segments like `%2E%2E` or `%2F..%2F` are properly rejected.
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.
If a caller-supplied document ID or path contains
..or.segments, it's possible to use this to traverse to a different path than intended. For example, a document ID ofx/../../_allwould cause the request to be sent to/{index}/_doc/x/../../_all, which is resolved to/_all.Fix this in
Snap.Requestby validating the path before sending the request, and rejecting any paths that contain traversal segments or are not absolute with aSnap.InvalidPathErrorerror tuple.