Add ML deserialization rules (torch.load, joblib, pandas.read_pickle,… - #3992
Open
DipesThapa wants to merge 1 commit into
Open
Add ML deserialization rules (torch.load, joblib, pandas.read_pickle,…#3992DipesThapa wants to merge 1 commit into
DipesThapa wants to merge 1 commit into
Conversation
… numpy allow_pickle) - CWE-502
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
python/lang/security/deserialization/ml-deserialization.yamlwith four audit rules for pickle-backed ML deserialisers that aren't currently covered:avoid-torch-load-untrusted— torch.load() without weights_only=Trueavoid-joblib-load— joblib.load()avoid-pandas-read-pickle— pandas.read_pickle() / pd.read_pickle()avoid-numpy-allow-pickle— numpy.load(..., allow_pickle=True)These are the model-file attack surface (CWE-502) behind many recent AI/ML CVEs. The
deserialization/folder currently covers pickle, jsonpickle, pyyaml and ruamel but none of these four ML loaders, so this is net-new coverage. Rules follow the existing deserialization conventions (metadata,avoid-*ids, constant-stringpattern-notto reduce false positives), and the test file passes viasemgrep --test(4/4).Resolves #3990.