Skip to content

fix: prevent arbitrary code execution in torch.load()#25

Open
rajpratham1 wants to merge 1 commit intoRobbyant:mainfrom
rajpratham1:fix/security-torch-load-vulnerability
Open

fix: prevent arbitrary code execution in torch.load()#25
rajpratham1 wants to merge 1 commit intoRobbyant:mainfrom
rajpratham1:fix/security-torch-load-vulnerability

Conversation

@rajpratham1
Copy link
Copy Markdown

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

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
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