Repository navigation
[Security] Centralize grammar compilation timeout at scheduler level - #45172
Open
jperezdealgaba wants to merge 2 commits into
Open
jperezdealgaba wants to merge 2 commits into
jperezdealgaba wants to merge 2 commits into
Conversation
jperezdealgaba
requested review from
aarnphm,
benchislett,
mgoin and
russellb
as code owners
June 10, 2026 16:57
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
jperezdealgaba
force-pushed
the
fix/structured-output-compilation-timeout
branch
from
June 13, 2026 10:40
9cf912d to
eb0b75c
Compare
Add upper-bound validation at the SamplingParams._verify_args() chokepoint for logit_bias, bad_words, stop_token_ids, and allowed_token_ids. All limits are user-configurable via environment variables so operators can override when their workload legitimately exceeds the defaults: - VLLM_MAX_LOGIT_BIAS_SIZE (default: 0 = vocab_size ceiling) - VLLM_MAX_ALLOWED_TOKEN_IDS (default: 0 = vocab_size ceiling) - VLLM_MAX_STOP_TOKEN_IDS (default: 128) - VLLM_MAX_BAD_WORDS (default: 1000) - VLLM_MAX_BAD_WORD_LENGTH (default: 1000) - VLLM_MAX_BATCH_CONVERSATIONS (default: 1000) For logit_bias and allowed_token_ids the natural ceiling is vocab_size, enforced at verify() time when model_config is available. The env var overrides can tighten this further. Batch chat completions messages list is bounded at the protocol layer (VLLM_MAX_BATCH_CONVERSATIONS) since it has no SamplingParams equivalent. Addresses GHSA-4fv6-24cq-h5pw, GHSA-m9fh-2f8w-jhw9, GHSA-83mh-6mwq-3hg9, and GHSA-rp22-rc8r-qjmh. Signed-off-by: Juan Pérez de Algaba <jperezde@redhat.com> Signed-off-by: jperezde <jperezde@redhat.com>
Replace per-backend run_with_timeout() + semaphore approach with a centralized deadline check at the scheduler's existing promotion poll point. This addresses multiple issues with the previous design: - 4 hung requests permanently exhausted the semaphore, disabling structured output until restart (makes DoS easier to trigger) - Semaphore throttled legitimate traffic (performance regression) - Per-backend wrapping was scattered and hard to maintain New approach: - Record compilation_start_time in StructuredOutputRequest when grammar_init() starts compilation - Scheduler checks elapsed time at the WAITING_FOR_GRAMMAR promotion point; if exceeded, fail the request (not the engine) - Fix _check_grammar_completion to catch ALL exceptions from the Future, not just TimeoutError; store as compile_error and let the scheduler fail the request gracefully - Slim frontend validation to cheap checks only (JSON parsing, schema feature detection, regex buildability, string conversions); let the engine-side compile be the authority The existing bounded ThreadPoolExecutor (cpu_count//2 workers) already provides natural concurrency control for compilation jobs. The compile_regex_with_timeout from PR vllm-project#45118 is preserved as a complementary ReDoS-specific guard for regex patterns. Adds compilation_timeout config field to StructuredOutputsConfig (default: 10s, set to 0 to disable). Addresses GHSA-q9q8-922v-2c42 and GHSA-29wg-4hmv-h32g. Signed-off-by: Juan Pérez de Algaba <jperezde@redhat.com> Signed-off-by: jperezde <jperezde@redhat.com>
jperezdealgaba
force-pushed
the
fix/structured-output-compilation-timeout
branch
from
June 14, 2026 06:55
eb0b75c to
fa5b813
Compare
jperezdealgaba
requested review from
AndreasKaratzas,
ApostaC,
DarkLight1337,
NickLucche,
WoosukKwon,
alexm-redhat,
chaunceyjiang,
heheda12345,
houseroad,
njhill,
orozery,
robertgshaw2-redhat,
tlrmchlsmth,
youkaichao and
ywang96
as code owners
June 14, 2026 06:55
jperezdealgaba
requested review from
ProExpertProg and
yewentao256
as code owners
June 14, 2026 06:55
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce compile_with_timeout() and wrap every grammar/schema/regex compilation call in xgrammar, outlines, and llguidance backends. Adversarial JSON schemas (recursive $ref, deeply nested oneOf/anyOf), regex patterns, and EBNF grammars can cause exponential DFA state-space explosion that hangs the inference worker indefinitely.
Covered call sites: