-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
h2/h2c: better error handling when CURL_MAX_HTTP_HEADER
is exceeded
#16535
Comments
This is a partial fix of curl#16535. The error message format is borrowed from the existing code[1]. Sample message before: curl: (56) process_pending_input: nghttp2_session_mem_recv() returned -902:The user callback function failed Sample message after: curl: (56) Error receiving HTTP2 header: 100(A value or data field grew larger than allowed) [1]: https://github.com/curl/curl/blob/df672695e5992ad9b99819e9950de682e243cb48/lib/http2.c#L1999-L2000
This is a partial fix of curl#16535. The error message format is borrowed from the existing code[1]. Sample message before: curl: (56) process_pending_input: nghttp2_session_mem_recv() returned -902:The user callback function failed Sample message after: curl: (56) Error receiving HTTP2 header: 100(A value or data field grew larger than allowed) [1]: https://github.com/curl/curl/blob/df672695e5992ad9b99819e9950de682e243cb48/lib/http2.c#L1999-L2000
This is a partial fix of #16535. The error message format is borrowed from the existing code[1]. Sample message before: curl: (56) process_pending_input: nghttp2_session_mem_recv() returned -902:The user callback function failed Sample message after: curl: (56) Error receiving HTTP2 header: 100(A value or data field grew larger than allowed) [1]: https://github.com/curl/curl/blob/df672695e5992ad9b99819e9950de682e243cb48/lib/http2.c#L1999-L2000 Closes #16536
In my testing, the server never seems to send the response header frame and curl just waits for a reply. Can you increase the tracing in curl via |
Hi @icing , thanks for helping look into this! Please find attached a local traffic capture on the sample request described above: a2.pcap.zip From the traffic capture it may be observed that:
Thus I would assume it's an issue related to nghttp2, which might come from either nghttp2 itself or curl's configuration of it. Besides, the sample server appears to work properly with other HTTP clients (e.g. Chromium[1]) with the 105 KB case. [1]: That won't work directly though due to the lack of h2c support. That however may be verified by introducing TLS+ALPN (e.g. to add a self-signed cert to the Nginx configuration or to put that service behind a TLS terminator) to suggest h2. |
@starrify just for clarification: you do not see curl "hanging", it gets the headers, errors and sends GOAWAY? (And I assume the curl command exist code is 16 - at least in my tests). |
Hi, sorry for the confusion. It indeed appears to be hanging to me. Please also refer to the traffic capture shared above:
After that curl exits by emitting the |
Thanks, I see now the delay in the pcap. Hmm, but that does not tell me what curl is doing here. Curl wants to terminate the transfer (that is why it sends the GOAWAY), but somehow stumbles during the CONTINUATION frames incoming. Could you produce a trace with Update: I have an idea and will make a PR. |
refs curl#16535 We send a GOAWAY, but some servers ignore that and happily continue sending the stream response. RST the stream when response header errors are encountered.
Hi @icing sorry for the delay and thanks for the follow-up work! Please find attached here the Please find attached here the respective With the local build the issue persists (hanging for ~75s / curl doesn't seem to terminate the connection after sending that |
@starrify having some problems piecing things together here:
Could you double check that the log is actually produced by a curl with #16544 and that the pcap file matches? Thanks. |
Hi @icing , hmm that's weird. I do see the client-sent
Sample output from wireshark: Just in case I happened to have sent a wrong file, could you please also verify that the SHA256 checksum of
I went verifying my shell history and to the best of my knowledge it is indeed at that branch where I made a local build and recorded the
Hmm.. I do not expect it to. In the main text of this issue report I described two cases observed. My other PR specifically targets case 1 (e.g. 101 KB payload) and here we've been talking about case 2 (e.g. 105 KB payload). I would assume that this is also the reason why #16544 doesn't fix it. |
Tried to get the sample server running locally, but the installation instructions for |
refs curl#16535 We send a GOAWAY, but some servers ignore that and happily continue sending the stream response. RST the stream when response header errors are encountered.
Hi @icing I'm sorry for the inconvenience. :( That PR at 819733b indeed seems to fix the issue, where curl sends a RST immediately following that GOAWAY. Thanks a lot for the help! :) Attached for reference are the same |
Thanks for confirming! |
That's a 👍 for #16544, right? |
Yes. |
I did this
Using curl for an h2/h2c request where the web server unexpectedly sends a header larger than
CURL_MAX_HTTP_HEADER
(currently 100 KB).Observed behavior:
CURL_MAX_HTTP_HEADER
(e.g. 101 KB), curl aborts the response with:curl: (56) process_pending_input: nghttp2_session_mem_recv() returned -902:The user callback function failed
which may be not clear enough.curl: (16) Error in the HTTP2 framing layer
).A PoC web server
(click to expand)
nginx.conf
(requires thenjs
module):foo.js
:To launch the service:
Reproducing the issue (with the above PoC web server)
Case 0: 99 KB -- good
Case 1: 101 KB -- could use better error message
Case 2: 105 KB -- blocks indefinitely (until timeout)
I expected the following
Expected behavior:
BTW with HTTP/1.1 curl handles this properly and emits the
CURLE_TOO_LARGE
error message.curl/libcurl version
Said behavior may be reproduced using my distro's curl release at 8.12.1:
Also using a local build at df67269:
operating system
The text was updated successfully, but these errors were encountered: