Skip to content

Compare strings, not only hash keys, in addnode() - #525

Merged
jsuto merged 1 commit into
masterfrom
fix-addnode-key-collision
Nov 6, 2026
Merged

jsuto merged 1 commit into
masterfrom
fix-addnode-key-collision

Conversation

@jsuto

@jsuto jsuto commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Problem

addnode() (src/hash.c) treated any existing node with the same DJBHash value as a duplicate. A new string whose hash collides with one already stored was silently dropped. findnode() compares the actual strings, so the two functions disagree.

DJBHash collisions are trivial to craft (e.g. "az" and "bY"). Impact per caller:

  • MIME boundaries: a crafted second boundary is not stored, so that part isn't split and its content can't be found by search.
  • IMAP folders: two folder names with colliding hashes cause one folder to be skipped during import.
  • Recipients (rcpt, rcpt_domain, journal_recipient): no real impact. Callers check duplicates with findnode() and append the address regardless.
  • mydomains: comes from admin-controlled config.

Follow-up to #524 (raised by an automated security review of that PR).

Fix

Also compare the stored string with strcmp() before treating a node as a duplicate.

Testing

  • New test_addnode_collision() in unit_tests/check_hash.c. It fails on master and passes with this change.
  • All unit tests, including the DB-backed check_parser, pass in sutoj/builder:resolute.

🤖 Generated with Claude Code

addnode() treated any existing node with the same DJBHash value as a
duplicate, so a string whose hash collides with an already stored one
was silently dropped. DJBHash collisions are trivial to craft (eg. "az"
and "bY"), so a crafted MIME boundary could prevent another boundary
from being stored, and colliding IMAP folder names would cause a folder
to be skipped during import.

Check the stored string with strcmp() as findnode() already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jsuto
jsuto merged commit e593b75 into master Nov 6, 2026
7 of 8 checks passed
@jsuto
jsuto deleted the fix-addnode-key-collision branch November 6, 2026 07:24
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