fix: add weights_only=True to torch.load in run_multimodal.py#103
Open
cyberkittens4u wants to merge 1 commit into
Open
fix: add weights_only=True to torch.load in run_multimodal.py#103cyberkittens4u wants to merge 1 commit into
cyberkittens4u wants to merge 1 commit into
Conversation
Add weights_only=True to torch.load() call. Without this flag, loading a malicious checkpoint executes arbitrary Python via pickle deserialization (CWE-502). Reported via Google AIVRP issue 500737486.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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
scripts/run_multimodal.pyline 116 callstorch.load()withoutweights_only=True. PyTorch uses pickle for checkpoint deserialization by default; a maliciously crafted checkpoint file can execute arbitrary code when loaded, giving an attacker full RCE on any machine running this script with a controlled checkpoint path.Vulnerable call:
Fix:
weights_only=Truerestricts pickle to safe tensor types only, eliminating the deserialization attack surface.This issue was reported through Google's AI Vulnerability Rewards Program (AIVRP), issue 500737486.
Sibling scripts
run.pyandrun_xla.pyare not affected — they usemodel.load_weights()which has a safe code path.Refs: PyTorch security advisory on torch.load, CWE-502 (Deserialization of Untrusted Data).