Created from a Codex audit of grovedb. No code changes were made as part of the audit.
Summary
SQLite commitment store helpers cast DB integers such as position and shard_index into unsigned values.
Impact / failure scenario
Corrupt rows with -1 become u64::MAX, potentially corrupting witnesses or causing downstream errors.
References
grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:88
grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:121
grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:378
grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:387
Suggested fix
Use u64::try_from(i64) and add SQLite CHECK (position >= 0) / CHECK (shard_index >= 0) constraints.
Suggested tests
Add corrupt-row tests for negative position and shard index.
Created from a Codex audit of grovedb. No code changes were made as part of the audit.
Summary
SQLite commitment store helpers cast DB integers such as
positionandshard_indexinto unsigned values.Impact / failure scenario
Corrupt rows with
-1becomeu64::MAX, potentially corrupting witnesses or causing downstream errors.References
grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:88grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:121grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:378grovedb-commitment-tree/src/client/sqlite_store/sql_helpers.rs:387Suggested fix
Use
u64::try_from(i64)and add SQLiteCHECK (position >= 0)/CHECK (shard_index >= 0)constraints.Suggested tests
Add corrupt-row tests for negative position and shard index.