Skip to content
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

Fix unsafe torch.load by adding weights_only=True #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FlyingFathead
Copy link

@FlyingFathead FlyingFathead commented Sep 23, 2024

Fix Description: Resemblyzer Unsafe Pickle Loading Mitigation

In version 0.1.4 of Resemblyzer, the use of torch.load() without explicitly setting weights_only=True can expose users to potential risks when loading pickled files. Pickle files can execute arbitrary code during deserialization, leading to security vulnerabilities, and current versions of torch warn about this.

To address this, I modified Resemblyzer's voice_encoder.py to enforce safer loading practices. Specifically, we updated the torch.load() calls to include the parameter weights_only=True, ensuring that only model weights are loaded without executing untrusted code.

This modification secures the file loading process and mitigates the risks associated with untrusted data deserialization. The change was made directly in the codebase without using external scripts to patch the system.

Details of the Change:

  • File: voice_encoder.py
  • Version: Resemblyzer 0.1.4
  • Modification: Added weights_only=True to all torch.load() calls that previously lacked this parameter.

FYI: Since the currently implemented torch.load() method is considered unsafe, I've been using an automated code patching script for my whisper-transcriber-telegram-bot when it comes to loading Resemblyzer-related stuff. Should someone need to patch their v0.1.4, the script I made is here. I haven't experienced any bugs or glitches when using the weights_only=True load method in my own application.

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.

2 participants