skillfed

requests-hardened

A library that overrides the default behaviors of the requests library, and adds new security features.

requests-hardened v1.3.0 190.4K downloads/30d#9,913 on PyPI12
Permissive license BSD-3-Clause Active released

What it is and what it does

requests-hardened is a security-focused wrapper around the requests library that applies hardened defaults and adds SSRF protection. It lets you configure global security policies like enforcing request timeouts, disabling redirects, and filtering outbound requests to private IP ranges—preventing server-side request forgery attacks where untrusted user input could be used to probe internal infrastructure.

The library works by wrapping requests.Session and intercepting HTTP calls through a Manager and Config object. You set security policies once (timeout, redirect behavior, SSRF filtering rules) and then use the manager to send requests or get sessions, ensuring those policies apply consistently. It supports proxies including SOCKS4/SOCKS5, and the SSRF filter can be tuned to allow or block loopback addresses depending on your threat model.

Use it for:

  • Protect web applications that make HTTP requests based on user input from SSRF attacks by filtering private IP ranges.
  • Enforce organization-wide HTTP client security policies like mandatory request timeouts and disabled redirects across multiple services.
  • Build secure API clients that reject redirects and enforce User-Agent headers to prevent header injection or redirect-based attacks.
  • Combine with proxy configurations for defense-in-depth, filtering tunneled requests while trusting the proxy itself.
  • Harden microservices that call internal APIs to prevent attackers from pivoting through HTTP requests to localhost or private networks.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Wraps the requests library to enforce security defaults and block SSRF attacks by filtering private and loopback IP addresses.

Yes, if you make HTTP requests based on untrusted user input or need to enforce consistent security defaults across your application. The single dependency on requests, active maintenance, permissive license, and zero known vulnerabilities make it a low-risk addition. Install it if SSRF protection or global timeout/redirect policies matter for your threat model; skip it if your requests are fully trusted or you handle these concerns elsewhere.

Install

requests-hardened on PyPI

pip

pip install requests-hardened

uv

uv add requests-hardened

poetry

poetry add requests-hardened

Installing requests-hardened

Before you install

Low install friction with a single runtime dependency on requests. Active maintenance with a recent release 31 days ago and a commit from 2026-08-10.

License in practice

BSD-3-Clause permissive license allows commercial and private use with minimal restrictions.

Quickstart

pip install requests-hardened

from requests_hardened import Config, Manager

http_manager = Manager(
    Config(
        default_timeout=(2, 10),
        ip_filter_enable=True,
        ip_filter_allow_loopback_ips=False
    )
)
resp = http_manager.send_request("GET", "https://example.com")

Requires Python 3.10 or later. For SOCKS4/SOCKS5 proxy support, requires pip install requests[socks].

Verify before relying

  • Whether SSRF filtering covers all edge cases in URL parsing or DNS rebinding attacks.
  • Performance overhead of IP filtering on high-throughput HTTP clients.
  • Compatibility with requests library versions beyond the tested range.

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 1 — requests
Maintenance actively maintained — 31 days since the last release
Last repo commit
First released
Downloads 190,369/month — #9,913 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: requests_hardened-1.3.0-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: POSIX :: BSDOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Security

Tags

ssrf filter requestsrequests security hardeningblock private ip addresses httpsecure http client defaultsrequests library security wrapper
ssrf-protectionhttp-securityrequests-wrapper

More Security packages