Skip to content

Commit 6d20564

Browse files
Add smtplib, imaplib, ftplib, poplib, telnetlib, nntplib to UNSAFE_IMPORTS (#233)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c89126b commit 6d20564

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

fickling/fickle.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
"requests",
9191
"urllib",
9292
"urllib2",
93+
"smtplib",
94+
"imaplib",
95+
"ftplib",
96+
"poplib",
97+
"telnetlib",
98+
"nntplib",
9399
# IDE and dev tools
94100
"idlelib",
95101
"lib2to3",

test/test_bypasses.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,37 @@ def test_numpy_f2py_getlincoef(self):
531531
res = check_safety(pickled)
532532
self.assertGreater(res.severity, Severity.LIKELY_SAFE)
533533

534+
def test_network_protocol_ssrf(self):
535+
cases = [
536+
("smtplib", "SMTP", 25),
537+
("imaplib", "IMAP4", 143),
538+
("ftplib", "FTP", 21),
539+
("poplib", "POP3", 110),
540+
("telnetlib", "Telnet", 23),
541+
("nntplib", "NNTP", 119),
542+
]
543+
for module, cls, port in cases:
544+
with self.subTest(module=module):
545+
pickled = Pickled(
546+
[
547+
op.Proto.create(4),
548+
op.Global.create(module, cls),
549+
op.ShortBinUnicode("127.0.0.1"),
550+
op.BinInt2(port),
551+
op.TupleTwo(),
552+
op.Reduce(),
553+
op.EmptyDict(),
554+
op.Build(),
555+
op.Stop(),
556+
]
557+
)
558+
res = check_safety(pickled)
559+
self.assertGreater(
560+
res.severity,
561+
Severity.LIKELY_SAFE,
562+
f"{module}.{cls} was not flagged as unsafe",
563+
)
564+
534565
# https://github.com/mmaitre314/picklescan/security/advisories/GHSA-f7qq-56ww-84cr
535566
def test_asyncio_subprocess(self):
536567
"""Test detection of asyncio subprocess execution bypass."""

0 commit comments

Comments
 (0)