Skip to content

Commit 76c1889

Browse files
fix: restrict Image.open() formats to prevent PSD parsing (workaround) (#6214)
Signed-off-by: Dan Gil <dagil@nvidia.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6759dc8 commit 76c1889

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

components/src/dynamo/sglang/multimodal_utils/multimodal_image_loader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ async def load_image(self, image_url: str) -> Image.Image:
9191
raise ValueError(f"Invalid image source scheme: {parsed_url.scheme}")
9292

9393
# PIL is sync, so offload to a thread to avoid blocking the event loop
94-
image = await asyncio.to_thread(Image.open, image_data)
94+
# Restrict to supported formats to prevent PSD parsing
95+
image = await asyncio.to_thread(
96+
Image.open, image_data, formats=["JPEG", "PNG", "WEBP"]
97+
)
9598

9699
# Validate image format and convert to RGB
97100
if image.format not in ("JPEG", "PNG", "WEBP"):

components/src/dynamo/vllm/multimodal_utils/image_loader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ async def load_image(self, image_url: str) -> Image.Image:
7878
raise ValueError(f"Invalid image source scheme: {parsed_url.scheme}")
7979

8080
# PIL is sync, so offload to a thread to avoid blocking the event loop
81-
image = await asyncio.to_thread(Image.open, image_data)
81+
# Restrict to supported formats to prevent PSD parsing
82+
image = await asyncio.to_thread(
83+
Image.open, image_data, formats=["JPEG", "PNG", "WEBP"]
84+
)
8285

8386
# Validate image format and convert to RGB
8487
if image.format not in ("JPEG", "PNG", "WEBP"):

examples/multimodal/utils/image_loader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ async def load_image(self, image_url: str) -> Image.Image:
7878
raise ValueError(f"Invalid image source scheme: {parsed_url.scheme}")
7979

8080
# PIL is sync, so offload to a thread to avoid blocking the event loop
81-
image = await asyncio.to_thread(Image.open, image_data)
81+
# Restrict to supported formats to prevent PSD parsing
82+
image = await asyncio.to_thread(
83+
Image.open, image_data, formats=["JPEG", "PNG", "WEBP"]
84+
)
8285

8386
# Validate image format and convert to RGB
8487
if image.format not in ("JPEG", "PNG", "WEBP"):

0 commit comments

Comments
 (0)