fix(security): prevent SSRF bypass for IMDS endpoints in browser routing - #16250
fix(security): prevent SSRF bypass for IMDS endpoints in browser routing#16250PratikRai0101 wants to merge 1 commit into
Conversation
|
Recommendation: close as superseded rather than merging this branch as-is. I checked current Validation:
CodeRabbit completed on the uncommitted PR patch and only reported a minor unused Signed: GPT-5.5-xhigh in Codex |
|
Thanks for this — IMDS endpoints are already blocked ahead of the routing decision on current
Appreciate the SSRF analysis — thanks! |
What does this PR do?
This PR patches a P0 SSRF vulnerability where the hybrid browser routing logic unintentionally short-circuits the pre-navigation safety guard.
By default, an agent could bypass the block for link-local addresses (e.g.,
169.254.169.254), allowing it to reach Instance Metadata Services (IMDS) and exfiltrate cloud credentials in AWS, GCP, Azure, or Aliyun environments.This fix decouples the routing decision (
auto_local_this_nav) from the security gate, ensuring_is_safe_url()acts as an absolute gatekeeper before any routing occurs. It also includes a secondary fix for Python 3.10 compatibility regarding private IP classification.Related Issue
Fixes #16234
Type of Change
Changes Made
tools/browser_tool.py(Security Guard): Moved the_is_safe_url()check before the hybrid routing decision for both pre-navigation and post-redirect logic. Theauto_local_this_navflag can no longer short-circuit the safety gate.tools/browser_tool.py(Python 3.10 Compatibility): Replaced the reliance onip.is_privatewith an explicit_PRIVATE_IP_RANGEStuple (RFC1918 +169.254.0.0/16+fd00::/8). This ensures172.16.x.xaddresses don't leak on older Python runtimes.tests/tools/test_browser_ssrf_local.py: AddedTestImdsBlockingWithHybridRoutingcovering AWS, GCP, Azure, and Aliyun metadata endpoints.How to Test
Run the targeted automated test suite:
Manual Verification: Run the Hermes agent configured with a cloud browser provider (e.g., Browserbase) and instruct it to navigate to
http://169.254.169.254/latest/meta-data/.Verify that the agent immediately returns a
Blocked: URL targets a private or internal addresserror JSON rather than successfully retrieving the page.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Test Execution Output: