node-http-mitm-proxy icon indicating copy to clipboard operation
node-http-mitm-proxy copied to clipboard

`Proxy.sslServers` race condition

Open fopinappb opened this issue 1 year ago • 1 comments

https://github.com/joeferner/node-http-mitm-proxy/blob/310a3bc8918b07b9c7dbdb345e358f8be2a74044/lib/proxy.ts#L677

...
https server started for www.google.com on 54724
https server started for www.google.com on 54726
...

With concurrent requests to www.google.com this semaphore is but the asynchronous callback (that populates sslServers) is outside the lock/sem.

This results in 2+ sslServers created for the same hostname yet only the last is tracked in the dictionary. This also means only the last one is cleaned up upon Proxy.close() resulting in lingering handles...

fopinappb avatar Apr 11 '23 20:04 fopinappb

This can be kinda worked around with forceSNI: true which doesn't create extra HTTPS servers.

WGH- avatar Nov 21 '23 14:11 WGH-