Skip to content

Commit 1931c2d

Browse files
Missing detection when calling Python functions (#49)
Address: - Missing detection when calling pytorch function torch.utils.bottleneck.__main__.run_autograd_prof GHSA-4whj-rm5r-c2v8 - Missing detection when calling built-in python ensurepip._run_pip GHSA-xp4f-hrf8-rxw7 - Missing detection when calling built-in python lib2to3.pgen2.pgen.ParserGenerator.make_label GHSA-p9w7-82w4-7q8m - Missing detection when calling built-in python idlelib.run.Executive.runcode GHSA-m869-42cg-3xwr - Missing detection when calling built-in python idlelib.pyshell.ModifiedInterpreter.runcommand GHSA-j343-8v2j-ff7w - Missing detection when calling built-in python idlelib.pyshell.ModifiedInterpreter.runcode GHSA-3gf5-cxq9-w223 - Missing detection when calling built-in python doctest.debug_script GHSA-fqq6-7vqf-w3fg - Missing detection when calling built-in python cProfile.runctx GHSA-9w88-8rmg-7g2p - Missing detection when calling built-in python cProfile.run GHSA-49gj-c84q-6qm9 - Missing detection when calling built-in python library asyncio.unix_events._UnixSubprocessTransport._start GHSA-q77w-mwjj-7mqx Co-authored-by: Matthieu Maitre <[email protected]>
1 parent aecd11b commit 1931c2d

14 files changed

+92
-14
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
Security scanner detecting Python Pickle files performing suspicious actions.
1717

18-
> For more generic model scanning, Protect AI's [modelscan](https://github.com/protectai/modelscan) is now available to scan not only Pickle files but
19-
> also PyTorch, TensorFlow, and Keras.
20-
2118
## Getting started
2219

2320
Scan a malicious model on [Hugging Face](https://huggingface.co/):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = picklescan
3-
version = 0.0.29
3+
version = 0.0.30
44
author = Matthieu Maitre
55
author_email = [email protected]
66
description = Security scanner detecting Python Pickle files performing suspicious actions

src/picklescan/scanner.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,18 @@ def __str__(self) -> str:
134134
"ssl": "*", # DNS exfiltration via ssl.get_server_certificate()
135135
"subprocess": "*",
136136
"sys": "*",
137+
"asyncio.unix_events": {"_UnixSubprocessTransport._start"},
137138
"code": {"InteractiveInterpreter.runcode"},
139+
"cProfile": {"runctx", "run"},
140+
"doctest": {"debug_script"},
141+
"ensurepip": {"_run_pip"},
138142
"idlelib.autocomplete": {"AutoComplete.get_entity", "AutoComplete.fetch_completions"},
139143
"idlelib.calltip": {"Calltip.fetch_tip", "get_entity"},
140144
"idlelib.debugobj": {"ObjectTreeItem.SetText"},
145+
"idlelib.pyshell": {"ModifiedInterpreter.runcode", "ModifiedInterpreter.runcommand"},
146+
"idlelib.run": {"Executive.runcode"},
141147
"lib2to3.pgen2.grammar": {"Grammar.loads"},
148+
"lib2to3.pgen2.pgen": {"ParserGenerator.make_label"},
142149
"pdb": "*",
143150
"pickle": "*",
144151
"_pickle": "*",
@@ -154,7 +161,7 @@ def __str__(self) -> str:
154161
"torch.utils._config_module": {
155162
"ConfigModule.load_config"
156163
}, # allows storing a pickle inside a pickle (if this has valid use cases, scan the input bytes instead of flagging the global)
157-
"torch.utils.bottleneck.__main__": {"run_cprofile"},
164+
"torch.utils.bottleneck.__main__": {"run_cprofile", "run_autograd_prof"},
158165
"torch.utils.collect_env": {"run"},
159166
"torch.utils.data.datapipes.utils.decoder": {
160167
"basichandlers"

tests/data2/GHSA-3gf5-cxq9-w223.pkl

104 Bytes
Binary file not shown.

tests/data2/GHSA-49gj-c84q-6qm9.pkl

71 Bytes
Binary file not shown.

tests/data2/GHSA-4whj-rm5r-c2v8.pkl

110 Bytes
Binary file not shown.

tests/data2/GHSA-9w88-8rmg-7g2p.pkl

76 Bytes
Binary file not shown.

tests/data2/GHSA-fqq6-7vqf-w3fg.pkl

80 Bytes
Binary file not shown.

tests/data2/GHSA-j343-8v2j-ff7w.pkl

107 Bytes
Binary file not shown.

tests/data2/GHSA-m869-42cg-3xwr.pkl

90 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)