-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: Block path traversal attacks via the deployment API for MLflow-Triton #8665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mudit-eng
merged 9 commits into
main
from
mudita/tri-665-psirt-triton-inference-server-mlflow-plugin-path-traversal
Mar 4, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e2ef312
[TRI-665] Block path traversal attacks via the deployment API for MLf…
mudit-eng 3d1b780
Addressed the PR feedback
mudit-eng fb05d7b
Making pre-commit happy
mudit-eng 88c5f47
Making pre-commit happier
mudit-eng 65ca276
Making pre-commit super happy
mudit-eng b84b9a6
Changed the test name
mudit-eng d329827
Added more checks for model name
mudit-eng df77b0b
Incorporated feedback
mudit-eng 41eb772
Fix CI test
mudit-eng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # Copyright 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # Copyright 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions | ||
|
|
@@ -90,7 +90,7 @@ def create_deployment(self, name, model_uri, flavor=None, config=None): | |
| """ | ||
| Deploy the model at the model_uri to the Triton model repo. Associated config.pbtxt and *labels* files will be deployed. | ||
|
|
||
| :param name: Name of the of the model | ||
| :param name: Name of the model | ||
| :param model_uri: Model uri in format model:/<model-name>/<version-or-stage> | ||
| :param flavor: Flavor of the deployed model | ||
| :param config: Configuration parameters | ||
|
|
@@ -99,6 +99,9 @@ def create_deployment(self, name, model_uri, flavor=None, config=None): | |
| """ | ||
| self._validate_flavor(flavor) | ||
|
|
||
| # Validate model name | ||
| self._validate_model_name(name) | ||
|
|
||
| # Verify model does not already exist in Triton | ||
| if self._model_exists(name): | ||
| raise Exception( | ||
|
|
@@ -513,6 +516,18 @@ def _validate_flavor(self, flavor): | |
| if flavor not in self.supported_flavors: | ||
| raise Exception("{} model flavor not supported by Triton".format(flavor)) | ||
|
|
||
| def _validate_model_name(self, name): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note no need to fix today, there are multiple similar pattern @whoisj added to address PSIRT issues in server. We could refactor them into one common utility fuction. |
||
| # Check if the model name is empty or only contains whitespace, tabs, or newlines | ||
| if name.strip() == "": | ||
| raise Exception( | ||
| "Model name cannot be empty. Please enter a valid name to deploy." | ||
| ) | ||
| # Path traversal protection | ||
| if "/" in name or name == "..": | ||
| raise Exception( | ||
| "Path traversal is not allowed in model's name: {}".format(name) | ||
| ) | ||
|
|
||
| def _model_exists(self, name): | ||
| deploys = self.list_deployments() | ||
| exists = False | ||
|
|
||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.