Fix unsafe torch.load with weights_only=False#385
Open
hobostay wants to merge 1 commit into
Open
Conversation
Change torch.load calls to use weights_only=True to prevent arbitrary code execution via pickled objects. The loaded files contain dicts of tensors (e.g., cached prompt outputs) which are supported by weights_only=True in PyTorch 2.0+. This aligns with the existing safe usage in vibevoice_tokenizer_processor.py which already uses weights_only=True. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
torch.loadcalls indemo/realtime_model_inference_from_file.pyanddemo/web/app.pyto useweights_only=Trueweights_only=Falseallows arbitrary code execution via pickled objects in.ptfilesweights_only=Truein PyTorch 2.0+vibevoice_tokenizer_processor.pywhich already usesweights_only=TrueDetails
Affected files:
demo/realtime_model_inference_from_file.py(line 225)demo/web/app.py(line 161-164)Security impact: If a malicious
.ptfile were provided (e.g., a poisoned voice preset),weights_only=Falsewould allow it to execute arbitrary code on the host machine via Python's pickle deserialization.Test plan
weights_only=True🤖 Generated with Claude Code