Fix traversal bug - #306
Merged
Merged
Conversation
ndmitchell
commented
May 28, 2019
Owner
Thanks for the patch. I'm going to need to study this one in detail so will review Thursday. |
ndmitchell
commented
May 30, 2019
Owner
Very nice work - thanks a lot! |
achirkin pushed a commit
to achirkin/hoogle
that referenced
this pull request
Nov 26, 2020
cocreature added a commit
to cocreature/hoogle
that referenced
this pull request
Apr 8, 2021
This fixes another directory traversal for paths of the form http://localhost:8080/..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fetc/nixos/configuration.nix. Also added a bunch of tests for the validation logic since I really don’t trust it given that this is the second issue after the first one got fixed almost two years ago in ndmitchell#306. I’m also starting to wonder if hoogle should have an option to just disable the generic file server completely. In anything some type of production setup, serving the required static assets via nginx seems like a much more sensible solution than trying to get this right in hoogle.
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 freeto 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.
There is a bug in the current path handling code that allows an attacker with direct access to the hoogle server to force it to return files it has access to. This does not seem to work through an nginx proxy such as the setup on hoogle.haskell.org.
Repro on current master:
This PR tries to solve that problem by bridging the existing gap between URI parsing for replays (which does attempt to prevent this kind of issue) and for the server, which for some reason use completely different code paths.