You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
The TieredStorageFooter is written-to and read-from disk by simply copying bytes. Since the footer contains enums, there are implicit invalid bit patterns for the footer. In Rust, it is undefined behavior to access uninitialized bytes, which I believe extends to invalid bit patterns, a la bool. We should only access initialized—and well-defined—bytes. Otherwise this would allow corrupt on-disk footers, potentially creating corrupt/invalid snapshots.
brooksprumo
changed the title
Serialization/Deserialization has undefined behavior/needs sanitization
tiered storage: Serialization/Deserialization has undefined behavior/needs sanitization
Nov 16, 2023
brooksprumo
changed the title
tiered storage: Serialization/Deserialization has undefined behavior/needs sanitization
tiered storage: Footer deserialization has undefined behavior/needs sanitization
Dec 4, 2023
Problem
The TieredStorageFooter is written-to and read-from disk by simply copying bytes. Since the footer contains enums, there are implicit invalid bit patterns for the footer. In Rust, it is undefined behavior to access uninitialized bytes, which I believe extends to invalid bit patterns, a la
bool
. We should only access initialized—and well-defined—bytes. Otherwise this would allow corrupt on-disk footers, potentially creating corrupt/invalid snapshots.Here's the footer:
solana/accounts-db/src/tiered_storage/footer.rs
Lines 89 to 145 in b4c652e
And the enums:
solana/accounts-db/src/tiered_storage/footer.rs
Lines 35 to 87 in b4c652e
Proposed Solution
We probably need to read and write the enums as
u16
s, and then perform sanitation on those values to ensure they're valid values for the enums.Note: Tiered storage is not live/in-use yet, so we don't have any attack vectors for a malicious actor.
The text was updated successfully, but these errors were encountered: