@@ -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