Repository navigation
[BugFix] Prevent shell injection in cache manager launch commands - #8131
Open
kaltsit-10 wants to merge 1 commit into
Open
kaltsit-10 wants to merge 1 commit into
kaltsit-10 wants to merge 1 commit into
Conversation
Config-derived values are interpolated into shell commands executed with shell=True; quote string values with shlex.quote() so arguments are not re-parsed by the shell. Adds unit tests for both launch paths.
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.
Motivation
launch_cache_manager/launch_cache_messagerassemble a shell command by interpolating configuration-derived values (model path, cache protocol/dtype, splitwise role, the speculative-config JSON, ...) and run it viasubprocess.Popen(..., shell=True).If any interpolated value contains shell metacharacters (space,
;,&&, quotes), the command is re-parsed by the shell:--speculative_config/--default_dtypevalues breaks the manually added quoting,...; cmd) is executed as a separate shell command (CWE-78, command injection).Modifications
fastdeploy/cache_manager/prefix_cache_manager.pyshlex.quote(), including the executable path (sys.executable,py_path).--speculative_config/--default_dtype;shlex.quote()escapes them correctly even when the JSON contains quotes.int(...)conversions), the environment-variable prefixes and the trailing log redirection are unchanged.shlex.quote()returns such values unchanged - so this is a minimal hardening rather than a refactor of the command assembly (env prefixes and the>redirection are intentionally untouched).tests/cache_manager/test_prefix_cache_manager.pyshlex.split(), that values carrying shell metacharacters (model dir; touch ...,zmq && ...) arrive as single, unmodified argv elements for both the cache-manager and cache-messager launch paths.Usage or Command
No new usage. To run the new tests:
Accuracy Tests
Not applicable - this change does not touch model computation, kernels or outputs.
Checklist
[BugFix])pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag. (N/A - this PR targetsdevelop)