Created from a Codex audit of grovedb. No code changes were made as part of the audit.
Summary
Several element sizing and cost-accounting paths use unchecked u32 arithmetic or unchecked casts.
Impact / failure scenario
Near-u32::MAX lengths can wrap in release or panic in debug, causing undercharged storage costs or verifier bypasses.
References
grovedb-element/src/element/helpers.rs:622
grovedb-element/src/element/helpers.rs:647
grovedb-element/src/element/helpers.rs:681
costs/src/lib.rs:194
costs/src/storage_cost/key_value_cost.rs:64
grovedb/src/batch/mod.rs:2945
Suggested fix
Use checked_add, checked_sub, and u32::try_from with explicit overflow errors.
Suggested tests
Add boundary tests around u32::MAX, u32::MAX - n, and oversized serialized values.
Created from a Codex audit of grovedb. No code changes were made as part of the audit.
Summary
Several element sizing and cost-accounting paths use unchecked
u32arithmetic or unchecked casts.Impact / failure scenario
Near-
u32::MAXlengths can wrap in release or panic in debug, causing undercharged storage costs or verifier bypasses.References
grovedb-element/src/element/helpers.rs:622grovedb-element/src/element/helpers.rs:647grovedb-element/src/element/helpers.rs:681costs/src/lib.rs:194costs/src/storage_cost/key_value_cost.rs:64grovedb/src/batch/mod.rs:2945Suggested fix
Use
checked_add,checked_sub, andu32::try_fromwith explicit overflow errors.Suggested tests
Add boundary tests around
u32::MAX,u32::MAX - n, and oversized serialized values.