What changed, and why it matters
This commit fixes a bug where the COLDCARD device's internal flash filesystem was created but not properly entered before trying to create a settings folder. As a result, the folder could be created in the wrong place or the filesystem setup could fail. The fix changes the code to enter the new filesystem first, then create the folder. A related change removes an extra argument when wiping the filesystem during seed operations, and adds a confirmation-key requirement to the filesystem wipe command to reduce accidental use.
Treat as a routine bugfix with possible reliability/security side effects. Review whether the missing os.chdir could have caused settings or HSM files to be written outside the intended filesystem, and verify that the corrected initialization path is covered by device tests. No immediate exploit mitigation is indicated by the diff alone.
Security signals we found
Filesystem initialization bug could leave device without expected settings directory or create it at wrong path
Incorrect working directory after mkfs/mount may cause subsequent file operations to target unexpected location
Function signature mismatch in seed.py suggests prior call could pass unexpected argument to filesystem wipe routine
Confirmation key added to destructive filesystem wipe reduces accidental trigger risk
Evidence from the diff
In shared/mk4.py, make_flash_fs() now calls os.chdir(‘/flash’) immediately after os.mount(fl, ‘/flash’) and then creates ‘settings’ as a relative path rather than ‘/flash/settings’. This ensures the VFS root is the current working directory before directory creation. In shared/seed.py, remember_ephemeral_seed() now calls wipe_flash_filesystem() without the True argument, matching the current function signature. In shared/actions.py, the wipe_filesystem UX confirmation now requires pressing key ‘4’ to proceed.
Changed components
shared/mk4.pyshared/seed.pyshared/actions.pyCOLDCARD Mk4 internal flash filesystem initializationInspect captured patch +5 / −3
diff --git a/releases/Next-ChangeLog.md b/releases/Next-ChangeLog.md
index 96294ab..708fa2d 100644
--- a/releases/Next-ChangeLog.md
+++ b/releases/Next-ChangeLog.md
@@ -10,6 +10,7 @@ This lists the new changes that have not yet been published in a normal release.
now offered for transactions of all sizes.
- Bugfix: If all change outputs have `nValue=0` they're not shown in UX.
- Bugfix: Disallow negative input/output amounts in PSBT.
+- Bugfix: Fix filesystem initialization after Wife LFS or Destroy Seed
# Mk4 Specific Changes
diff --git a/shared/actions.py b/shared/actions.py
index 370d848..884c0a0 100644
--- a/shared/actions.py
+++ b/shared/actions.py
@@ -1459,7 +1459,7 @@ async def wipe_filesystem(*A):
Erase internal filesystem and rebuild it. Resets contents of internal flash area \
used for settings, address search cache, and HSM config file. Does not affect funds, \
or seed words but will reset settings used with other temporary seeds & BIP-39 passphrases. \
-Does not affect MicroSD card, if any.'''):
+Does not affect MicroSD card, if any.''', confirm_key="4"):
return
from files import wipe_flash_filesystem
diff --git a/shared/mk4.py b/shared/mk4.py
index 297b33a..69b024c 100644
--- a/shared/mk4.py
+++ b/shared/mk4.py
@@ -11,7 +11,8 @@ def make_flash_fs():
os.VfsLfs2.mkfs(fl)
os.mount(fl, '/flash')
- os.mkdir('/flash/settings')
+ os.chdir('/flash')
+ os.mkdir('settings')
def make_psram_fs():
# Filesystem is wiped and rebuilt on each boot before this point, but
diff --git a/shared/seed.py b/shared/seed.py
index cc51ffd..66e42f1 100644
--- a/shared/seed.py
+++ b/shared/seed.py
@@ -737,7 +737,7 @@ async def remember_ephemeral_seed():
# address cache, settings from tmp seeds / seedvault seeds
# rebuild fs as we want to save current tmp settings immediately
from files import wipe_flash_filesystem
- wipe_flash_filesystem(True)
+ wipe_flash_filesystem()
dis.draw_status(bip39=0, tmp=0)
dis.fullscreen('Saving...')
Why this scored 41/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.