[Security] Validate cache salts before they reach LMCache (#51444)

Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com>
Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
Clinton Thomas
2026-09-05 03:56:06 +00:00
committed by GitHub
co-authored by Lucas Bourtoule Cyrus Leung
parent 4ee2595512
commit e962733e08
8 changed files with 101 additions and 3 deletions
@@ -11,7 +11,7 @@ from pydantic import (
)
from vllm.config import ModelConfig
from vllm.entrypoints.generate.base.protocol import StreamOptions
from vllm.entrypoints.generate.base.protocol import StreamOptions, validate_cache_salt
from vllm.entrypoints.openai.chat_completion.protocol import (
ChatCompletionLogProbs,
ChatCompletionRequest,
@@ -177,6 +177,13 @@ class GenerateRequest(BaseModel):
instance._sampling_params_provided_keys = provided
return instance
@model_validator(mode="before")
@classmethod
def _validate_cache_salt(cls, data: Any) -> Any:
if isinstance(data, dict):
validate_cache_salt(data.get("cache_salt"))
return data
def is_sampling_param_provided(self, name: str) -> bool:
"""Whether the caller explicitly set ``sampling_params.<name>``.