disable the proxy setting when no proxy server is configured
What changed, and why it matters
This commit tightens how Sparrow Wallet handles its proxy setting. Previously, a user could enable 'use proxy' even if no proxy server was actually configured, or the app could save an empty/whitespace proxy server value. The change now disables the proxy setting automatically when no valid proxy server is configured, trims whitespace from the proxy host, and treats blank host values as invalid. This is a defensive hardening fix that prevents the wallet from accidentally running without the privacy/protection the user expected from a proxy.
Treat as a low-to-moderate hardening fix. Users relying on proxies/Tor should upgrade and verify their proxy settings are still configured correctly after update. No immediate emergency response required absent a disclosed exploit.
Security signals we found
Proxy bypass / privacy degradation: enabling useProxy without a configured proxy server could lead to connections not being routed through the intended proxy/Tor
Input validation hardening: blank/whitespace proxy host values are now rejected
Configuration consistency fix: useProxy flag is now coupled to presence of a valid proxyServer
No explicit security advisory or CVE referenced in commit
Evidence from the diff
The patch modifies both the GUI and terminal server settings controllers. It introduces a shared setProxyConfig() helper that only sets Config.proxyServer when a non-blank host is parsed, and only sets Config.useProxy to true when both the user selected the proxy option and a valid proxyServer exists. It also changes the useProxy listener to set useProxy = newValue && proxyServer configured, and updates validation to use isBlank() instead of isEmpty(). getHost() now trims input before parsing. These changes prevent the wallet from operating with useProxy=true but no actual proxy configured, which could cause traffic to bypass the user’s intended Tor/proxy route.
Changed components
src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.javasrc/main/java/com/sparrowwallet/sparrow/terminal/settings/ServerProxyDialog.javaConfig.useProxy / Config.proxyServer settingsInspect captured patch +31 / −19
### src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java
@@ -403,7 +403,7 @@ public void initializeView(Config config) {
});
useProxy.selectedProperty().addListener((observable, oldValue, newValue) -> {
- config.setUseProxy(newValue);
+ config.setUseProxy(newValue && config.getProxyServer() != null && !config.getProxyServer().isBlank());
proxyHost.setText(proxyHost.getText() + " ");
proxyHost.setText(proxyHost.getText().trim());
proxyHost.setDisable(!newValue);
@@ -748,7 +748,7 @@ private void setupValidation() {
));
validationSupport.registerValidator(proxyHost, Validator.combine(
- (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Proxy host required", useProxy.isSelected() && newValue.isEmpty()),
+ (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Proxy host required", useProxy.isSelected() && newValue.isBlank()),
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Invalid host name", getHost(newValue) == null)
));
@@ -874,23 +874,31 @@ private ChangeListener<String> getProxyListener(Config config) {
return;
}
- String hostAsString = getHost(proxyHost.getText());
- Integer portAsInteger = getPort(proxyPort.getText());
- if(hostAsString != null && portAsInteger != null && isValidPort(portAsInteger)) {
- config.setProxyServer(HostAndPort.fromParts(hostAsString, portAsInteger).toString());
- } else if(hostAsString != null) {
- config.setProxyServer(HostAndPort.fromHost(hostAsString).toString());
- }
+ setProxyConfig(config);
};
}
+ private void setProxyConfig(Config config) {
+ String hostAsString = getHost(proxyHost.getText());
+ Integer portAsInteger = getPort(proxyPort.getText());
+ String proxyServer = null;
+ if(hostAsString != null && !hostAsString.isBlank() && portAsInteger != null && isValidPort(portAsInteger)) {
+ proxyServer = HostAndPort.fromParts(hostAsString, portAsInteger).toString();
+ } else if(hostAsString != null && !hostAsString.isBlank()) {
+ proxyServer = HostAndPort.fromHost(hostAsString).toString();
+ }
+
+ config.setProxyServer(proxyServer);
+ config.setUseProxy(useProxy.isSelected() && proxyServer != null);
+ }
+
private Protocol getProtocol() {
return (electrumUseSsl.isSelected() ? Protocol.SSL : Protocol.TCP);
}
private String getHost(String text) {
try {
- return HostAndPort.fromHost(text).getHost();
+ return HostAndPort.fromHost(text.trim()).getHost();
} catch(IllegalArgumentException e) {
return null;
}
### src/main/java/com/sparrowwallet/sparrow/terminal/settings/ServerProxyDialog.java
@@ -48,7 +48,7 @@ protected void addProxyComponents(Panel mainPanel) {
useProxy = new ComboBox<>("Yes", "No");
useProxy.setSelectedIndex(Config.get().isUseProxy() ? 0 : 1);
useProxy.addListener((selectedIndex, previousSelection, changedByUserInteraction) -> {
- Config.get().setUseProxy(selectedIndex == 0);
+ setProxyConfig(selectedIndex == 0);
});
mainPanel.addComponent(useProxy);
mainPanel.addComponent(new EmptySpace(TerminalSize.ONE));
@@ -70,26 +70,30 @@ protected void addProxyComponents(Panel mainPanel) {
}
proxyHost.setTextChangeListener((newText, changedByUserInteraction) -> {
- setProxyConfig();
+ setProxyConfig(useProxy.getSelectedIndex() == 0);
});
proxyPort.setTextChangeListener((newText, changedByUserInteraction) -> {
- setProxyConfig();
+ setProxyConfig(useProxy.getSelectedIndex() == 0);
});
}
- private void setProxyConfig() {
+ private void setProxyConfig(boolean useProxySelected) {
String hostAsString = getHost(proxyHost.getText());
Integer portAsInteger = getPort(proxyPort.getText());
- if(hostAsString != null && portAsInteger != null && isValidPort(portAsInteger)) {
- Config.get().setProxyServer(HostAndPort.fromParts(hostAsString, portAsInteger).toString());
- } else if(hostAsString != null) {
- Config.get().setProxyServer(HostAndPort.fromHost(hostAsString).toString());
+ String proxyServer = null;
+ if(hostAsString != null && !hostAsString.isBlank() && portAsInteger != null && isValidPort(portAsInteger)) {
+ proxyServer = HostAndPort.fromParts(hostAsString, portAsInteger).toString();
+ } else if(hostAsString != null && !hostAsString.isBlank()) {
+ proxyServer = HostAndPort.fromHost(hostAsString).toString();
}
+
+ Config.get().setProxyServer(proxyServer);
+ Config.get().setUseProxy(useProxySelected && proxyServer != null);
}
protected String getHost(String text) {
try {
- return HostAndPort.fromHost(text).getHost();
+ return HostAndPort.fromHost(text.trim()).getHost();
} catch(IllegalArgumentException e) {
return null;
}Why this scored 38/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.