File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff 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 = {
Original file line number Diff line number Diff 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 ):
Original file line number Diff line number Diff line change 77
88
99class 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\n os.system("id")' , "<string>" , "exec" )
You can’t perform that action at this time.
0 commit comments