Skip to content

Conversation

@fxrhan
Copy link
Contributor

@fxrhan fxrhan commented Jan 3, 2026

I noticed that when sqlmap tries different SSL/TLS versions to connect to a server, it wasn't closing the socket if the handshake threw an exception. Each failed attempt left an open socket behind, which could add up to a resource leak over time.

The fix:
Pretty straightforward - I added sock.close() to both exception handlers in HTTPSConnection.connect(). This matches what the code already does when wrap_socket returns a falsy value (see lines 94 and 112), so it's just making the error path consistent with the existing cleanup logic.

Why it matters:
When scanning a lot of targets, or when a server rejects certain TLS versions, these leaked sockets could pile up and eventually hit system limits ("too many open files"). Not catastrophic, but definitely something worth fixing.

Tested by:
Verified the module imports cleanly
Checked that the fix follows the same pattern already used elsewhere in the function

When iterating through SSL/TLS protocols during connection establishment, the socket was not being closed when wrap_socket raised an exception. This caused socket resource leaks when connecting to servers that reject certain protocol versions.

The fix adds sock.close() calls to both exception handlers, matching the existing pattern used for non-exception failure cases.
stamparm added a commit that referenced this pull request Jan 4, 2026
@stamparm stamparm closed this Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants