test: SOCKS5 proxy: expect that connection may be reset during handshake
What changed, and why it matters
This commit only changes a test helper script used during Bitcoin Core's automated testing. It makes the built-in SOCKS5 test proxy log expected connection resets as debug messages instead of printing full error backtraces. There is no change to the actual Bitcoin node software, no fix for a real vulnerability, and no security impact on users running Bitcoin Core.
No action needed. This is a test-only logging improvement with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/test_framework/socks5.py, a Python SOCKS5 proxy used only in the functional test suite. It adds handling for BrokenPipeError and ConnectionResetError during the SOCKS5 handshake so these expected test conditions are logged at debug level rather than as exceptions. It also improves log messages to include client/proxy socket addresses. The production bitcoind SOCKS5 client code is untouched.
Changed components
test/functional/test_framework/socks5.pyInspect captured patch +10 / −2
diff --git a/test/functional/test_framework/socks5.py b/test/functional/test_framework/socks5.py
index a794dc08..f7a1aabd 100644
--- a/test/functional/test_framework/socks5.py
+++ b/test/functional/test_framework/socks5.py
@@ -138,7 +138,12 @@ class Socks5Connection():
def handle(self):
"""Handle socks5 request according to RFC1928."""
+ log_exception_prefix = "Socks5Connection.handle(): "
try:
+ log_exception_prefix = ("Socks5Connection.handle("
+ f"client={format_sock(self.conn, local=False)}, "
+ f"proxy={format_sock(self.conn, local=True)}): ")
+
# Verify socks version
ver = recvall(self.conn, 1)[0]
if ver != 0x05:
@@ -212,9 +217,12 @@ class Socks5Connection():
else:
logger.debug(f"Can't serve the connection to {requested_to}: no destinations factory")
- # Fall through to disconnect
+ # Disconnect happens in the "finally" block below.
+
+ except (BrokenPipeError, ConnectionResetError) as e:
+ logger.debug(f"{log_exception_prefix}abnormal connection close: {str(e)}")
except Exception as e:
- logger.exception(f"socks5 request handling failed (running {self.serv.is_running()})")
+ logger.exception(f"{log_exception_prefix}exception: {str(e)} (running {self.serv.is_running()})")
if self.serv.is_running():
self.serv.queue.put(e)
finally:
Why this scored 15/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.