Skip to content

PR #582 recovery fix preserves only one coded word; backspacing across two boundaries corrupts bypass detection again #584

Description

@BitHighlander

Residual defect in the proposed #581 fix

PR #582 adds a single last_completed_coded_word[12] and overwrites it every time a word is completed. That repairs one backspace across the immediately preceding boundary, but it cannot restore raw host bytes after the user backs up across two or more completed words.

Concrete sequence after entering two words and the following space:

  1. State is decoded mnemonic word1 word2 ; last_completed_coded_word contains only word2 raw bytes.
  2. Delete the trailing space: coded_word is correctly restored to word2.
  3. Delete every character of word2: coded_word becomes empty and mnemonic ends in the space after word1.
  4. Delete that space: plaintext decoded_word now points at word1, but the code again copies last_completed_coded_word, which still contains word2 raw bytes.
  5. Re-enter/correct word1. Once coded_word reaches four bytes, attempt_auto_complete(coded_word) evaluates a synthetic word2/word1 mixture rather than the literal host bytes, recreating the substitution-cipher-bypass detector gap recovery_cipher.c: backspace-before-4th-character defeats the substitution-cipher-bypass detector, because the per-position cipher used to reconstruct coded_word isn't preserved #581 was meant to close.

The PR adds no targeted recovery/backspace regression tests, so its reported 494/499 existing-suite result does not exercise this state transition.

Required fix

Preserve raw coded history for every editable word (or maintain a separate raw-coded mnemonic/history stack), not only the most recently completed word. Add regressions that backspace:

  • within the current word;
  • across one word boundary;
  • across two and 23 word boundaries;
  • then re-enter a direct unciphered BIP39 prefix and prove the bypass detector still fires;
  • through repeated delete/retype cycles while checking words_entered, decoded mnemonic, and raw coded history remain aligned.

Related: #581 and PR #582.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions