Commit 19e828d
Integrate recent PickleScan bypasses into unsafe imports detection (#210)
* Integrate recent PickleScan bypasses into unsafe imports detection
Add detection for 8+ CVEs and GHSAs discovered in PickleScan v0.0.31-v0.0.34:
- Operator module bypasses (GHSA-m273-6v24-x4m4, GHSA-955r-x9j8-7rhh):
_operator/operator.attrgetter, itemgetter, methodcaller
- File handling bypasses (CVE-2025-10155, CVE-2025-10156):
distutils.file_util.write_file, _io.FileIO, shutil
- Async subprocess execution (CVE-2025-10157):
asyncio.unix_events._UnixSubprocessTransport
- Profiler/debugger code execution (GHSA-46h3-79wf-xr6c, GHSA-4675-36f9-wf6r):
profile, trace, pdb, bdb, timeit, doctest
- Nested pickle attacks (GHSA-84r2-jw7c-4r5q): pickle, _pickle
- Package manipulation (GHSA-vqmv-47xg-9wpr): pip, venv, ensurepip
- Network modules (GHSA-hgrh-qx5j-jfwx): aiohttp, httplib, http, ssl, requests
- IDE tools (GHSA-r8g5-cgf2-4m4m): idlelib, lib2to3
- numpy.f2py.crackfortran.getlincoef/_eval_length
- functools.partial wrapper bypass
Closes #190
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Remove CVE/GHSA references from unsafe imports comments
References were pointing to wrong advisories.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Remove non-ML modules from UnsafeImportsML.UNSAFE_MODULES
Keep only modules relevant to ML model scanning. General-purpose
modules remain in fickle.py UNSAFE_IMPORTS for standard detection.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Update bypass tests with real PickleScan advisory payloads
- Replace test_operator_methodcaller with actual exploit payload from
GHSA-955r-x9j8-7rhh that chains __import__, _operator.methodcaller
to call os.system()
- Replace test_asyncio_subprocess with payload from GHSA-f7qq-56ww-84cr
targeting _UnixSubprocessTransport._start
- Add GHSA references to test_distutils_write_file and test_numpy_f2py_getlincoef
- Remove test_operator_attrgetter and test_functools_partial (redundant)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix STACK_GLOBAL validation to allow dotted attribute names
Pickle files may contain dotted attribute names like
`_UnixSubprocessTransport._start` in STACK_GLOBAL. Allow these
by validating each component separately.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Remove duplicate entries from UnsafeImportsML.UNSAFE_IMPORTS
- Keep only ML-specific imports (torch, numpy) since other modules
are already covered by fickle.py UNSAFE_IMPORTS at the module level
- Move _io/io from fickle.py to UnsafeImportsML with FileIO-only check
to avoid false positives (io.BytesIO is commonly used legitimately)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Thomas Chauchefoin <thomas.chauchefoin@trailofbits.com>1 parent 3d656b9 commit 19e828d
3 files changed
+164
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | 254 | | |
260 | 255 | | |
261 | 256 | | |
| |||
264 | 259 | | |
265 | 260 | | |
266 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
62 | 96 | | |
63 | 97 | | |
64 | 98 | | |
| |||
1267 | 1301 | | |
1268 | 1302 | | |
1269 | 1303 | | |
1270 | | - | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
1271 | 1307 | | |
1272 | 1308 | | |
1273 | 1309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
0 commit comments