Skip to content

Commit 2a763ab

Browse files
Merge pull request #187 from trailofbits/fix-GHSA-r7v6-mfhq-g3m2
2 parents d8eb575 + e4fc5d5 commit 2a763ab

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

fickling/analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ class UnsafeImportsML(Analysis):
223223
"torch.hub": "This module can load untrusted files from the web, exposing the system to arbitrary code execution.",
224224
"dill": "This module can load and execute arbitrary code.",
225225
"code": "This module can compile and execute arbitrary code.",
226+
"pty": "This module contains functions that can perform system operations and execute arbitrary code.",
226227
}
227228

228229
UNSAFE_IMPORTS = {

fickling/fickle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ def unsafe_imports(self) -> Iterator[ast.Import | ast.ImportFrom]:
875875
"sys",
876876
"builtins",
877877
"socket",
878+
"pty",
878879
"marshal",
879880
"types",
880881
):

test/test_bypasses.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,45 @@
77

88

99
class TestBypasses(TestCase):
10+
# https://github.com/trailofbits/fickling/security/advisories/GHSA-r7v6-mfhq-g3m2
11+
def test_missing_pty_unsafe_imports_ghsa(self):
12+
pickled = Pickled(
13+
[
14+
op.Proto.create(4),
15+
op.Frame(26),
16+
op.ShortBinUnicode("pty"),
17+
op.Memoize(),
18+
op.ShortBinUnicode("spawn"),
19+
op.Memoize(),
20+
op.StackGlobal(),
21+
op.Memoize(),
22+
op.ShortBinUnicode("id"),
23+
op.Memoize(),
24+
op.TupleOne(),
25+
op.Memoize(),
26+
op.Reduce(),
27+
op.Memoize(),
28+
op.ShortBinUnicode("gottem"),
29+
op.Memoize(),
30+
op.Build(),
31+
op.Stop(),
32+
]
33+
)
34+
self.assertGreater(check_safety(pickled).severity, Severity.LIKELY_SAFE)
35+
36+
# https://github.com/trailofbits/fickling/pull/108
37+
def test_missing_pty_unsafe_imports_pr(self):
38+
pickled = Pickled(
39+
[
40+
op.Mark(),
41+
op.Global("pty spawn"),
42+
op.String("id"),
43+
op.Obj(),
44+
op.Stop(),
45+
]
46+
)
47+
self.assertGreater(check_safety(pickled).severity, Severity.LIKELY_SAFE)
48+
1049
# https://github.com/trailofbits/fickling/security/advisories/GHSA-565g-hwwr-4pp3
1150
def test_missing_marshal_and_types(self):
1251
code = compile('import os\nos.system("id")', "<string>", "exec")

0 commit comments

Comments
 (0)