You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Socket use after close when connecting to remote HTTPS via HTTPS proxy #8193
First I set a debug log on CloseHandle and I found out that we are closing the same handle in the place which I patched. When the code unwinds from there it triggers the stream_error on
which is an interesting code. Curl_ssl_close will dereference SSL context at curl_easy_t->conn->ssl[0]->backend which has the same socket handle in it's read/write structures as curl_easy_t->conn->sock[0] which was just closed.
Activity
bagder commentedon Dec 27, 2021
You didn't show the curl -V output though, so we're clueless about your TLS config.
intxgo commentedon Dec 27, 2021
Thanks, I see, but I'm only linking with curl lib in my project.
Running curl.exe built from this repo, top of master branch, the problem is still there. I added
curl -V outputto the description above.Patch which enables strict handle check policy on Windows:
https://github.com/intxgo/curl/blob/8c04acbaecd4071b86c962998545c77fcf49b066/src/tool_main.c#L262-L275
With the above policy, unpatched code crash when executed like this (with no server on port 9999):
with my PR all is fine:
bagder commentedon Dec 27, 2021
I want to A) reproduce the problem and then B) verify that the fix is fine.
bagder commentedon Dec 27, 2021
It does not reproduce for me on Linux, with or without valgrind:
./src/curl -x https://localhost:8843 https://localhost:7999/ --proxy-insecureWhere is the socket use after close happening? Can you get a stack trace from your crash?
intxgo commentedon Dec 28, 2021
The stack trace:
First I set a debug log on CloseHandle and I found out that we are closing the same handle in the place which I patched. When the code unwinds from there it triggers the
stream_erroroncurl/lib/multi.c
Line 2006 in e7f9c90
then it falls into
curl/lib/multi.c
Line 2569 in e7f9c90
then here
curl/lib/url.c
Line 753 in e7f9c90
which is an interesting code.
Curl_ssl_closewill dereference SSL context at curl_easy_t->conn->ssl[0]->backend which has the same socket handle in it's read/write structures as curl_easy_t->conn->sock[0] which was just closed.A blind try to fix it with
also worked but walking the code, reading comments, I made an educated guess to fix it as submitted in my PR
http_proxy: don't close the socket (too early)
bagder commentedon Dec 28, 2021
Awesome, that was just the info I needed to get a full picture.