Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fickling/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class UnsafeImportsML(Analysis):
"torch.hub": "This module can load untrusted files from the web, exposing the system to arbitrary code execution.",
"dill": "This module can load and execute arbitrary code.",
"code": "This module can compile and execute arbitrary code.",
"pty": "This module contains functions that can perform system operations and execute arbitrary code.",
}

UNSAFE_IMPORTS = {
Expand Down
1 change: 1 addition & 0 deletions fickling/fickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ def unsafe_imports(self) -> Iterator[ast.Import | ast.ImportFrom]:
"sys",
"builtins",
"socket",
"pty",
"marshal",
"types",
):
Expand Down
39 changes: 39 additions & 0 deletions test/test_bypasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,45 @@


class TestBypasses(TestCase):
# https://github.com/trailofbits/fickling/security/advisories/GHSA-r7v6-mfhq-g3m2
def test_missing_pty_unsafe_imports_ghsa(self):
pickled = Pickled(
[
op.Proto.create(4),
op.Frame(26),
op.ShortBinUnicode("pty"),
op.Memoize(),
op.ShortBinUnicode("spawn"),
op.Memoize(),
op.StackGlobal(),
op.Memoize(),
op.ShortBinUnicode("id"),
op.Memoize(),
op.TupleOne(),
op.Memoize(),
op.Reduce(),
op.Memoize(),
op.ShortBinUnicode("gottem"),
op.Memoize(),
op.Build(),
op.Stop(),
]
)
self.assertGreater(check_safety(pickled).severity, Severity.LIKELY_SAFE)

# https://github.com/trailofbits/fickling/pull/108
def test_missing_pty_unsafe_imports_pr(self):
pickled = Pickled(
[
op.Mark(),
op.Global("pty spawn"),
op.String("id"),
op.Obj(),
op.Stop(),
]
)
self.assertGreater(check_safety(pickled).severity, Severity.LIKELY_SAFE)

# https://github.com/trailofbits/fickling/security/advisories/GHSA-565g-hwwr-4pp3
def test_missing_marshal_and_types(self):
code = compile('import os\nos.system("id")', "<string>", "exec")
Expand Down
Loading