A passphrase pasted with a trailing line ending is kept byte for byte, so the wallet is encrypted with a character the user cannot see or type #1132

Open
opened 2026-11-13 15:16:57 +00:00 by jarolrod · 0 comments
jarolrod commented 2026-11-13 15:16:57 +00:00 (Migrated from github.com)

The password fields keep a pasted line ending as part of the passphrase. A wallet created with Correct-Horse-7 plus a line feed pasted into both fields is not opened by Correct-Horse-7 typed, and nothing on the form shows the extra character. Bitcoin-Qt's field keeps the same bytes.

To reproduce:

  1. Put Correct-Horse-7 followed by a line feed on the clipboard.
  2. Add wallet → Regular, type a name, and paste into Password and Confirm password. Both show 16 bullets and no mismatch message. With Show password on, both read Correct-Horse-7.
  3. Tick the acknowledgement, Create wallet, Done.
  4. walletpassphrase "Correct-Horse-7" 5 fails with error -14. With the line feed appended it unlocks.
  5. Wallet settings → Sign message: at the prompt, Correct-Horse-7 typed gives "The wallet password you entered was incorrect." Pasting the same clipboard signs.
Pasted Result
Seven clipboards (trailing LF, CRLF, CR, leading LF, inner LF, TAB, trailing space) into eight fields: Add wallet (2), Set password (2), Update password (3), the Sign message prompt kept exactly, 56 of 56
The same clipboard in both fields counted as matching, 7 of 7
Wallets made with a pasted control character 8 of 8 refuse the visible text and open with the pasted text
Pasted into Password, typed into Confirm "Passwords don't match", Create disabled
Plain wallet, correct passphrase pasted with LF, CRLF or a space at the prompt called incorrect

The last row is the everyday form: a correct passphrase copied with its line ending is refused at an unlock prompt. The lock-out needs the same clipboard in both fields. Masked, the field has one bullet more. With Show password on there is no sign: the text and its width are the same with and without the line feed.

The fields have no validator, the create form trims the name and the xpub but not the passphrase, and the text goes to Core byte for byte:

github.com/bitcoin-core/gui-qml@2bd5a61e83/qml/pages/wallet/CreateWalletForm.qml (L43-L44)

github.com/bitcoin-core/gui-qml@2bd5a61e83/qml/util.cpp (L76-L85)

Core takes exactly the bytes it is given, and its own tool does not add a line ending by accident: bitcoin-cli encryptwallet "$(printf 'Correct-Horse-7\n')" encrypts with the 15 characters. Bitcoin-Qt passes its QLineEdit text on with no trimming, and a QLineEdit set up as its dialog sets it up, run on the same Qt 6.9.0, kept all seven clipboards unchanged. With the passphrase shown it draws a line ending as a space, which is the one difference. I did not run Bitcoin-Qt itself.

A line ending cannot be typed into these fields, so could pasted ones be dropped, or at least reported? #931 would remove one of the three flows. #1052 at e89a2bcd4624 and #1060 at 733018ca9eab add no filter, by their diffs.

Reproduced on qt6 at 2bd5a61e8304 and eed1f426fcb6, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen only. The paste was not Cmd+V: the clipboard was the offscreen platform's private one, set through the test bridge, and the field's own paste function was called after a forced focus. I have not shown that a real paste from the macOS clipboard delivers the line ending; by Qt's source it does. Which everyday sources leave a trailing line ending on the clipboard was not tested; by its manual, pbcopy fed from a pipeline keeps it. Only LF, CR, TAB and a space were tried, and the Send, Speed up, Receive and migration prompts were not pasted into.

The password fields keep a pasted line ending as part of the passphrase. A wallet created with `Correct-Horse-7` plus a line feed pasted into both fields is not opened by `Correct-Horse-7` typed, and nothing on the form shows the extra character. Bitcoin-Qt's field keeps the same bytes. To reproduce: 1. Put `Correct-Horse-7` followed by a line feed on the clipboard. 2. **Add wallet → Regular**, type a name, and paste into **Password** and **Confirm password**. Both show 16 bullets and no mismatch message. With **Show password** on, both read `Correct-Horse-7`. 3. Tick the acknowledgement, **Create wallet**, **Done**. 4. `walletpassphrase "Correct-Horse-7" 5` fails with error -14. With the line feed appended it unlocks. 5. **Wallet settings → Sign message**: at the prompt, `Correct-Horse-7` typed gives "The wallet password you entered was incorrect." Pasting the same clipboard signs. | Pasted | Result | |---|---| | Seven clipboards (trailing LF, CRLF, CR, leading LF, inner LF, TAB, trailing space) into eight fields: Add wallet (2), **Set password** (2), **Update password** (3), the Sign message prompt | kept exactly, 56 of 56 | | The same clipboard in both fields | counted as matching, 7 of 7 | | Wallets made with a pasted control character | 8 of 8 refuse the visible text and open with the pasted text | | Pasted into Password, typed into Confirm | "Passwords don't match", Create disabled | | Plain wallet, correct passphrase pasted with LF, CRLF or a space at the prompt | called incorrect | The last row is the everyday form: a correct passphrase copied with its line ending is refused at an unlock prompt. The lock-out needs the same clipboard in both fields. Masked, the field has one bullet more. With **Show password** on there is no sign: the text and its width are the same with and without the line feed. The fields have no validator, the create form trims the name and the xpub but not the passphrase, and the text goes to Core byte for byte: https://github.com/bitcoin-core/gui-qml/blob/2bd5a61e8304d5143e32f1ce977a2de2aceb6413/qml/pages/wallet/CreateWalletForm.qml#L43-L44 https://github.com/bitcoin-core/gui-qml/blob/2bd5a61e8304d5143e32f1ce977a2de2aceb6413/qml/util.cpp#L76-L85 Core takes exactly the bytes it is given, and its own tool does not add a line ending by accident: `bitcoin-cli encryptwallet "$(printf 'Correct-Horse-7\n')"` encrypts with the 15 characters. Bitcoin-Qt passes its `QLineEdit` text on with no trimming, and a `QLineEdit` set up as its dialog sets it up, run on the same Qt 6.9.0, kept all seven clipboards unchanged. With the passphrase shown it draws a line ending as a space, which is the one difference. I did not run Bitcoin-Qt itself. A line ending cannot be typed into these fields, so could pasted ones be dropped, or at least reported? #931 would remove one of the three flows. #1052 at `e89a2bcd4624` and #1060 at `733018ca9eab` add no filter, by their diffs. Reproduced on `qt6` at `2bd5a61e8304` and `eed1f426fcb6`, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen only. The paste was not Cmd+V: the clipboard was the offscreen platform's private one, set through the test bridge, and the field's own paste function was called after a forced focus. I have not shown that a real paste from the macOS clipboard delivers the line ending; by Qt's source it does. Which everyday sources leave a trailing line ending on the clipboard was not tested; by its manual, `pbcopy` fed from a pipeline keeps it. Only LF, CR, TAB and a space were tried, and the Send, Speed up, Receive and migration prompts were not pasted into.
Sign in to join this conversation.
No description provided.