Skip to content

NumPy serialization bypasses the integrity checksum (silent corruption on read) #155

Description

@27Bslash6

Summary

Top-level np.ndarray values are serialized via _serialize_numpy and returned directly, never passing through Rust ByteStorage.store. Unlike the DataFrame/Series/msgpack branches, the numpy path gets no xxHash3 checksum and no LZ4, regardless of enable_integrity_checking.

Evidence

  • src/cachekit/serializers/auto_serializer.py:427-430data = self._serialize_numpy(obj) returned directly
  • Contrast: dataframe (:678), series (:743), msgpack (:785) all call self._byte_storage.store(...)
  • Read side _deserialize_numpy (:603-645) reconstructs via np.frombuffer with no checksum verification

Impact

A corrupted numpy cache entry (bit flip / truncation) is silently reconstructed as wrong data or raises an opaque reshape error. Violates the "never silently return corrupted data" contract for the entire numpy path.

Fix

Route numpy bytes through ByteStorage (checksum + optional LZ4) like the other branches, or prepend the same 8-byte xxHash3 envelope and verify on read.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:highMust fix soonpythonPython library

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions