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

Pytorch Load / Save Plugin #1114

Merged
merged 16 commits into from
Sep 23, 2024
Merged

Pytorch Load / Save Plugin #1114

merged 16 commits into from
Sep 23, 2024

Conversation

lukehinds
Copy link
Member

@lukehinds lukehinds commented Mar 3, 2024

This plugin checks for the use of torch.load and torch.save.
Using torch.load with untrusted data can lead to arbitrary code execution,
and improper use of torch.save might expose sensitive data or lead to data
corruption.

This plugin checks for the use of `torch.load` and `torch.save`.
Using `torch.load` with untrusted data can lead to arbitrary code
execution, and improper use of `torch.save` might expose sensitive
data or lead to data corruption.

Signed-off-by: Luke Hinds <luke@stacklok.com>
@lukehinds
Copy link
Member Author

Bit of cleaning up to do, will get onto next week

@sigmavirus24
Copy link
Member

Closing and reopening to trigger precommit ci to auto fix this for you

@sigmavirus24 sigmavirus24 reopened this Mar 3, 2024
bandit/blacklists/calls.py Outdated Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Outdated Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Outdated Show resolved Hide resolved
bandit/blacklists/calls.py Outdated Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Outdated Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Show resolved Hide resolved
Signed-off-by: Luke Hinds <luke@stacklok.com>
Signed-off-by: Luke Hinds <luke@stacklok.com>
Signed-off-by: Luke Hinds <luke@stacklok.com>
@lukehinds
Copy link
Member Author

@sigmavirus24 / @ericwb I think I have reviewed most of the points now, fancy taking a second sweep?

Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
Copy link
Member

@ericwb ericwb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently the trojansource plugin was merged which conflicts with this plugin ID of B613. Please change to B614

bandit/plugins/pytorch_load_save.py Outdated Show resolved Hide resolved
bandit/plugins/pytorch_load_save.py Outdated Show resolved Hide resolved
doc/source/plugins/b704_pytorch_load_save.rst Outdated Show resolved Hide resolved
lukehinds and others added 3 commits September 14, 2024 09:56
Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
@lukehinds
Copy link
Member Author

sorry for late action, changes accepted @ericwb

@ericwb ericwb merged commit 36fd650 into PyCQA:main Sep 23, 2024
16 checks passed
ericwb added a commit to ericwb/bandit that referenced this pull request Sep 27, 2024
* Pytorch Load / Save Plugin

This plugin checks for the use of `torch.load` and `torch.save`.
Using `torch.load` with untrusted data can lead to arbitrary code
execution, and improper use of `torch.save` might expose sensitive
data or lead to data corruption.

Signed-off-by: Luke Hinds <luke@stacklok.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add missing save check

Signed-off-by: Luke Hinds <luke@stacklok.com>

* Review fixes from 8b92a02

Signed-off-by: Luke Hinds <luke@stacklok.com>

* Fix tox issues

Signed-off-by: Luke Hinds <luke@stacklok.com>

* Review fixes

Signed-off-by: Luke Hinds <luke@stacklok.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update test_functional.py

* Update bandit/plugins/pytorch_load_save.py

Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>

* Update bandit/plugins/pytorch_load_save.py

Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>

* Update doc/source/plugins/b704_pytorch_load_save.rst

Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>

* Update bandit/plugins/pytorch_load_save.py

Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>

---------

Signed-off-by: Luke Hinds <luke@stacklok.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
Signed-off-by: Eric Brown <eric_wade_brown@yahoo.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.

3 participants