fix: add weights_only=True to torch.load calls in apply_delta.py#3863
Open
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Open
fix: add weights_only=True to torch.load calls in apply_delta.py#3863Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Conversation
torch.load without weights_only=True uses pickle deserialization, which allows arbitrary code execution from a malicious checkpoint file. Pass weights_only=True to all four torch.load calls so only tensor data is loaded. Fixes lm-sys#3777
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.
Bug
All four
torch.load()calls inapply_delta.pyomitweights_only=True. Without this flag, PyTorch uses pickle deserialization, which allows a maliciously crafted.bincheckpoint to execute arbitrary code on the host machine when loaded.Root cause
torch.loaddefaults toweights_only=Falsefor backward compatibility. PyTorch has deprecated this default since 2.0 and will raise aFutureWarningin affected versions. Explicitly passingweights_only=Truerestricts loading to tensor data only.Fix
Add
weights_only=Trueto all fourtorch.load()calls — lines 37, 90, 97, and 102 — insplit_filesandapply_delta_low_cpu_mem. No behavior change for legitimate.binfiles containing only tensors.Fixes #3777