Repository navigation
Release 0.17.9 - #132
Release 0.17.9#132
Conversation
zarr decodes a chunk with whatever codecs its array's metadata names, and numcodecs' pickle codec unpickles it. A Zarr v2 store naming it for a text array ran its author's code on the first read of that array: convert, subset, split, concat, recast and export dataframe did, with exit 0, and subset to Zarr carried the codec into its output. - storage.check_zarr_contents walks every array's metadata through the handle that reads its chunks (the consolidated index when zarr reads through one) and refuses a codec outside ZARR_V2_CODECS or ZARR_V3_CODECS, naming the array and the codec, before any chunk is read. open_store runs it for every mode but a fresh write. - copy_path checks both the hierarchy on disk and the consolidated index before it copies a store, and import's precheck checks the source it opens. - The v2 list is every numcodecs codec whose decode only compresses or transforms bytes, numbers or length-prefixed text: not pickle, nor json2 and msgpack2, which build Python objects in a shape the chunk names. The v3 list is zarr's own codecs and numcodecs' wrappers. - tests/test_zarr_safety.py: every command refuses a store whose payload would leave a marker; the codec as compressor or filter, in either metadata, or nested in a shard; anndata's v2 and sharded v3 stores still open; the check fetches metadata only. - Docs: Codecs read on the Zarr spec page, the refusal in troubleshooting, the new test file in the testing map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Zarr store naming a codec adata does not decode is refused when it is opened; numcodecs' pickle codec ran a crafted store's code on read. - pyproject.toml and uv.lock at 0.17.9. - docs/changelog.md: a 0.17.9 section (Fixed). - STATUS.md: 0.17.9 released; the December audit in progress, its epic to follow the release; the Zarr hardening follow-up narrowed to what remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The walk at opening saw only the arrays zarr lists, and zarr reads more: a path looked up in one go reached an array below a folder with no group metadata, or one hidden by an index a group's metadata embeds, and `export array` and `concat` ran the payload that way with exit 0; metadata re-read after the check was decoded as it then said; and a copy could carry a codec only the files on disk named. - restrict_zarr_codecs, run when adata.storage is imported: every codec id off the lists resolves, in numcodecs' registry and zarr's, to a class that refuses to be built, and numcodecs' get_codec and zarr's get_codec_class (with the name zarr's v3 parser imported) refuse such an id even if it is registered later. This is the layer that holds. - open_store keeps its walk for the message, and when zarr refuses while parsing, reads the store's metadata files to name the array. - check_zarr_store reads every metadata file a copy would carry as JSON (the arrays' own, the consolidated index, any index a group's metadata embeds), through linked folders as the copy goes; one that is not JSON is refused. - The walk no longer prints zarr's warning about a stray file. - Tests: an array no listing shows, two ways; metadata changed after opening; each metadata file a copy carries; the registries refuse and a second run changes nothing; a refusal is one Error: line. - AGENTS.md and developers.md: the rule; the spec, troubleshooting and changelog describe both layers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test Results (py3.13)3 881 tests 3 868 ✅ 8m 29s ⏱️ Results for commit 7f8e339. ♻️ This comment has been updated with latest results. |
Test Results (py3.12)3 881 tests 3 868 ✅ 9m 46s ⏱️ Results for commit 7f8e339. ♻️ This comment has been updated with latest results. |
The scan before a copy matched file names exactly and took an array's word for its version, so a `.zarray` saying `"node_type": "array"` had its compressor skipped, and on a case-insensitive filesystem `.ZARRAY` (which zarr opens as `.zarray`) was not read at all. With the array where no listing of the copy shows it, `import -o` wrote a store that runs the payload in any reader; adata itself never decoded it. - In each folder the four metadata names are opened through the filesystem, as zarr opens them. - Every mapping holding a compressor, filters or codecs is checked, whatever it says it is; a codec's own configuration (lzma's filter chain) and attributes are not looked into. - copy_path checks the copy again once it is made, and removes it if it is refused: the source may change between the check and the copy. - restrict_zarr_codecs says that importing adata.storage restricts zarr for whatever else the process does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Release 0.17.9: version in
pyproject.tomlanduv.lock, a## 0.17.9section indocs/changelog.md, and STATUS.md. One fix, a security one.What was wrong. zarr decodes a chunk with whatever codecs its array's metadata names. numcodecs'
picklecodec unpickles the chunk, and unpickling runs whatever code the store's author put in it. A Zarr v2 store can name it for any text array, and every AnnData store has two: the obs and var indexes. So reading a crafted store ran its author's code:convert(to h5ad and to Zarr),subset,split,concat,recastandexport;subsetto Zarr copied the codec into its output.zarr-python and anndata decode such a store the same way. adata already refuses unsafe HDF5 inputs (0.17.5) and loads pickles through an allowlist; Zarr was the gap.
The fix, in two layers:
storage.restrict_zarr_codecs, run whenadata.storageis imported). Every chunk is decoded by codecs built from metadata, through numcodecs' registry for v2 and zarr's for v3.get_codec, zarr'sget_codec_class, and the name zarr's v3 metadata parser imported.open_storewalks every array zarr lists, through the metadata that read uses.copy_path(import,--inplace) reads every metadata file the copy would carry as JSON before copying: the arrays' own, the consolidated index, and any index a group's metadata embeds. So no output carries the codec on.Error:line.The lists. I read the
decode()of each of the 26 codecs numcodecs 0.16.5 registers.pickle, which runs code, andjson2andmsgpack2, which build Python objects in a shape the chunk names. anndata writes none of the three.numcodecs.*wrappers. zarr resolves no v3 codec that runs code; the list keeps a plugin from adding one.Review. An independent reviewer went over it twice.
First pass: the first version only walked the arrays
members()lists, and zarr reads more.export arrayandconcatran the payload that way, with exit 0.Second pass: no way left for adata to build or decode an off-list codec, on zarr 3.4.1 / numcodecs 0.16.5 or at the floors (zarr 3.2.0 / numcodecs 0.14.0). But the copy scan could be fooled:
.zarray's"node_type"claim;.ZARRAY, which zarr opens on a case-insensitive filesystem;The scan now opens the four metadata names through the filesystem, as zarr does, and checks every compressor, filters and codecs entry whatever the file claims. It also checks the copy once it is made.
Each of these is a test.
Tests:
tests/test_zarr_safety.py, 39 tests. The crafted stores carry a payload that only creates a marker file, and the marker is the oracle.Error:line and no output:ls,view,convert(to h5ad and to Zarr),subset,split,concat,recast,export dataframe/array,import dict/array..ZARRAYwhere the filesystem ignores case), and the copy is checked again once made. A metadata file that is not JSON is refused. Neither lzma's own filter chain nor attributes are mistaken for codecs..DS_Storeprints nothing.Docs:
After this merges, push the tag
0.17.9from main. Publish then:A GitHub security advisory for
pyadata-cli <= 0.17.8, fixed in 0.17.9, follows the release.🤖 Generated with Claude Code