Skip to content

tests demonstrating a failure case of CF digests #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: palantir-cassandra-2.2.18
Choose a base branch
from

Conversation

rhuffy
Copy link
Contributor

@rhuffy rhuffy commented Apr 25, 2025

During the review of #639, some concerns were raised about the potential for digest collisions when added the PageToken to the column family digest.

We should expect CFs that are not equal to have different digests, except for the unlucky hash collision.
After close inspection, it appears that the existing code is actually vulnerable to collisions of crafted Cells or DeletionInfos.

A Cell digest has the following structure

[ name, value, 8-bytes-timestamp, 0]

A DeletionInfo digest has the following structure (assuming there is no row tombstone)

[ start, end, 8-bytes-timestamp]

name, value in the Cell and start, end in the DeletionInfo are arbitrary-length ByteBuffers, so the structure of these digests is almost identical, except for the suffixed 0 at the end of the Cell digest. With some simple bit shifting, we can easily craft a Cell and a DeletionInfo that have the same digest.

cell("A", "B", 1)
[ name, value, 8-bytes-timestamp, 0]
[ 65,   66,    0,0,0,0,0,0,0,1,   0]

tombstone("AB", "\0", 1 << 8)
[ start,     end, 8-bytes-timestamp]
[ 65, 66,    0,   0,0,0,0,0,0,1,0 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant