Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/image_gen/openai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def _load_image_bytes(ref: str) -> Tuple[bytes, str]:
ref = ref.strip()
lower = ref.lower()
if lower.startswith(("http://", "https://")):
from tools.url_safety import is_safe_url

if not is_safe_url(ref):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requests.get() follows redirects by default, so this only validates the first hop. A public URL can still redirect to a metadata/private address; validate every redirect target before issuing its request, as tools/vision_tools.py:405-417 does.

raise ValueError(
f"Refusing to fetch image from unsafe URL: {ref}"
)
import requests

resp = requests.get(ref, timeout=60)
Expand Down