Conversation
36ab0ac to
068e45c
Compare
068e45c to
f688492
Compare
|
At The guard predates this PR ( |
Replace environment-dependent test_loopback_always_rejected with two deterministic tests using a stub resolver: - test_loopback_accepted_by_default (local-first, block_private=False) - test_loopback_rejected_in_strict_mode (block_private=True) The old test only passed when localhost resolved to ::1 (hit is_reserved), not because loopback was actually always rejected. Co-Authored-By: Santoshkumarpuppala
|
Good catch. You're right that The intended behavior is local-first, so loopback should be accepted by default and rejected when I've updated the tests to use a stub resolver (same pattern as |
Summary
POST /api/model-endpoints/testandPOST /api/model-endpointsaccept arbitrary user-supplied URLs and make HTTP requests to them via_probe_endpoint()with zero SSRF protection — no scheme check, no DNS resolution, no private-IP filtering. This fix applies the existingcheck_outbound_url()guard fromsrc/url_safety.py, matching every other route that accepts external URLs.Linked Issue
Closes #6315
Type of Change
What Changed
check_outbound_url(base_url)at the top of bothPOST /api/model-endpoints/test(routes/model_routes.py:2257) andPOST /api/model-endpoints(routes/model_routes.py:2026)MODELENDPOINT_BLOCK_PRIVATE_IPSenv var added, following the existing convention (EMBEDDING_BLOCK_PRIVATE_IPS,IMAGE_BLOCK_PRIVATE_IPS, etc.) — defaultfalse(local-first)tests/test_model_endpoint_ssrf.pyWhy
Both handlers called
_probe_endpoint()(which makes HTTP requests to arbitrary hosts) on user-supplied URLs with no validation. An admin (or anyone exploiting the auth system) could probe cloud metadata athttp://169.254.169.254/latest/meta-data/, scan internal networks athttp://10.x.x.x, or exfiltrate data viagopher:///file://URLs.Every other route that accepts external URLs already uses
check_outbound_url(): embedding (line 266), contacts (line 68), gallery (lines 335, 1272, 1536), notes (line 455), and webhooks (line 108). The model endpoint routes are the only two exceptions.Diff
How to Test
POST /api/model-endpoints/testwithbase_url=http://169.254.169.254/latest/meta-data/Runtime Validation
Checklist