requests-hardened
A library that overrides the default behaviors of the requests library, and adds new security features.
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-hardeneduv
uv add requests-hardenedpoetry
poetry add requests-hardenedInstalling 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
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
advocateAdvocate wraps the requests library to prevent…
permissive · top 15,000 on PyPI
safehttpxWraps httpx.AsyncClient.get() with DNS…
permissive · top 5,000 on PyPI
wrapper-tls-requestsMakes HTTP requests with browser-like TLS…
permissive · top 15,000 on PyPI
redfishA Python library for interacting with…
permissive · top 15,000 on PyPI
django-xffDjango middleware that extracts the real client…
permissive · top 15,000 on PyPI
requests-ntlm2Adds NTLM authentication support to the…
permissive · top 15,000 on PyPI
PySocksPySocks provides a SOCKS and HTTP proxy client…
permissive · top 1,000 on PyPI
requests-mockIntercepts and mocks HTTP requests made through…
permissive · top 1,000 on PyPI
pproxypproxy is an asynchronous proxy server that…
permissive · top 15,000 on PyPI
requests-ntlm3Provides HTTP NTLM authentication for the…
permissive · top 15,000 on PyPI