What changed, and why it matters
This change makes Electrum tolerate a failure when setting restrictive file permissions on a temporary wallet file. Previously, if the operating system refused the permission change (for example on some network file systems), saving a wallet would crash. Now it logs a warning and continues. The security trade-off is that in rare cases a wallet file may be created with slightly looser permissions than intended, but the wallet data is still encrypted by the user's password if the wallet is password-protected.
Users who store wallets on network filesystems or other environments where chmod fails should verify that wallet files are not world-readable and should continue to use strong wallet passwords. Developers should consider whether a failed chmod should trigger a stronger warning or an explicit user notification, since silent fallback to default permissions could expose unencrypted metadata or backup files in edge cases.
Security signals we found
Permission-hardening logic changed from mandatory to best-effort
Potential for wallet temp file to be created with default (less restrictive) permissions on exotic filesystems
Fixes a denial-of-service style crash during wallet save operations
No change to encryption of wallet data itself
Evidence from the diff
In WalletStorage.write(), the call to os_chmod() on the temporary wallet file is now wrapped in a try/except for PermissionError. The intent of the original chmod was to set restrictive permissions before writing sensitive data. The patch makes that chmod best-effort: if it fails, the write continues with a warning. This fixes crashes on environments such as NFS where chmod may fail, but it weakens the defense-in-depth permission-hardening guarantee in those same environments. The wallet contents remain encrypted by the user’s passphrase if one is set.
Changed components
electrum/storage.pyWalletStorage.write()wallet file saving on filesystems where chmod failsInspect captured patch +4 / −1
diff --git a/electrum/storage.py b/electrum/storage.py
index b7d2a6b..7c79f2d 100644
--- a/electrum/storage.py
+++ b/electrum/storage.py
@@ -104,7 +104,10 @@ class WalletStorage(Logger):
s = self.encrypt_before_writing(data)
temp_path = "%s.tmp.%s" % (self.path, os.getpid())
with open(temp_path, "wb") as f:
- os_chmod(temp_path, mode) # set restrictive perms *before* we write data
+ try:
+ os_chmod(temp_path, mode) # set restrictive perms *before* we write data
+ except PermissionError as e: # tolerate NFS or similar weirdness?
+ self.logger.warning(f"cannot chmod temp wallet file: {e!r}")
f.write(s.encode("utf-8"))
self.pos = f.seek(0, os.SEEK_END)
f.flush()
Why this scored 29/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.