stop a connection waiting to retry while the server settings are open, and reconnect on closing
What changed, and why it matters
This commit fixes a small timing bug in Sparrow Wallet's server settings screen. Previously, if the wallet was trying to reconnect to a server in the background while the user opened the server settings, the reconnect could read the half-edited settings and behave incorrectly. Now the reconnect is paused while settings are open and resumed when the settings screen closes.
Treat as a low-severity hardening fix. Review whether other configuration dialogs have similar background-activity races, and consider adding explicit locking or cancellation patterns for settings that affect live connections.
Security signals we found
TOCTOU-like race between background connection retry and user editing server settings
Potential use of partially modified server configuration by a connection attempt
Fix is preventive rather than reactive to a reported exploit
Evidence from the diff
In ServerSettingsController.initializeView(), the change detects when the app is not currently connected but a connection retry is pending. It calls AppServices.cancelConnection() to stop that pending retry and sets a flag (reconnectOnClosingProperty) so the master controller will reconnect once the settings dialog closes. This prevents a background retry from consuming server configuration that is in the middle of being edited.
Changed components
src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.javaAppServices connection retry logicServer settings dialogInspect captured patch +4 / −0
### src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java
@@ -431,6 +431,10 @@ public void initializeView(Config config) {
});
boolean isConnected = AppServices.isConnecting() || AppServices.isConnected();
+ //A connection waiting to retry would read these settings while they are being edited, so it is stopped and restarted once they are closed
+ if(!isConnected && AppServices.cancelConnection()) {
+ getMasterController().reconnectOnClosingProperty().set(true);
+ }
if(Config.get().getServerType() == ServerType.BITCOIN_CORE && AppServices.isConnecting()) {
testResults.appendText("Connecting to server, please wait...");Why this scored 28/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.