Skip to content

Fix unsafe torch.load with weights_only=False#385

Open
hobostay wants to merge 1 commit into
microsoft:mainfrom
hobostay:fix/unsafe-torch-load
Open

Fix unsafe torch.load with weights_only=False#385
hobostay wants to merge 1 commit into
microsoft:mainfrom
hobostay:fix/unsafe-torch-load

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 4, 2026

Summary

  • Fix torch.load calls in demo/realtime_model_inference_from_file.py and demo/web/app.py to use weights_only=True
  • Using weights_only=False allows arbitrary code execution via pickled objects in .pt files
  • The loaded files contain dicts of tensors (cached prompt outputs) which are fully 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

Details

Affected files:

  • demo/realtime_model_inference_from_file.py (line 225)
  • demo/web/app.py (line 161-164)

Security impact: If a malicious .pt file were provided (e.g., a poisoned voice preset), weights_only=False would allow it to execute arbitrary code on the host machine via Python's pickle deserialization.

Test plan

  • Verify voice presets load correctly with weights_only=True
  • Verify the loaded data structure is a dict of tensors (no custom Python objects)

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant