Skip to content

Finish the inactivity wipe: the secrets it was missing - #448

Open
kkdao wants to merge 5 commits into
3rdIteration:devfrom
kkdao:fix/inactivity-wipe
Open

kkdao wants to merge 5 commits into
3rdIteration:devfrom
kkdao:fix/inactivity-wipe

Conversation

@kkdao

@kkdao kkdao commented Sep 20, 2026 •

Copy link
Copy Markdown

Description

Problem or Issue being addressed

The inactivity wipe told the user their data was wiped while secrets survived it:

  1. Slip39Seed / XprvSeed wipe() raised, which aborted the rest of the wipe; an xprv seed's root key was never zeroed.
  2. A half-entered mnemonic, a WIF key in psbt_seed, the JavaCard GlobalPlatform keys, card PINs and Satodime unlock secrets, the EncryptedQR key and the password-generator entropy were not wiped at all.
  3. One failing step skipped every step after it, and an exception ended the timer thread, turning the wipe off for the rest of the session.

Solution

Five commits:

  1. fix: wipe the secrets the inactivity timer misses — every step runs on its own; wipe_dict() zeroes only the named secret fields, so type tags like single survive.
  2. fix: keep the wipe timer running after an error
  3. fix: zero the WIF signing key when going Home
  4. fix: never zero a bytes object CPython shares — one-byte bytes are interned; zeroing one corrupted it for the whole process.
  5. fix: let the screensaver start after a wipe — the wipe leaves an unrun main-menu Destination on the back stack, and the screensaver check read its missing view: every device with the Wipe Timer on showed a System Error after the first wipe (found on the Pi Zero test below; the check is on dev too).

Additional Information

Not fixed here: a WIF key dropped mid-flow is freed without being zeroed (the natural place is #451's psbt_seed setter once it lands); BIP85 GPG keys stay in the gpg keyring; camera entropy frames are only dereferenced.

Screenshots

N/A — no screen change.


This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Documentation
  • Other

Checklist

I ran pytest locally

  • All tests passed before submitting the PR
  • I couldn't run the tests
  • N/A

CI on the fork (Linux 3.10/3.12 and the Linux/macOS desktop matrix, screenshots included) is green on this exact code. The Windows desktop lanes were left out: they fail on dev itself ("runner lost communication").

I included screenshots of any new or modified screens

  • Yes
  • No
  • N/A

I added or updated tests

  • Yes
  • No, I'm a fool
  • N/A

I tested this PR hands-on on the following platform(s):

  • Raspberry Pi OS
  • SeedSigner OS on a Pi0/Pi0W board
  • Emulator

Pi Zero, SeedSigner OS built from this branch merged with #449–#451: Wipe Timer set to 5 minutes, left idle, the wipe ran and returned to the main screen; the next use hit the screensaver AttributeError that commit 5 fixes. Commit 5 is in-memory controller state only, reproduced exactly by its unit test, so it was not re-flashed.

I have reviewed these notes:

  • I understand

@kkdao
kkdao force-pushed the fix/inactivity-wipe branch from c1c50c6 to 2b6a0d0 Compare September 21, 2026 08:24
@kkdao
kkdao marked this pull request as draft September 21, 2026 17:29
The inactivity wipe zeroed stored seeds, but other secrets outlived
it.

The inherited Seed.wipe() clears _mnemonic, which Slip39Seed and
XprvSeed never defined. It raised AttributeError after the subclass
fields were zeroed, and the exception escaped clear_pending_seed() and
aborted handle_wipe_timeout(): nothing after it was cleared and no
toast was shown. XprvSeed.wipe() dropped the HDKey parsed from the
xprv without zeroing its key and chain code.

The words of a half-finished seed entry live in SeedStorage rather
than in a Seed, so nothing cleared them. psbt_seed can hold a WIFKey,
which never enters storage.seeds and had no wipe(). The psbt parser
keeps a root key of its own, and can hold a WIF key that psbt_seed has
already dropped. The timer never touched the GlobalPlatform card keys.
The password-generator entropy, the card PINs, the Satodime unlock
secrets, the OpenPGP admin PIN and the EncryptedQR key were only
dereferenced.

Zero each of these where it is held, and make clear_pending_seed()
best-effort as discard_seed() already is. Each zeroing step runs on
its own, so one failure cannot skip the others.

wipe_dict() zeroes only the values named as secret. Next to them sit
type tags and source names that are code constants, and on CPython
before 3.12, which the device runs, a constant is not immortal:
zeroing one in place breaks the key file parser and every comparison
with the constant until reboot.
WipeTimerThread is the only thing that runs the inactivity wipe, and
nothing caught an exception inside it. One failure in
handle_wipe_timeout(), such as the AttributeError a pending
Slip39Seed or XprvSeed used to raise, ended the thread: that wipe
stopped part way, no toast was shown, and no later timeout wiped
anything for the rest of the session.

Log the error and keep the thread running. The inactivity clock
restarts after a failed wipe, so the wipe is retried after the next
full interval rather than every second.
A WIF or BIP38 key signs a psbt without entering SeedStorage, so the
inactivity wipe reaches it only while psbt_seed or the psbt parser
still holds it. Home ends the psbt flow and drops both references: on
the ordinary route, sign and then go Home, the private key was freed
unzeroed long before any timeout, and the later wipe still reported
the data as wiped.

Zero a WIF key held by psbt_seed or by the parser before Home drops
them. A stored seed is left alone: it outlives the flow, and an
XprvSeed shares its root key with the parser.
wipe_string() refuses a string the interpreter shares, but
wipe_bytes() zeroed any bytes object it was given. CPython keeps one
object for each one-byte value, so wiping a one-byte secret turned
that value into NUL everywhere else in the process, on every version.
One-character strings are cached the same way, and before 3.11 their
refcount is too low for the shared-string check to notice.

Treat one-byte and one-character objects as shared, and give
wipe_bytes() the same guard as wipe_string().
The inactivity wipe leaves a Destination for the main menu on the back
stack, for the main loop to run next. A Destination has no view until
it has run, and the check for whether the screensaver may start read
the view of the top one, so the first check after a wipe raised
AttributeError and the device showed a System Error. Every device with
the Wipe Timer on hit it the first time the timer fired.

A Destination that has not run yet counts as the main menu, as an
empty back stack already did.
@kkdao
kkdao force-pushed the fix/inactivity-wipe branch from 2b6a0d0 to 4f66509 Compare September 22, 2026 09:19
@kkdao
kkdao marked this pull request as ready for review September 22, 2026 09:20

This branch has not been deployed

No deployments
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