Skip to content

SOCKS options from multiple bridge lines clobber each other in socksAcceptLoop

socksAcceptLoop accepts a ClientConfig struct with default configuration options (from the command line). It then further modifies the ClientConfig with options from each SOCKS client connection.

The problem is, socksAcceptLoop uses the same ClientConfig for all SOCKS connections. That means that the options from multiple SOCKS connections end up accumulating into the same struct. This causes no harm when only one bridge line is used, because the same struct fields just get overwritten with the same values. The problem happens when two or more bridge lines have different options. All the different options get mixed up in the same struct.

You can see this by configuring two bridge lines, one with domain fronting and one with SQS. The first SOCKS connection sets config.BrokerURL. The second SOCKS connection sets config.SQSQueueURL. This ends up causing an error in newBrokerChannelFromConfig: "Multiple rendezvous methods specified".

socksAcceptLoop should make an independent copy of its config argument for each new SOCKS connection.