set restrictive unix umask application-wide by default
What changed, and why it matters
This change makes Electrum create files and folders with stricter default permissions, so other users on the same computer cannot read or modify them. The developer noticed the RPC socket was being created with overly permissive permissions (0o775, meaning group members had full access), and decided to tighten the default for all files rather than fixing each case individually. It is a proactive hardening patch, not a fix for a reported exploit.
Treat as a worthwhile hardening commit. Review whether any remaining explicit chmod/0o775 calls are still intentional and necessary, and verify that the RPC socket and other sensitive files now receive owner-only permissions on supported platforms. No urgent incident response is indicated.
Security signals we found
Hardening: restrictive default umask applied application-wide
Information-disclosure/pre-auth risk: RPC unix socket previously created with group-writable 0o775
Proactive fix: no CVE or exploit chain described in commit
Scope limitation: umask set only in run_electrum, not in library import path
Evidence from the diff
The commit adds os.umask(0o0077) near the top of the run_electrum entry point. This causes all subsequently created files and directories to default to owner-only access (rw------- for files, rwx------ for dirs), unless the code explicitly chmods them wider. The stated motivation is that the RPC server unix domain socket was being created with 0o775 permissions, which would let any member of the owner’s group read/write the socket. The umask is placed in run_electrum rather than electrum/init.py to avoid changing behavior when Electrum is imported as a library. The patch is a default-hardening measure; it does not remove any specific vulnerable permission call.
Changed components
run_electrum entry pointElectrum data directory file/directory creationRPC server unix domain socket permissionsInspect captured patch +9 / −0
diff --git a/run_electrum b/run_electrum
index df45836..e0fd845 100755
--- a/run_electrum
+++ b/run_electrum
@@ -107,6 +107,15 @@ if is_android:
ctypes.pythonapi = ctypes.PyDLL("libpython%d.%d.so" % sys.version_info[:2]) # replaces ctypes.PyDLL(None)
+# Set default application-wide file umask to more restrictive than typical.
+# We want to create all files and directories (esp. inside the datadir) with locked-down permissions.
+# note: this helps even on Windows! (see https://docs.python.org/3/library/os.html#os.mkdir)
+# > `os.mkdir(path, mode=0o777, *, dir_fd=None)`
+# > On Windows, a mode of 0o700 is specifically handled to apply access control to the new
+# > directory such that only the current user and administrators have access.
+os.umask(0o0077)
+
+
sys._ELECTRUM_RUNNING_VIA_RUNELECTRUM = True # used by logging.py
from electrum.logging import get_logger, configure_logging # import logging submodule first
Why this scored 52/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.