Skip to content

Reject oversized media before fully downloading it - #51896

Merged
DarkLight1337 merged 5 commits into
vllm-project:mainfrom
KernelClint:fix/ghsa-p6g9-media-fetch-before-size-limit
Aug 24, 2026
Merged

DarkLight1337 merged 5 commits into
vllm-project:mainfrom
KernelClint:fix/ghsa-p6g9-media-fetch-before-size-limit

Conversation

@KernelClint

Copy link
Copy Markdown
Member

Reject oversized media before fully downloading it

What this fixes

Several media paths checked size only after a remote response or inline audio value had already
been turned into one complete bytes object. Batch speech requests could also download several
oversized rows concurrently before applying their per-row limit.

For example, with a 1 MiB limit, a remote server can return a 2 MiB body. Before this change,
async_get_bytes() called the response's full-body read and allocated all 2 MiB before any limit
ran. After this change, vLLM checks Content-Length when present and otherwise reads bounded
chunks, stopping as soon as the cumulative total exceeds 1 MiB. Oversized inline base64 audio is
rejected from its encoded length before decoding.

Why it matters

A client able to submit media URLs or batch audio could force the API or batch process to consume
memory and download bandwidth chosen by the remote response, even though the request would later
be rejected. Concurrent rows multiplied that cost and could make the process run out of memory.

The change

The three related sites are combined in commit 4cb3fe0:

Site What now happens
PTP-VLLM-037 β€” chat audio URL downloads stream under the audio byte limit; oversized base64 is rejected before decoding.
PTP-VLLM-038 β€” batch speech The audio byte limit is passed into each URL download before concurrent row processing.
PTP-VLLM-094 β€” shared remote media VLLM_MAX_MEDIA_DOWNLOAD_SIZE_MB sets a shared default ceiling; sync and async readers check headers and streamed bytes before caching or decoding.

PTP-VLLM-041 is intentionally not included. Current main already has stronger per-modality item
validation in the Rust frontend, and applying the older patch would weaken that behavior.

How it was tested

PTP-VLLM-037 changed from 4 failures without the fix to all 4 passing. PTP-VLLM-038 changed from
3 failures and 1 pass to all 4 passing. The PTP-VLLM-094 module could not collect on the old tree
because the new shared limit did not exist; with the change, all 4 tests passed.

The cases cover a declared oversized Content-Length, chunked responses without that header, an
exact-limit control, early stop after the first over-limit chunk, base64 pre-checking, and batch
handler code not being reached for an oversized row.

Reference

Advisory: GHSA-p6g9-7v3x-m8mv

Track B: this is a public PR against vllm-project/vllm@main.

Credit

  • @KernelClint (Clinton Thomas) and @dhalf (Lucas Bourtoule)
  • Patch the Planet (Trail of Bits + OpenAI collaboration); discovered using GPT-5.5-Cyber

All commits include DCO Signed-off-by trailers.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork β€” automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify

mergify Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--51896.org.readthedocs.build/en/51896/

