-
Notifications
You must be signed in to change notification settings - Fork 18
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
Properly check for invalid characters when parsing URI-string #25
Comments
This issue was originally inspired by "A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages!" and is thus security relevant. Since this package is an important dependency for many packages, this is probably a critical bug. It should be enough to properly filter for the allowed characters before retrieving the parts of the URL with the regex. For a change, trying this today gives me the following error:
which bubbles up from |
Trying to reproduce this now leads to a error output of `HTTP.get(bad_url)`
However, this is not a good error to receive here and URIs.jl should still catch this much earlier. The reasoning is that if this is run on a machine with vulnerable |
https://github.com/JuliaWeb/HTTP.jl/blob/668e7e68747bb333ebde13af8d16add5b82b3b8a/src/URIs.jl#L120-L132
The quoted section of code doesn't actually check whether a URI contains invalid characters or not - e.g.,
' '
(space character) is not allowed in the host part of an authority (or anywhere in a URI for that matter as far as I can tell), but still makes it through and can lead to some weird requests. There's also no two@
allowed.When parsing user-typed URIs "should attempt to recognize and strip both delimiters and embedded whitespace", according to RFC3986.
It should be noted that the regex from the RFC for seperating valid URIs doesn't check for invalid characters that are not explicitly excluded in the grammar definitions and so is not enough for ensuring a URI is valid.
Here a MWE for showing the fault:
and in a seperate terminal session:
That the request actually goes through is a problem with
Sockets.getaddrinfo
though, since that does no checking either and the underlying OS library returns127.0.0.1
for the (invalid) host127.0.0.1 @test.com
on my machine.The text was updated successfully, but these errors were encountered: