Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore B614 Use of unsafe PyTorch load. #1426

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

tanwarsh
Copy link
Collaborator

@tanwarsh tanwarsh commented Mar 5, 2025

Summary

Ignored bandit issue B614.

Type of Change (Mandatory)

Specify the type of change being made.

  • Security improvement

@tanwarsh tanwarsh changed the title WIP: B614 Use of unsafe PyTorch load fix B614 Use of unsafe PyTorch load fix Mar 6, 2025
@MasterSkepticista
Copy link
Member

MasterSkepticista commented Mar 6, 2025

This change introduces unnecessary complexity with minimal user benefit. Torch tensors are routinely loaded using built-ins, and I think there are other areas that may require more attention. I don't think passing this bandit scan is a priority. I recommend closing this PR.

@rahulga1
Copy link
Collaborator

rahulga1 commented Mar 7, 2025

This change introduces unnecessary complexity with minimal user benefit. Torch tensors are routinely loaded using built-ins, and I think there are other areas that may require more attention. I don't think passing this bandit scan is a priority. I recommend closing this PR.

@MasterSkepticista I agree that this PR may not be providing user benefit. But lets be clear that Security is an important aspect for any of Intel products. We have taken calls for some bandit issues, where we have closed those due to being false positive, but this is not one of those. So, I won't recommend closing it.
Instead, if you have any suggestion, how we can fix it more appropriately, would appreciate that.

@MasterSkepticista
Copy link
Member

MasterSkepticista commented Mar 7, 2025

I appreciate the focus on security, but in open-source frameworks like these, ease of use, simplicity, and maintainability are equally critical.

These are user convenience APIs and not consumed directly by OpenFL. The intent behind adding {load, save}_native functions was to offer a bridge for users to transfer model weights between OpenFL and their own projects. By using safetensors, we are forcing users to modify their own project code—even when their work may have no connection to OpenFL or Federated Learning. This impacts usability and is not a good user experience in my view.

PyTorch's own recommendation to using torch.{load, save} is that the user must trust the source that they are loading data from. I think this is a fair expectation to have from a user, knowing that they are required to call those functions themselves in their source code.

@tanwarsh
Copy link
Collaborator Author

tanwarsh commented Mar 7, 2025

I appreciate the focus on security, but in open-source frameworks like these, ease of use, simplicity, and maintainability are equally critical.

These are user convenience APIs and not consumed directly by OpenFL. The intent behind adding {load, save}_native functions was to offer a bridge for users to transfer model weights between OpenFL and their own projects. By using safetensors, we are forcing users to modify their own project code—even when their work may have no connection to OpenFL or Federated Learning. This impacts usability and is not a good user experience in my view.

PyTorch's own recommendation to using torch.{load, save} is that the user must trust the source that they are loading data from. I think this is a fair expectation to have from a user, knowing that they are required to call those functions themselves in their source code.

In this case, Can we ignore this bandit issue @rahulga1 ?

@rahulga1
Copy link
Collaborator

rahulga1 commented Mar 7, 2025

I appreciate the focus on security, but in open-source frameworks like these, ease of use, simplicity, and maintainability are equally critical.
These are user convenience APIs and not consumed directly by OpenFL. The intent behind adding {load, save}_native functions was to offer a bridge for users to transfer model weights between OpenFL and their own projects. By using safetensors, we are forcing users to modify their own project code—even when their work may have no connection to OpenFL or Federated Learning. This impacts usability and is not a good user experience in my view.
PyTorch's own recommendation to using torch.{load, save} is that the user must trust the source that they are loading data from. I think this is a fair expectation to have from a user, knowing that they are required to call those functions themselves in their source code.

In this case, Can we ignore this bandit issue @rahulga1 ?

Please note this down and ignore this. If PSE comes back, we go ahead with this explanation.
FYI @psfoley

@tanwarsh tanwarsh changed the title B614 Use of unsafe PyTorch load fix Ignore B614 Use of unsafe PyTorch load. Mar 7, 2025
@kta-intel
Copy link
Collaborator

Would setting weights_only=True work? Starting with torch 2.6, that flag will be set by default without the pickle_module argument https://pytorch.org/docs/stable/notes/serialization.html#weights-only.

Since we only load the state dictionaries, it will still align with expectations from OpenFL's perspective without sacrificing user experience.

Btw, load_native() actually isn't currently exposed to the user (or used at all, for that matter)

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.

4 participants