-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The current implementation of safe_requests parses the hostname from the request URL and checks it against a fairly limited set of IP addresses (namely 198.168.1.1 and the AWS instance metadata URL). This should be fairly easy to bypass by registering a domain name (or finding one that already exists) either with an A record that resolves to one of these restricted addresses, or by hosting a web server that returns a redirect to the restricted address.
I propose the following procedure for sandboxing requests.
- Resolve the host to an IP address, ex.
socket.gethostbyname() - Check that the IP address falls within a set of public IP address ranges
- Swap the hostname of the URL with the resolved IP address
- Hand the request off to
requests
There are many edge cases to handle here, ex. tls hostname verification, proxies, redirects, and it may ultimately be easiest to add functionality to requests and/or urllib to support IP address allow/block lists.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request