[Bugfix] Handle DoS Overflow Cases (#6598)

Signed-off-by: Alex Brooks <albrooks@redhat.com>
This commit is contained in:
Alex Brooks authored and GitHub committed 2026-08-25 16:09:03 +00:00
1 parent 497c537c6f
commit 0eb47b76d0
7 files changed
+175 -58

No files matched your search

+21 -7
View File
@@ -1,9 +1,15 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
import math
from typing import Any, Literal
import numpy as np
from pydantic import AliasChoices, BaseModel, Field, field_validator, model_validator
# Bound int request fields to avoid overflow issues.
_INT64_MIN = -(2**63)
_INT64_MAX = 2**63 - 1
_MAX_EMBEDDING_DIM = 8192
SUPPORTED_AUDIO_FORMATS: frozenset[str] = frozenset({"wav", "pcm", "flac", "mp3", "opus"})
@@ -142,18 +148,21 @@ class OpenAICreateSpeechRequest(BaseModel):
)
max_new_tokens: int | None = Field(
default=None,
ge=1,
le=_INT64_MAX,
description="Maximum tokens to generate",
)
seed: int | None = Field(
default=None,
ge=0,
le=2**63 - 1,
ge=_INT64_MIN,
le=_INT64_MAX,
description="Random seed for reproducible generation. When set, ensures "
"deterministic output for the same input text and seed value.",
)
initial_codec_chunk_frames: int | None = Field(
default=None,
ge=0,
le=_INT64_MAX,
description="Per-request initial chunk size override. If null, computed dynamically based on server load.",
)
non_streaming_mode: bool | None = Field(
@@ -365,10 +374,14 @@ class OpenAICreateAudioGenerateRequest(BaseModel):
)
num_inference_steps: int | None = Field(
default=None,
ge=1,
le=_INT64_MAX,
description="Number of inference steps",
)
seed: int | None = Field(
default=None,
ge=_INT64_MIN,
le=_INT64_MAX,
description="Random seed for reproducibility",
)
@@ -413,8 +426,8 @@ class SpeechBatchItem(BaseModel):
ref_audio: str | None = None
ref_text: str | None = None
x_vector_only_mode: bool | None = None
max_new_tokens: int | None = None
initial_codec_chunk_frames: int | None = Field(default=None, ge=0)
max_new_tokens: int | None = Field(default=None, ge=1, le=_INT64_MAX)
initial_codec_chunk_frames: int | None = Field(default=None, ge=0, le=_INT64_MAX)
non_streaming_mode: bool | None = None
@@ -433,8 +446,8 @@ class BatchSpeechRequest(BaseModel):
ref_audio: str | None = None
ref_text: str | None = None
x_vector_only_mode: bool | None = None
max_new_tokens: int | None = None
initial_codec_chunk_frames: int | None = Field(default=None, ge=0)
max_new_tokens: int | None = Field(default=None, ge=1, le=_INT64_MAX)
initial_codec_chunk_frames: int | None = Field(default=None, ge=0, le=_INT64_MAX)
non_streaming_mode: bool | None = None
@@ -517,10 +530,11 @@ class StreamingSpeechSessionConfig(BaseModel):
instructions: str | None = None
response_format: Literal["wav", "pcm", "flac", "mp3", "opus"] = DEFAULT_AUDIO_FORMAT
speed: float | None = Field(default=1.0, ge=0.25, le=4.0)
max_new_tokens: int | None = Field(default=None, ge=1)
max_new_tokens: int | None = Field(default=None, ge=1, le=_INT64_MAX)
initial_codec_chunk_frames: int | None = Field(
default=None,
ge=0,
le=_INT64_MAX,
description="Initial chunk size for reduced TTFA. Overrides the deploy config for this session.",
)
non_streaming_mode: bool | None = Field(
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""
OpenAI-compatible protocol definitions for image generation.
@@ -21,6 +21,10 @@ from pydantic import BaseModel, Field, field_validator
from vllm_omni.entrypoints.openai.image_api_utils import validate_layered_layers
# Bound int request fields to avoid overflow issues.
_INT64_MIN = -(2**63)
_INT64_MAX = 2**63 - 1
_IMAGE_FILE_METADATA = {
"jpg": ("jpg", "image/jpeg"),
"jpeg": ("jpeg", "image/jpeg"),
@@ -144,7 +148,7 @@ class ImageGenerationRequest(BaseModel):
default=None,
description="Optional model-specific parameters passed directly to the model's extra_args.",
)
seed: int | None = Field(default=None, description="Random seed for reproducibility")
seed: int | None = Field(default=None, ge=_INT64_MIN, le=_INT64_MAX, description="Random seed for reproducibility")
generator_device: str | None = Field(
default=None,
description="Device for the seeded torch.Generator (e.g. 'cpu', 'cuda'). Defaults to the runner's device.",
+21 -11
View File
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""
OpenAI-compatible protocol definitions for video generation.
@@ -20,6 +20,10 @@ from pydantic import BaseModel, ConfigDict, Field, StringConstraints, field_vali
from vllm_omni.entrypoints.openai.image_api_utils import parse_size
from vllm_omni.inputs.data import DIFFUSION_QUALITY_LEVELS
# Bound int request fields to avoid overflow issues.
_INT64_MIN = -(2**63)
_INT64_MAX = 2**63 - 1
class VideoGenerationStatus(str, Enum):
QUEUED = "queued"
@@ -48,10 +52,10 @@ def file_extension(media_type: str):
class VideoParams(BaseModel):
"""Optional block for video-specific parameters."""
width: int | None = Field(default=None, ge=1, description="Video width in pixels")
height: int | None = Field(default=None, ge=1, description="Video height in pixels")
num_frames: int | None = Field(default=None, ge=1, description="Number of frames")
fps: int | None = Field(default=None, ge=1, description="Frames per second for output video")
width: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Video width in pixels")
height: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Video height in pixels")
num_frames: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Number of frames")
fps: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Frames per second for output video")
@property
def size(self) -> str | None:
@@ -140,10 +144,10 @@ class VideoGenerationRequest(BaseModel):
user: str | None = Field(default=None, description="User identifier for tracking")
# Video-specific fields (top-level for OpenAI-style compatibility)
width: int | None = Field(default=None, ge=1, description="Video width in pixels")
height: int | None = Field(default=None, ge=1, description="Video height in pixels")
fps: int | None = Field(default=None, ge=1, description="Frames per second for output video")
num_frames: int | None = Field(default=None, ge=1, description="Number of frames to generate")
width: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Video width in pixels")
height: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Video height in pixels")
fps: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Frames per second for output video")
num_frames: int | None = Field(default=None, ge=1, le=_INT64_MAX, description="Number of frames to generate")
aspect_ratio: str | None = Field(
default=None,
description=(
@@ -151,7 +155,12 @@ class VideoGenerationRequest(BaseModel):
"FL2VA follows the input image; Ref2VA defaults to 16:9."
),
)
short_edge: int | None = Field(default=None, ge=1, description="MiniMax H3 output short edge in pixels")
short_edge: int | None = Field(
default=None,
ge=1,
le=_INT64_MAX,
description="MiniMax H3 output short edge in pixels",
)
num_outputs_per_prompt: int = Field(
default=1,
ge=1,
@@ -218,7 +227,7 @@ class VideoGenerationRequest(BaseModel):
le=20.0,
description="True CFG scale (model-specific parameter, may be ignored if not supported)",
)
seed: int | None = Field(default=None, description="Random seed for reproducibility")
seed: int | None = Field(default=None, ge=_INT64_MIN, le=_INT64_MAX, description="Random seed for reproducibility")
generate_sound: bool = Field(
default=False,
description="Request model-generated audio for video models that support sound generation.",
@@ -237,6 +246,7 @@ class VideoGenerationRequest(BaseModel):
frame_interpolation_exp: int = Field(
default=1,
ge=1,
le=_INT64_MAX,
description="Interpolation exponent: 1=2x temporal resolution, 2=4x, etc.",
)
frame_interpolation_scale: float = Field(