Skip to content

Security: Insecure deserialization via torch.load on LoRA checkpoint#217

Open
tuanaiseo wants to merge 1 commit intonikopueringer:mainfrom
tuanaiseo:contribai/fix/security/insecure-deserialization-via-torch-load-
Open

Security: Insecure deserialization via torch.load on LoRA checkpoint#217
tuanaiseo wants to merge 1 commit intonikopueringer:mainfrom
tuanaiseo:contribai/fix/security/insecure-deserialization-via-torch-load-

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

torch.load(checkpoint) is used to load a .pt file constructed from an external path. PyTorch checkpoint loading uses pickle semantics and can execute arbitrary code when loading malicious files. If an attacker can influence pretrained_model_name_or_path_or_dict or checkpoint contents, this can become code execution.

Severity: high
File: gvm_core/gvm/pipelines/pipeline_gvm.py

Solution

Avoid pickle-based loading for untrusted files. Prefer safetensors for weights. If using PyTorch >=2.0+, use torch.load(..., weights_only=True) where compatible, and strictly validate/allowlist checkpoint locations.

Changes

  • gvm_core/gvm/pipelines/pipeline_gvm.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

`torch.load(checkpoint)` is used to load a `.pt` file constructed from an external path. PyTorch checkpoint loading uses pickle semantics and can execute arbitrary code when loading malicious files. If an attacker can influence `pretrained_model_name_or_path_or_dict` or checkpoint contents, this can become code execution.

Affected files: pipeline_gvm.py

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
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