The short version: my tool does not win its own benchmark

I maintain pickle-sentry, a scanner for unsafe pickle deserialization in Python code and ML data files. Version 0.5.0 went live on GitHub and PyPI on Nov 30, 2026.

Before writing anything promotional about it, I ran it against the scanners it competes with, on a corpus built from the malicious test fixtures those scanners ship in their own repositories: 96 malicious files and 24 benign ones, benchmarked Nov 26, 2026. Static modes only, default settings for every tool.

Tool Malicious caught Benign falsely flagged
Picklescan 92 / 96 0 / 24
Fickling 86 / 96 8 / 24
pickle-sentry 0.5.0 76 / 96 5 / 24
ModelScan 29 / 96 0 / 24

Picklescan wins, and it is not close. That result is published in the repo, with the per-category misses written out, because a scanner that only publishes its wins is asking you to trust a marketing page instead of evidence. The rest of this post is about what the losses taught me, because both of the last two releases exist specifically because of misses in that table.

What the misses turned into: 0.4.1

The first run, against 0.4.0, scored 71 / 96. The largest single miss group was embarrassing in a useful way: 8 standalone archive files (a zip, six zip variants, and a 7z) received no findings at all. The inspector already knew how to peel archives and scan their members. The command line tool simply never routed those file extensions to it.

Version 0.4.1 fixed the routing. Standalone .zip, .tar, .tgz, .gz, .bz2, .xz, and .7z files now go to the inspector, .bin files joined the inspected set, and magic-byte sniffing catches a container hiding behind a wrong extension. Same corpus, no tuning to the fixtures: 71 went to 75, and the benign false flags stayed at 5 / 24.

What the misses turned into: 0.5.0

The second miss category was subtler. Some payloads are built on stdlib globals that look harmless in a disassembly but execute commands when called. They scored medium, because the globals they use are not on the obvious dangerous list that contains os.system and eval.

Version 0.5.0 adds one rule:

  • PICKLE-INVOKED-DANGEROUS-GLOBAL (critical): the pickle actually invokes a command-execution-capable stdlib global, following the payload set in GHSA-g38g-8gr9-h9xp. The set includes uuid._get_command_stdout, _osx_support._read_output and _find_build_tool, _aix_support._read_cmd_output, _pyrepl.pager.pipe_pager and tempfile_pager, imaplib.IMAP4_stream, and test.support.script_helper.assert_python_ok / assert_python_failure.

The precision rule matters more than the list. The scanner runs an abstract interpreter over the pickletools disassembly and only raises this finding when the global is actually invoked through REDUCE, NEWOBJ, or INST. A pickle that merely references one of these globals is not flagged high. A benign neighbour such as uuid.uuid4 is not flagged at all.

The honest delta: 75 went to 76, with false flags unchanged. One file. That is because the uuid GHSA fixture was the only corpus file this mechanism could newly catch; the other five GHSA-g38g fixtures were already flagged high under coarser rules, and 0.5.0 upgrades them to critical for the precise reason, actual invocation. I would rather ship a one-file benchmark gain with a correct reason than a bigger number with a sloppier one.

What it catches

Pickle is code, not data. A pickle file is a program for a small stack-based virtual machine, and unpickling a file you did not create runs whatever its opcodes say. pickle-sentry covers both sides of that problem.

In Python code, an AST scan that parses your code and never imports it:

  • pickle.load / loads, plus dill, cloudpickle, marshal, shelve, and joblib.load
  • pandas.read_pickle(...)
  • torch.load(...) with weights_only=False (high), or with no explicit weights_only at all (medium)
  • yaml.load(...) without a SafeLoader
  • numpy.load(..., allow_pickle=True)
  • load_dataset("pandas", ...), flagged critical as CVE-2026-57845 (CVSS 8.8), the Hugging Face datasets pandas builder route to pandas.read_pickle() in versions through 5.1.0

In data files, by disassembly only:

  • Pickle files, including streams inside torch zip archives and members of zip and tar archives, with gzip, bzip2, xz, and zlib wrappers peeled first
  • .npy object-array payloads and .npz members, which are pickle streams
  • .keras archives, including a check for Lambda layers that load marshalled Python bytecode at load time
  • Header checks for safetensors and GGUF, which are data-only formats

It can also scan a Hugging Face Hub repo remotely before you load anything from it:

pickle-sentry hub user/repo --repo-type model 

One property I was not willing to compromise on: the scanner never executes the files it inspects. The test suite builds a real malicious pickle whose payload would create a canary file if executed, and asserts the finding is raised and the canary never appears. The suite is at 113 tests in 0.5.0.

Quick start

pip install pickle-sentry pickle-sentry . # scan a project: code plus pickle files pickle-sentry . --fail-on high # CI gate: exit 1 on high or above 

Zero dependencies, Python 3.9+. Output formats are text, JSON, and SARIF for GitHub code scanning.

As a GitHub Action:

- uses: Sun-Wukhan/pickle-sentry@v0.5.0 with: path: . fail-on: high 

As a pre-commit hook:

- repo: https://github.com/Sun-Wukhan/pickle-sentry rev: v0.5.0 hooks: - id: pickle-sentry 

Honest limits

These are stated in the benchmark doc, and they belong in the launch post too:

  • Payloads that invoke torch.* or numpy.* globals are still missed. That is a different class from the stdlib set in 0.5.0 and it is not modelled yet.
  • A builtins stack-chain proof of concept, where the callable is assembled through __import__, vars, and dict.get, is still not modelled by the virtual machine analysis.
  • Damaged zip variants sit at medium severity rather than being fully inspected.
  • 5 of 24 benign files are falsely flagged. Picklescan and ModelScan both manage 0 on the same set.
  • A clean scan is not proof a file is safe. It is a heuristic over a disassembly. Provenance and sandboxing are separate questions, and the README says so.

Use pickle-sentry alongside a model-file scanner, not instead of one. Its contribution is the surface the others do not cover: the loaders in your code, the packages you are about to install, and the Hub repo you are about to load.

Links

False positives and missed loaders are the feedback I most want. Issues are open.

  • Navid Khan