Skip to content

fix(safety): verify in-place writes against full content, not a 4-byte prefix #3

Description

The in-place compression path verifies its readback against a 4-byte magic prefix, while compress_bytes compares full content. Any corruption past the first four bytes passes verification.

safety.rs builds a magic_prefix snapshot and checks that on readback. compress_bytes uses readback_matches against a full pre-apply snapshot. The two paths make different guarantees, and the weaker one is the one that mutates a file in place.

A fork of this engine in abitious used the full-content oracle on both paths. That fork is now deleted in favor of depending on this crate, which is why the difference matters: consumers moving onto the published crate get the weaker check.

Suggested fix: use readback_matches against the full pre-apply snapshot on the in-place path too, or document why a prefix check is sufficient there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions