feat(url_safety): add allow_benchmark_ips to exempt RFC 2544 benchmark range 198.18.0.0/15 - #26064
feat(url_safety): add allow_benchmark_ips to exempt RFC 2544 benchmark range 198.18.0.0/15#26064Jensenwgd wants to merge 2 commits into
Conversation
…k range 198.18.0.0/15 Solves DNS fake IP misidentification where github.com/pypi.org resolve to 198.18.x.x (IANA reserved for benchmark testing) and get blocked as non-private reserved IPs. Changes: - Add allow_benchmark_ips config toggle (default false) - Add HERMES_ALLOW_BENCHMARK_IPS env var (highest priority) - 198.18.0.0/15 is now controllable independently from private URL protection - Existing SSRF protection for 10.x, 192.168.x, 100.64.0.0/10 etc. unchanged - 110 tests passing
Security:
|
|
The underlying issue (RFC 2544 range blocked) was already resolved by merged #14054 ( |
… for all private IPs
The original allow_benchmark shortcut was:
if not allow_all_private and not allow_private_ip and not allow_benchmark and _is_blocked_ip(ip):
This means 'allow_benchmark=True' skips the entire _is_blocked_ip() check,
opening all private ranges (10.x, 192.168.x, CGNAT, etc.) — not just
198.18.0.0/15.
Correct structure (reviewer liuhao10264):
if not allow_all_private and not allow_private_ip and _is_blocked_ip(ip):
if allow_benchmark and ip in _BENCHMARK_NETWORK:
... # benchmark IP only
else:
return False # all other blocked IPs still blocked
Also: add tests/conftest.py to prevent HERMES_ALLOW_BENCHMARK_IPS env var
leaking into pytest-xdist worker processes during parallel test runs.
|
@liuhao1024 Good catch — you are right. The original short-circuit Fixed in the latest push. The correct structure now: Added regression tests:
Also fixed test isolation issue in conftest.py where HERMES_ALLOW_BENCHMARK_IPS=true in the host environment was leaking into pytest-xdist worker processes. |
|
@alt-glitch Agreed — |
|
Thanks for addressing a real granularity gap: current main still rejects a normal host resolving to Problems
Suggested changes
Automated hermes-sweeper review. |
Summary
In DNS fake IP environments (common in China), / can resolve to IPs in (RFC 2544 benchmark range). Hermes correctly identifies these as non-private, but had no way to exempt them, causing false positives.
This PR adds an independent
allow_benchmark_ipstoggle to precisely control198.18.0.0/15without affecting other reserved ranges or SSRF protection.Config
Priority
HERMES_ALLOW_BENCHMARK_IPSenv var (highest)security.allow_benchmark_ipsin config.yamlfalse(benchmarks blocked)What is NOT affected
allow_private_urlsremains fully independent