rtk-ai / rtk-ai/rtk

recall: content_hash truncates SHA-256 to 48 bits and ON CONFLICT overwrites on collision

Open
#3,948 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:security bug good first issue priority:low
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

content_hash() truncates SHA-256 to 12 hex characters (48 bits) and the store uses ON CONFLICT to overwrite, so two different outputs that collide silently overwrite one another - the older entry is gone and its hash now resolves to unrelated content.

At the default max_entries = 200 the birthday probability is around 1e-10, so this is a low-severity robustness note rather than a live bug. Widening the prefix (16 hex is 64 bits) or treating a conflict with differing content as an insert rather than a replace would remove the class.

Surfaced during review of #3278; the truncation is pre-existing behaviour in that PR's design.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the content_hash() implementation and the store code that uses ON CONFLICT, then read the surrounding handling of cached entries and the design discussed in #3278. Determine the intended collision behavior before changing it; done means differing content cannot silently replace an existing entry and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.