treat a proxy's reply that it could not reach the server as a server failure, so it no longer turns off the proxy
What changed, and why it matters
This change fixes a bug where Sparrow Wallet would disable its Tor/proxy connection whenever the proxy reported it couldn't reach the destination server. Previously, the app misread 'the destination is unreachable' as 'the proxy itself is broken' and turned off the proxy. Now it correctly treats those messages as server-side failures and keeps the proxy running. This is a reliability/privacy fix: users are less likely to accidentally fall back to a direct connection when their proxy is actually working fine.
Users relying on Tor or another SOCKS proxy should upgrade to a release containing this commit to avoid accidental proxy disablement when a server is temporarily unreachable. Reviewers should verify that the listed SOCKS messages cover all destination-failure cases emitted by the JVM's SocksSocketImpl across supported platforms and Java versions.
Security signals we found
Proxy bypass risk: misclassification of destination errors as proxy failures could cause the wallet to disable Tor/proxy and connect directly, degrading privacy
Network-level privacy fix: preserves intended proxy routing when the proxy is operational but the remote server is not
No cryptographic, authentication, or input-validation changes
Evidence from the diff
In TcpTransport.connect(), an IOException whose stack trace originated in SocksSocketImpl was unconditionally rethrown as ProxyServerException, which upstream handling interprets as a proxy failure and disables the proxy. The patch adds a set of SOCKS destination-failure message strings (general failure, network/host unreachable, connection refused, TTL expired, couldn’t reach destination) and only treats the exception as a proxy failure if the message is NOT one of those. Thus, destination-side errors are now propagated as ordinary server failures, preserving the proxy configuration.
Changed components
src/main/java/com/sparrowwallet/sparrow/net/TcpTransport.javaSparrow Wallet proxy/Tor connectivity logicInspect captured patch +5 / −1
### src/main/java/com/sparrowwallet/sparrow/net/TcpTransport.java
@@ -49,6 +49,10 @@ public class TcpTransport implements CloseableTransport, TimeoutCounter {
private static final Pattern ID_PATTERN = Pattern.compile("\"id\"\\s*:\\s*(\\d+)");
private static final JsonFactory JSON_FACTORY = new JsonFactory();
+ //The replies of a working proxy that could not reach the server, as SocksSocketImpl words them, which say nothing against the proxy itself
+ private static final Set<String> SOCKS_DESTINATION_FAILURES = Set.of("SOCKS server general failure", "SOCKS: Network unreachable", "SOCKS: Host unreachable",
+ "SOCKS: Connection refused", "SOCKS: TTL expired", "SOCKS server couldn't reach destination");
+
private static final AtomicLong deliveredResponses = new AtomicLong(); //Counts the responses delivered to callers ordering notifications with responses
private static final ThreadLocal<Long> lastResponseSequence = new ThreadLocal<>(); //Sequence of the response this thread's last RPC received
@@ -368,7 +372,7 @@ public void connect() throws ServerException {
} catch(SSLHandshakeException e) {
throw new TlsServerException(server, e);
} catch(IOException e) {
- if(e.getStackTrace().length > 0 && e.getStackTrace()[0].getClassName().contains("SocksSocketImpl")) {
+ if(e.getStackTrace().length > 0 && e.getStackTrace()[0].getClassName().contains("SocksSocketImpl") && !SOCKS_DESTINATION_FAILURES.contains(e.getMessage())) {
throw new ProxyServerException(e);
}
Why this scored 50/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.