Skip to content

fix(polygraphy): use weights_only=True in torch.load to prevent RCE#4728

Open
tailingy wants to merge 1 commit intoNVIDIA:mainfrom
tailingy:fix/polygraphy-torch-load-weights-only
Open

fix(polygraphy): use weights_only=True in torch.load to prevent RCE#4728
tailingy wants to merge 1 commit intoNVIDIA:mainfrom
tailingy:fix/polygraphy-torch-load-weights-only

Conversation

@tailingy
Copy link

Summary

  • Vulnerability: Arbitrary Code Execution (RCE) via unsafe pickle deserialization in polygraphy/json/serde.py
  • Root Cause: torch.load(infile) was called without weights_only=True, allowing maliciously crafted Polygraphy JSON files to execute arbitrary code via Python's pickle module
  • Fix: Pass weights_only=True to torch.load(), restricting deserialization to tensor data only

Change

# Before (vulnerable)
return torch.load(infile)

# After (safe)
return torch.load(infile, weights_only=True)

Impact

An attacker who can supply a crafted Polygraphy JSON file (e.g. via the CLI or Python API) can execute arbitrary code in the victim's process context. This enables data exfiltration, privilege escalation, and other attacks.

Compatibility

weights_only=True has been supported since PyTorch 1.13, which is already the minimum version declared by Polygraphy (torch>=1.13.0). No compatibility issues expected.

References

🤖 Generated with Claude Code

…ia pickle deserialization

Passing weights_only=True to torch.load() restricts deserialization to
tensor data only, blocking arbitrary pickle-based code execution.

Fixes NVBugs #5934574 - [PSIRT] Arbitrary Code Execution via unsafe
torch.load() in Polygraphy JSON deserialization.
@tailingy tailingy requested a review from a team as a code owner March 25, 2026 18:13
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