daemon: (trivial) CommandsServer.run: move tcp-specific line
What changed, and why it matters
This is a tiny code cleanup in Electrum's background daemon. A line that only makes sense for TCP network sockets was moved so it no longer runs for Unix domain sockets or Windows named pipes. Before the fix, starting the command server over a non-TCP socket could crash with an error. There is no sign this was exploitable as a security vulnerability.
No security action required. Treat as normal code-quality fix. If backporting, include only for stability, not for security.
Security signals we found
Crash-avoidance fix for non-TCP socket types
No change to authentication or authorization logic
No change to network listeners or exposed interfaces
Evidence from the diff
The patch moves socket = site._server.sockets[0] inside the elif self.socktype == 'tcp': branch. Previously it ran unconditionally, which would raise an AttributeError for web.NamedPipeSite (which has no _server.sockets). This is a defensive correctness fix preventing a startup crash on non-TCP socket types; it does not change authentication, access control, or network exposure.
Changed components
electrum/daemon.pyCommandsServer.runInspect captured patch +1 / −1
diff --git a/electrum/daemon.py b/electrum/daemon.py
index ceab53c..a8fc2ce 100644
--- a/electrum/daemon.py
+++ b/electrum/daemon.py
@@ -327,10 +327,10 @@ class CommandsServer(AuthenticatedServer):
await site.start()
except Exception as e:
raise Exception(f"failed to start CommandsServer at {self._socket_config_str()}. got exc: {e!r}") from None
- socket = site._server.sockets[0]
if self.socktype == 'unix':
addr = self.sockpath
elif self.socktype == 'tcp':
+ socket = site._server.sockets[0]
addr = socket.getsockname()
else:
raise Exception(f"impossible socktype ({self.socktype!r})")
Why this scored 18/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.