Skip to content

fix: validate ensemble composing model names against path traversal#500

Open
LinZiyuu wants to merge 1 commit into
triton-inference-server:mainfrom
LinZiyuu:fix/validate-ensemble-composing-model-names
Open

fix: validate ensemble composing model names against path traversal#500
LinZiyuu wants to merge 1 commit into
triton-inference-server:mainfrom
LinZiyuu:fix/validate-ensemble-composing-model-names

Conversation

@LinZiyuu

Copy link
Copy Markdown

This PR validates ensemble composing model names against path traversal, extending the existing top-level model-name check to the composing models an ensemble references.

Previously, ValidateModelName() (which rejects .. and /) was applied only to the top-level requested model in LoadUnloadModel(). An ensemble's composing model names are read from the model config and fed into the polling loop, where each name is joined onto the repository path (JoinPath) and passed to FileExists() / ReadTextProto(). A composing name such as ../../etc therefore escaped the model repository root: a model-load request could make the server read config.pbtxt files outside the repository and probe arbitrary host paths through the differing load response.

This change validates every composing step model name with ValidateModelName() before it is polled, matching the existing top-level check. Legitimate composing names are ordinary model names and are unaffected.

Reproduced on nvcr.io/nvidia/tritonserver:26.04-py3 (CPU, --model-control-mode=explicit): loading an ensemble whose step model_name was ../secret made the server read and parse /secret/config.pbtxt (a path mounted outside the repository), and a step ../../../../etc made it enumerate /etc; the load response distinguished existing from non-existing targets. After this change the load is rejected with "model name must not contain path traversal characters".

Relates to the model-name validation hardening in #472 / #481.

ValidateModelName() rejects '..' and '/' in a model name, but it is only
applied to the top-level requested model in LoadUnloadModel(). The
composing model names of an ensemble are taken from the model config and
fed into the polling loop, where each name is joined onto the repository
path (JoinPath) and passed to FileExists()/ReadTextProto(). A composing
name such as "../../etc" therefore escapes the model repository root,
letting a model-load request read config files outside the repository and
probe arbitrary host paths via the load response.

Validate every composing step model name with ValidateModelName() before
it is polled, matching the existing top-level check. Legitimate composing
names are ordinary model names and are unaffected.

Signed-off-by: LinZiyuu <linziyu0205@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant