Repository navigation
Restrict load_pickle to numpy and builtin containers - #72
Conversation
rossant
left a comment
There was a problem hiding this comment.
Thanks for tackling this too! As far as I remember, Phy doesn’t use object-dtype arrays, so explicitly rejecting them seems reasonable.
Could you document that restriction and add a test rejecting a harmless object array? The current malicious object-array test fails at NumPy reconstruction, before reaching the malicious element, so it shouldn’t imply that filtering inside object arrays is supported.
Please also check the supported save_pickle output formats, including compression, and narrow the compatibility claims accordingly.
7f9d152 to
206a60a
Compare
rossant
left a comment
There was a problem hiding this comment.
The requested format restrictions and compatibility changes are addressed. The joblib requirement matches the implementation, and CI is green for this commit.
cd3b000 to
497069c
Compare
Restore the exact reviewed tree, retaining the rewritten branch and original reviewed history.
load_pickle()previously delegated to unrestrictedjoblib.load(). It now uses a restricted joblib unpickler for uncompressed files containing plain Python containers and supported NumPy arrays, scalars, and dtypes.Custom globals, pickle extensions (including cached extensions), and all object-dtype arrays—including harmless ones—are rejected with
pickle.UnpicklingError. Compressed files are rejected withValueError. This is not support for filtering arbitrary objects inside object arrays.The implementation requires
joblib>=1.5; the requirement is recorded inpyproject.tomlanduv.lock.save_pickle()retains joblib's full writer behavior, so compressed files, custom objects, and object arrays it writes cannot be read back byload_pickle(). README and changelog describe supported round trips and migration.Regression tests cover supported containers, NumPy scalar/dtype and array formats, direct/nested malicious payloads, harmless and malicious object arrays, cached EXT1/EXT2/EXT4 payloads, compressed formats, and object-array conversion. All nine CI checks pass on head
cd3b000e97d0e4bbd44750aeea57323dbc22c863against the original stack base.Stacked on #71. After #71 merges, retarget this PR to
master, verify only pickle-related changes remain, and require passing CI on the resulting merge candidate. Companion Phy work will verify persisted cache compatibility before release. No package publication is part of this PR.