Fixes an issue where tlsx could hang indefinitely during large scans with cipher enumeration enabled.

Root Cause

During large scans some targets accept a TCP connection but never complete the TLS handshake. In this situation the TLS handshake call can block indefinitely.

Additionally, several parts of the scanning pipeline used context.Background() for connection pool acquisition and network operations. Under high concurrency this allowed workers to block without any timeout, eventually causing the scan to stall after processing thousands of targets.

Cipher enumeration also performed TLS handshakes sequentially, which increased the likelihood of worker starvation when multiple slow or unresponsive hosts were encountered.

Fix

This PR ensures that all potentially blocking operations respect timeouts and cannot stall workers:

  • Use timeout-aware contexts for pool.Acquire() and TLS operations.
  • Execute TLS handshakes with explicit deadlines so they cannot block indefinitely.
  • Close the underlying connection when a timeout occurs to guarantee the handshake returns.
  • Parallelize cipher enumeration using CipherConcurrency to avoid sequential blocking.
  • Ensure JSONL output is flushed reliably to prevent truncated output if the process stops.

Testing

Environment: Arch Linux
Go 1.26

Test setup:

  • 30,000 targets
  • concurrency: 300
  • cipher enumeration enabled

Before fix: tlsx consistently stalled around ~25k targets and the JSON output file ended with a truncated line.

After fix: The scan completes successfully with all results written and no deadlock observed.
JSONL output is valid and complete.

Proof: 30k targets processed successfully in 2min 31 sec

/claim #819

Claim

Total prize pool $1,324
Total paid $0
Status Pending
Submitted March 07, 2026
Last updated March 07, 2026

Contributors

BI

BISHT.cx

@cherry-bisht

100%

Sponsors

YO

youssefosama3820009-commits

@youssefosama3820009-commits

$1,224
PR

ProjectDiscovery

@projectdiscovery

$100