Skip to content

B2: Pickle reader #136

In review
In review

Description

@Claptar

Part of #149.

wave 1 · 0.17.11 · size M

Goal. The pickle reader keeps its documented promise: a crafted pickle is refused before numpy, scipy or pandas act on it, never a crash, and what it reads is written as anndata would.

Owns: formats/pickled.py, formats/pandas_frame.py, conversion/cistopic.py

Approach:

  • Every object is checked before numpy, scipy or pandas act on it, as the docs promise (details in the PR once released).
  • Sizes a pickle names are compared with the data it holds before anything is allocated, and the sniffer reads only what it needs.
  • Labels holding /, and empty labels, are refused or renamed with a warning, as anndata refuses such keys.
  • Object columns of large integers keep their values (uint64 or float), not a wrapped int64.
  • pandas 3's Arrow strings: allowlisted with a check of their chunks, or the pandas requirement documented.
  • Coverage of pickled.py (83%, the lowest in src) rises with the new tests; a 3.14 leg comes in B12.

Findings

Ref Sev Finding Where
F174 H A crafted pickle crashes the reader instead of being refused (details once the fix is released) withheld
F175 M Column labels and sample names holding / are written as paths: a label /var gives an h5ad anndata cannot open, with exit 0 formats/pandas_frame.py:62
F176 M Object column of ints >= 2**63 silently wraps to negative int64 formats/pandas_frame.py:111
F177 M The pickle sniffer can read far into a large text input formats/pickled.py:869
F178 L Lowest coverage is in the security-critical modules formats/pickled.py:1
F179 L A pandas 3 pickle with default string columns is refused formats/pickled.py:120
F180 L A crafted pickle can allocate memory out of proportion to its size formats/pickled.py:371

Done when one PR on fix/b2 closes this, with a regression test against an oracle for every finding, and docs and changelog in the same PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions