open-webui/backend/open_webui
Classic298 de8ea08f5c
Route user-supplied image-URL fetches through an SSRF-safe session (DNS rebinding, CWE-918) (#25960)
The connection-layer DNS-rebinding guard (_SSRFSafeResolver / _SSRFSafeAdapter, PR #24759) was
mounted only on SafeWebBaseLoader. Two user-reachable image fetches validate the URL then fetch
it through the shared get_session() pool with the default resolver, so a TTL-0 rebinding answer
that passed validate_url reaches an internal address at connect:

- get_image_base64_from_url (utils/files.py): user image_url on every chat completion.
- load_url_image (routers/images.py, POST /api/v1/images/edit): user-supplied image field.

Add get_ssrf_safe_session() (a one-off aiohttp session mounting _SSRFSafeResolver) and use it
for both fetches, so the connect-time IP is re-validated and a rebound loopback / RFC1918 /
metadata address is rejected. The shared pool is left untouched for the admin-configured
image-generation callers, which legitimately reach internal hosts.

Co-authored-by: dhyabi2 <32069256+dhyabi2@users.noreply.github.com>
Co-authored-by: geo-chen <2404584+geo-chen@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 23:36:53 +02:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal chore: format 2026-06-01 13:56:55 -07:00
migrations chore: format 2026-06-01 13:56:55 -07:00
models refac 2026-06-16 23:24:27 +02:00
retrieval Route user-supplied image-URL fetches through an SSRF-safe session (DNS rebinding, CWE-918) (#25960) 2026-06-16 23:36:53 +02:00
routers Route user-supplied image-URL fetches through an SSRF-safe session (DNS rebinding, CWE-918) (#25960) 2026-06-16 23:36:53 +02:00
socket chore: format 2026-06-01 13:56:55 -07:00
static chore: format 2026-06-01 14:10:40 -07:00
storage refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tools chore: format 2026-06-01 13:56:55 -07:00
utils Route user-supplied image-URL fetches through an SSRF-safe session (DNS rebinding, CWE-918) (#25960) 2026-06-16 23:36:53 +02:00
__init__.py refac 2026-05-09 02:38:08 +09:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-06-15 23:31:59 +02:00
constants.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
env.py refac 2026-06-01 14:13:28 -07:00
functions.py fix: emit [DONE] for AsyncGenerator pipe returns (#24763) 2026-05-19 22:07:56 +04:00
main.py refac 2026-06-16 23:02:20 +02:00
tasks.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00