fix: prevent arbitrary code execution in torch.load()#25
Open
rajpratham1 wants to merge 1 commit into
Open
Conversation
Security fix for vulnerability where torch.load() was used without weights_only=True, allowing potential arbitrary code execution. Changes: - Add secure checkpoint loading with weights_only=True by default - Implement fallback to weights_only=False for backward compatibility - Add security warning when unsafe loading is used - Add documentation comments in demo.py - Add comprehensive test suite (test_security_fix.py) Impact: - Prevents arbitrary code execution from malicious checkpoints - Maintains full backward compatibility - No breaking changes Testing: - All tests passing (test_security_fix.py) - Verified safe checkpoint loading - Verified malicious checkpoint blocking - Verified backward compatibility
|
Hi, demo.py still calls torch.load(..., weights_only=False) unconditionally, so loading an untrusted checkpoint can still execute arbitrary code despite the PR’s stated goal. Severity: action required | Category: security How to fix: Use safe load with opt-in Agent prompt to fix - you can give this to your LLM of choice:
We noticed a couple of other issues in this PR as well - happy to share if helpful. Found by Qodo code review |
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.
Security fix for vulnerability where torch.load() was used without weights_only=True, allowing potential arbitrary code execution.
Changes:
Impact:
Testing: