Skip to content

fix(restore): warn when the restored words belong to an address the relay has never seen - #42

Merged
Henner4746 merged 2 commits into
mainfrom
fix/wiederherstellen-pruefen
Nov 30, 2026
Merged

Henner4746 merged 2 commits into
mainfrom
fix/wiederherstellen-pruefen

Conversation

@Henner4746

Copy link
Copy Markdown
Owner

Addresses SEC-H2 from the external security assessment of 16–23 Nov 2026: "about 1 in 15 mistyped phrases silently creates a different identity".

Confirmed

Bip39.validate checks 12 words = 128 bit entropy + 4 bit checksum, so a word swapped for another word of the list passes about one time in sixteen. After that, restoreIdentity opens a new database, and on the first connect _mitRelayMitGeraeten silently creates an epoch-1 device list for the unknown address. The user lands in an empty chat list of a stranger's identity, and nobody can reach them there.

Fix (without breaking existing phrases)

A stronger checksum would invalidate every phrase that exists today, so that is left as a decision. What can be said without breaking anything: an identity that was ever used has a device at the relay.

  • restoreIdentity marks the database (meta wiederherstellung_offen), so it also survives a restart before the first connect.
  • _ermittleGeraetId: if the first device query answers 404 after a restore, it sets wiederherstellung_unbekannt.
  • The chat list then shows a hint: "The server knows no device for these 12 words. A single mistyped word can still pass the check…", with Enter the words again (wipes the empty identity, opens the restore screen) and The words are right (for identities unused for a long time, or on another relay).

A normal new identity, and a restore of a used identity, never show the hint.

Tests

test/net/wiederherstellen_unbekannt_test.dart (real relay):

  • valid words never used before → hint; "The words are right" removes it, also after a restart;
  • the real words of a used identity → no hint;
  • a freshly created identity → no hint.

Run in CT 107: flutter analyze shows only the 29 existing hints; the new test plus wiederherstellen_test, geraeteabmeldung_test, zwei_geraete_test, geraeteliste_stufe2_test and all of test/oberflaeche: 219 green.

Open (decision)

🤖 Generated with Claude Code

Henner4746 and others added 2 commits November 23, 2026 08:05
…elay has never seen

The twelve words carry only a 4-bit BIP39 checksum, so about one in sixteen
swaps of a word for another list word passes and silently creates a
different, empty identity (security assessment 2026-11-23, SEC-H2). A
stronger checksum would break every existing phrase.

What can be said without breaking anything: an identity that was ever used
has a device at the relay. After a restore, if the relay answers 404 on the
first device query, the chat list shows a hint with "Enter the words again"
(wipes the empty identity and opens the restore screen) and "The words are
right" (identities unused for a long time or on another relay). The marker
lives in the database meta, so it survives a restart before the first
connect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…merge conflict

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Henner4746 Henner4746 mentioned this pull request Nov 30, 2026
@Henner4746
Henner4746 merged commit c921759 into main Nov 30, 2026
11 of 12 checks passed
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