@mergify mergify Bot added documentation Improvements or additions to documentation frontend multi-modality Related to multi-modality (#4194) labels Aug 11, 2026
@KernelClint
KernelClint force-pushed the fix/ghsa-p6g9-media-fetch-before-size-limit branch from 4cb3fe0 to aa3f321 Compare August 12, 2026 02:35

@DarkLight1337 DarkLight1337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's remove the redundant ValidationError in _preprocess_speech_to_text

Comment thread vllm/connections.py Resolved
@KernelClint

Copy link
Copy Markdown
Member Author

Benchmark: you're right, b"".join(...) is much faster β€” 256 MiB (median of 5): 16KiB chunks 6.0ms join vs 61ms extend; 32KiB 6.4 vs 42; 64KiB 5.5 vs 39ms. Switched the bounded readers to collect chunks and b"".join at the end; the streaming size-cap early-abort still fires on the first over-limit chunk.

Redundant ValidationError: the check in run_batch applies the size limit during the streaming download, so an oversized remote file is aborted before it's fully materialized. That is the fetch-before-size-limit fix, which is distinct from the post-download check in _preprocess_speech_to_text (serving.py:277), which is not modified by this PR. I can drop it if you'd prefer to rely solely on the post-download check, but worth considering that we would lose the early-abort on oversized downloads.

@DarkLight1337

DarkLight1337 commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Let's delete it since the post-download check happens after the checks introduced by this PR anyway

@KernelClint

Copy link
Copy Markdown
Member Author

Done β€” removed the batch download size pre-check (run_batch.py); the batch path now relies on the existing post-download file-size check in _preprocess_speech_to_text, as you noted. The online media-fetch streaming cap in connections.py is unchanged.

@DarkLight1337

DarkLight1337 commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Actually I meant the other way round. If the checks from this PR could catch invalid sizes early, then there should be no need for the post-download check in _preprocess_speech_to_text, so you could remove the latter.

@KernelClint

Copy link
Copy Markdown
Member Author

Thanks β€” I traced the paths into that check, and it looks like it's the only guard for run_batch requests whose file_url is a data:;base64 blob, which run_batch decodes directly with no earlier cap. The other routes are already bounded before :277: online multipart uploads via read_upload_with_limit, and batch HTTP(S) file_urls via this PR's streaming download cap. (The online audio endpoints don't accept URL or data: inputs at all β€” file must be an upload.)

Because of that one path, :277 can't just be deleted as-is β€” batch base64 audio would become unbounded. Ideas:

  • (a) leave :277 in place as the backstop for the batch base64 path, or
  • (b) I add an early size cap at the batch base64 decode too, so every path is bounded up front β€” then :277 can be removed.

I've restored the batch download cap in the meantime. Thoughts?

@DarkLight1337

Copy link
Copy Markdown
Member

I prefer option (b)

@KernelClint
KernelClint requested a review from Isotr0py as a code owner August 13, 2026 23:35
@KernelClint

Copy link
Copy Markdown
Member Author

Done. Added the size cap in run_batch.py so all three audio paths (online uploads, batch URLs + batch base64) are bounded up front. Removed the post-download check in _preprocess_speech_to_text. Please approve if you're good with the changes.

@DarkLight1337 DarkLight1337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM now, thanks!

@DarkLight1337
DarkLight1337 enabled auto-merge (squash) August 14, 2026 04:16
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 14, 2026
@mergify

mergify Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @agentzappo.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

auto-merge was automatically disabled August 14, 2026 11:29

Head branch was pushed to by a user without write access

@KernelClint
KernelClint force-pushed the fix/ghsa-p6g9-media-fetch-before-size-limit branch from f6b0b08 to d9418b6 Compare August 14, 2026 11:29
@mergify mergify Bot removed the needs-rebase label Aug 14, 2026
@russellb
russellb enabled auto-merge (squash) August 14, 2026 20:04
auto-merge was automatically disabled August 19, 2026 17:53

Head branch was pushed to by a user without write access

@KernelClint
KernelClint force-pushed the fix/ghsa-p6g9-media-fetch-before-size-limit branch from dea099f to ab7b91f Compare August 19, 2026 17:53
@DarkLight1337

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

βœ… Triggered Buildkite CI #84648 for commit ab7b91f615d8.

@mergify

mergify Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @agentzappo.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Aug 21, 2026
KernelClint and others added 5 commits August 23, 2026 19:29
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>

Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
Remove the run_batch audio-download size guard per review; the batch path
relies on the existing post-download file-size validation in
_preprocess_speech_to_text. The online media-fetch streaming cap is unchanged.

Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
Reinstate the early streaming size cap on batch audio downloads; the
post-download check remains the only size guard for batch base64 (data:)
file_url inputs, so it stays as a backstop.

Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
@KernelClint
KernelClint force-pushed the fix/ghsa-p6g9-media-fetch-before-size-limit branch from ab7b91f to 073cf2f Compare August 23, 2026 23:43
@mergify mergify Bot removed the needs-rebase label Aug 23, 2026
@DarkLight1337
DarkLight1337 enabled auto-merge (squash) August 23, 2026 23:46
@DarkLight1337

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

βœ… Triggered Buildkite CI #85257 for commit 073cf2f8ec02.

@DarkLight1337
DarkLight1337 merged commit 2ec6f0d into vllm-project:main Aug 24, 2026
6 checks passed
@KernelClint

Copy link
Copy Markdown
Member Author

Thanks for merging this, @DarkLight1337! #51895 (the PyAV / IAMF parser fix) is also approved and green on all checks now β€” good to merge whenever you have a moment. Appreciate you helping move these along.

am-cohere pushed a commit to am-cohere/vllm that referenced this pull request Sep 1, 2026
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
mikeshawcode pushed a commit to mikeshawcode/vllm that referenced this pull request Sep 1, 2026
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
Signed-off-by: mikeshawcode <michaelwshaw2@gmail.com>
vrdn-23 added a commit to vrdn-23/vllm that referenced this pull request Oct 8, 2026
…nflicts

Took the branch's vllm/envs.py wholesale: main's legacy TYPE_CHECKING block
and environment_variables dict are already superseded by the pydantic
*Settings models here. Then ported main's semantic delta from the 57
main-side commits that touched vllm/envs.py since 03a8d0b:

  vllm-project#52431 VLLM_USE_MODELSCOPE: description (bool already accepts "1")
  vllm-project#52216 prefix_cache_retention_interval promoted to an arg (see vllm-project#55353)
  vllm-project#48484 + VLLM_REPLICATE_EMBED
  vllm-project#52633 + VLLM_CPU_CI_ENV
  vllm-project#52182 - VLLM_TEST_FORCE_FP8_MARLIN
  vllm-project#52523 VLLM_API_KEY not a compile factor (branch already marked it)
  vllm-project#52998 VLLM_ALLREDUCE_USE_FLASHINFER default -> True
  vllm-project#53040 + VLLM_DISABLE_DSV4_MEGAMOE_SHARED_EXPERT_FUSION
  vllm-project#53053 + VLLM_KIMI_K3_GEMM_AR
  vllm-project#50501 + VLLM_XPU_INC_WNA16_BACKEND (case-sensitive Literal)
  vllm-project#52018 + VLLM_B12X_MOE_FP4_FORCE_A16
  vllm-project#43018 + VLLM_KV_OFFLOAD_MAX_BATCH_DESCRIPTORS
  vllm-project#51718 VLLM_KV_CACHE_LAYOUT Literal widened to 8 layouts + description
  vllm-project#51896 + VLLM_MAX_MEDIA_DOWNLOAD_SIZE_MB
  vllm-project#53219 VLLM_ENABLE_COHERE_API: description
  vllm-project#53559 - VLLM_TRITON_ATTN_USE_TD shim (already absent on the branch)
  vllm-project#53561 VLLM_MAX_AUDIO_CLIP_FILESIZE_MB: description
  vllm-project#53378 VLLM_ELASTIC_EP_SCALE_UP_LAUNCH not a compile factor
  vllm-project#53141 VLLM_ROCM_USE_AITER_FP4_ASM_GEMM removed; restored by vllm-project#57055
  vllm-project#54160 + VLLM_ENABLE_HPC_OPS
  vllm-project#53536 + VLLM_XPU_FORCE_N_CONTIG_WEIGHT
  vllm-project#53576 + VLLM_ALLREDUCE_USE_FLASHINFER_PCIE_IPC
  vllm-project#54632 + VLLM_MAX_EMBED_DECODE_BYTES (not a compile factor)
  vllm-project#54579 + VLLM_ENABLE_SCALE_OUT_ENDPOINTS; removed by vllm-project#55176 (net zero)
  vllm-project#53491 VLLM_GPU_SYNC_CHECK: description
  vllm-project#54371 + VLLM_PLE_CPU_OFFLOAD; reworked vllm-project#56512, dropped vllm-project#57937 (net zero)
  vllm-project#48247 VLLM_ROCM_USE_AITER_CUSTOM_AR: description
  vllm-project#55353 - VLLM_MM_HASHER_ALGORITHM (+ _lower_mm_hasher),
         - VLLM_PREFIX_CACHE_RETENTION_INTERVAL
  vllm-project#54985 - VLLM_NIXL_EP_MAX_NUM_RANKS
  vllm-project#56512 VLLM_PLE_CPU_OFFLOAD rework (net zero, see vllm-project#54371)
  vllm-project#55176 - VLLM_ENABLE_SCALE_OUT_ENDPOINTS (net zero, see vllm-project#54579)
  vllm-project#53940 + VLLM_ROCM_USE_AITER_MOE_SITUV2 (case-insensitive Literal)
  vllm-project#41074 + VLLM_SKIP_VERSION_SUFFIX (not a compile factor)
  vllm-project#48599 - envs.validate_environ (moved to Platform.validate_environ,
         which reads the branch's environment_variables shim)
  vllm-project#52136 pydocstyle docstring restyle of legacy helpers (no-op here)
  vllm-project#57212 docstring rejoin of legacy helpers (no-op here)
  vllm-project#56913 + FORCE_COLOR (alias, non-"0" is True, not a compile factor)
  vllm-project#57055 VLLM_ROCM_USE_AITER_FP4_ASM_GEMM restored (net zero, see vllm-project#53141)
  vllm-project#57142 shm buffer name autogen -> new _generate_shm_name() (<=30 chars)
  vllm-project#56685 VLLM_HUMMING_INPUT_QUANT_CONFIG: description
  vllm-project#57937 - VLLM_PLE_CPU_OFFLOAD (net zero, see vllm-project#54371)
  vllm-project#50814 + VLLM_MXFP4_EMULATION_DEQUANT_AT_LOAD
  vllm-project#57428 + VLLM_ENABLE_GEMM_RS, - VLLM_KIMI_K3_GEMM_RS
  vllm-project#51600 - VLLM_XPU_ENABLE_XPU_GRAPH
  vllm-project#58582 + VLLM_TRITON_JIT_WARMUP_NUM_THREADS (not a compile factor)
  vllm-project#55145 + VLLM_XPU_PP_MICROBATCH
  vllm-project#58201 VLLM_ROCM_USE_AITER_MOE_SITUV2 6-way choice,
         - VLLM_ROCM_USE_AITER_MOE_SITUV2_A8W4
  vllm-project#58919 + VLLM_MOONCAKE_CONNECTOR_TIMEOUT
  vllm-project#56861 + VLLM_ROCM_AITER_MLA_DCP_VERIFY (case-insensitive Literal)
  vllm-project#53492 + VLLM_ROCM_USE_AITER_TRITON_SPARSE_MLA
  vllm-project#57991 VLLM_DEEPEP_V2_ALLOW_HYBRID_MODE default True (branch already
         True) + description
  vllm-project#58819 + VLLM_ROCM_USE_AITER_MOE_A4W4_DSV4 (tri-state, bool(int(v)))
  vllm-project#50300 + VLLM_CHAT_TEMPLATE_RENDER_TIMEOUT
  vllm-project#54024 VLLM_CPU_INT4_W4A8: description
  vllm-project#59781 - VLLM_ENGINE_ITERATION_TIMEOUT_S
  vllm-project#57995 + VLLM_FLASHINFER_MOE_A2A_LOW_PRECISION_COMBINE
  vllm-project#59965 VLLM_ROCM_AITER_MLA_DCP_VERIFY default route (final "auto")

Also VLLM_SSM_CONV_STATE_LAYOUT's description follows vllm-project#51718's layout rename.

Parity: 311 branch fields vs 311 main runtime entries, no difference in
either direction. Every var's value matches main's lambdas in an empty
environment and under 15 override scenarios, except case normalization of
the two lowercased ROCm choices (both callers already call .lower()).

Intentionally not ported: main's new consumer tests that match
env_with_choices' error text (test_invalid_backend_value_raises,
test_dcp_verify_env_rejects_unknown_route, and the ROCm-gated
test_aiter_moe_situv2_rejects_unknown_activation) fail on this branch:
pydantic's ValidationError names the field, not the env var. Invalid values
are still rejected. Tracked as a branch-wide follow-up.

Other conflicts and merge fallout:
- requirements/docs.txt, requirements/test/{cpu,cuda,rocm,xpu}.txt: took
  main's lockfiles and regenerated them with the pip-compile pre-commit
  hooks; they differ from main only by the branch's pydantic-settings lines.
- tests/test_envs_pydantic.py: dropped the mm-hasher test, pointed the
  validate_environ tests at Platform.validate_environ, updated the shm-name
  prefix assertion.
- check-test-tethering (new on main): wired test_envs_pydantic.py into the
  CPU params/env job; allowlisted tests/docs/test_env_vars_gen.py, which
  cannot run from a CI job's tests/ cwd (tests/docs shadows docs/).

Tests: pytest tests/test_envs.py tests/test_envs_pydantic.py
tests/docs/test_env_vars_gen.py -> 55 passed; pre-commit run --files on all
changed files -> clean.

AI assistance (Claude) was used for this merge resolution.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Vinay Damodaran <vrdn@hey.com>
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation frontend multi-modality Related to multi-modality (#4194) ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants