HomePhabricator

[electrum] fix error when cached password is forwarded to subwidget

Description

[electrum] fix error when cached password is forwarded to subwidget

Summary:
In D14729 we implemented zeroing the cached password in memory when a the owner widget is destructed.
This causes an issue when the password is initially cached by a parent widget (AvaDelegationWidget) and then passed to a child widget (AuxiliaryKeysDialog), because python passes a reference to the password. So when the child widget is destructed, the password is zeroed in memory also for the parent widget, which then causes an error when the parent widget tries to use it to decrypt the wallet.

  File "/home/pierre/dev/bitcoin-abc/electrum/electrumabc/bitcoin.py", line 296, in aes_decrypt_with_iv
    return strip_PKCS7_padding(data)
  File "/home/pierre/dev/bitcoin-abc/electrum/electrumabc/bitcoin.py", line 267, in strip_PKCS7_padding
    raise InvalidPadding("invalid padding byte (large)")
electrumabc.bitcoin.InvalidPadding: invalid padding byte (large)

Only zero the pwd memory in the del method of the widget that initialized the bytearray, so child widgets will not clear it if they received the reference via their init method.

Depends on D15708

Test Plan: Open the delegation editor, paste a proof or a delegation to trigger the password prompt and cache the wallet password in memory. Then click "generate key" next to the delegated key field so that the child widget is created. Close the auxiliary key dialog. Paste again a proof or delegation and check that there is no error related to InvalidPassword

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D15709

Details

Provenance
PiRKAuthored on Mar 15 2024, 09:29
PiRKPushed on Mar 15 2024, 14:26
Reviewer
Restricted Project
Differential Revision
D15709: [electrum] fix error when cached password is forwarded to subwidget
Parents
rABC220efcb592cf: [electrum] prefill the delegator key in the delegation editor when possible
Branches
Unknown
Tags
Unknown