Skip to content

[audit][low] SQLite commitment store casts negative integers to huge unsigned positions #714

Description

@QuantumExplorer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions