Skip to content

Studio: a remote image_url is forwarded to llama-server, which fetches it from the host #11010

Closed

Description

@danielhanchen

What happens

A remote image_url in an OpenAI-shaped chat request is forwarded verbatim to llama-server on the GGUF path, and llama-server downloads it from the Studio host. A caller who can reach /v1/chat/completions can therefore make the host fetch loopback, a LAN address, or a cloud metadata endpoint.

Reproduced on main (merge base 30c46d509) with the resident backend faked as a loaded vision GGUF:

[warning] Remote image URLs not yet supported: http://169.254.169.254/latest/meta-data/...
status: 200
dispatched: [{"type": "image_url", "image_url": {"url": "http://169.254.169.254/latest/meta-data/", "detail": "auto"}}]

The warning is misleading: the part is logged as unsupported by _extract_content_parts, which is the non-GGUF text-flattening path, but the GGUF path passes the original parts through untouched.

Why the existing guard does not cover it

_preflight_image_for_switch refuses a remote image URL only when the target is not GGUF:

if not target_is_gguf and image_preflight.get("remote") and image_preflight.get("b64") is None:
    raise HTTPException(status_code = 400, detail = "Remote image URLs are not supported. Use a base64 data URL.")

So the one backend that actually acts on the URL is the one that is not checked.

Why it matters beyond a single-user desktop

lan_access.py exists specifically so Studio can be reached from other machines, and API keys gate the route rather than the destination. Once Studio is bound past loopback, this is reachable by anyone who holds a key.

Suggested fix

Two options, in preference order:

  1. Fetch the media ourselves with the IP-pinned helper already in core/inference/external_provider.py (_fetch_image_pinned, https only, pinned IP plus SNI) and forward bytes, so llama-server never dials. This also makes the size limit ours rather than llama.cpp's 10 MB.
  2. Failing that, refuse remote URLs whose host is a non-global literal, the same bar the video path now holds in Studio: accept OpenAI video_url content parts on /v1/chat/completions #10439.

Note that validating a hostname without pinning is weak here either way: llama-server re-resolves, so a name that rebinds between our check and its fetch is not addressable from the Studio side.

Scope

Filed separately from #10439 because it is pre-existing on main and independent of video. #10439 applies option 2 to the remote video URLs it introduces, so the new path holds the higher bar while this one is decided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions