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.
The in-place compression path verifies its readback against a 4-byte magic prefix, while
compress_bytescompares full content. Any corruption past the first four bytes passes verification.safety.rsbuilds amagic_prefixsnapshot and checks that on readback.compress_bytesusesreadback_matchesagainst 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
abitiousused 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_matchesagainst the full pre-apply snapshot on the in-place path too, or document why a prefix check is sufficient there.