Skip to content

safe_requests feature request #13

@tjs-intel

Description

@tjs-intel

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.

  1. Resolve the host to an IP address, ex. socket.gethostbyname()
  2. Check that the IP address falls within a set of public IP address ranges
  3. Swap the hostname of the URL with the resolved IP address
  4. 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 request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions