-
Notifications
You must be signed in to change notification settings - Fork 66
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
Make it easier to prevent Server side request forgery (SSRF) attacks #141
Comments
I would be open to possible refactoring/method extraction so that you could override methods to get the behavior you want. However, understand that I am not the net-http maintainer, so you should get @nurse's opinion. |
I once discussed about a hook for DNS resolution, but failed to get a consensus. I'll discussed about this topic again in a next developer meeting. |
The method was getting large, and in preparation for ruby#141, I thought it would be easier to break up the method into several other methods.
The method was getting large, and in preparation for ruby#141, I thought it would be easier to break up the method into several other methods.
The method was getting large, and in preparation for ruby#141, I thought it would be easier to break up the method into several other methods.
The method was getting large, and in preparation for ruby#141, I thought it would be easier to break up the method into several other methods.
I should note that Golang supports something similar: https://www.agwa.name/blog/post/preventing_server_side_request_forgery_in_golang Reference: golang/go#55301. |
Over the years, we've received many bug bounty reports relating to Server side request forgery (SSRF) attacks. In a nutshell, these attacks use short-lived DNS entries to direct Web hooks and other URLs to internal IP addresses, such as AWS's instance metadata endpoint.
To a large extent, the problem is mitigated by using HTTPS, since a SSL certificate Common Name (CN) must match the hostname. However, there are a number of edge cases where HTTPS doesn't solve the issue. For example:
In the past, we've mitigated the problem by:
net-http
to use the original hostname by overriding thehostname=
method.A similar approach is taken by
ssrf_filter
.However, with #36, our
net-http
patch no longer works becausehostname=
isn't called when an IP address is used. To handle that, arkadiyt/ssrf_filter#54 introduced an even uglier patch that overrides theResolv
equality methods.Both
hostname=
andResolv
patches are a bit ugly, but short of patching the#connect
method there's no alternative at the moment.A better approach might be to invoke some callback in
#connect
that will allow the caller to resolve the hostname and decide whether the connection should still proceed.I realize that others might argue that a proxying all external calls via a proxy server is ultimately the right approach, but that's another moving part that requires more setup.
@jeremyevans What do you think about this?
The text was updated successfully, but these errors were encountered: