I did this
#Problem
When passing a custom HTTP method with spaces using -X or --request, curl sends unexpected pseudo-headers in HTTP/2:
Example:
./curl -X "GET 123" https://example.com -v
Observed HTTP/2 request:
:method: GET
:path: 123 /
:scheme: https
:authority: example.com
The extra tokens after the first word in the method end up in the path, which is non-standard and can confuse servers.
Steps to reproduce
- Build curl (latest master or release branch).
- Run:
./curl -v -X "GET 123" https://example.com -v
- Observe the :path header in HTTP/2.
Observed behavior
- Curl sends
:path: 123 / instead of rejecting the invalid method.
- Servers respond with 404 or "Invalid URL".
Expected behavior
- Curl should reject methods containing whitespace according to RFC 9110.
- It should not use leftover tokens as the request path.
Notes
- This is "not a security vulnerability" but a spec compliance issue and could be confusing for users.
- Relevant source file:'tool_getparam.c', in the 'C_REQUEST' case for -X / --request.
I expected the following
- Curl should reject any HTTP method that contains whitespace, instead of sending it.
- No extra tokens after the first word should be used as part of the request path or pseudo-headers.
- The command should return an error message like:
curl/libcurl version
curl 8.18.0
operating system
Operating System: Linux x86_64, Debian 6.1.76-1, Kernel 6.1.0-18-amd64 (SMP PREEMPT_DYNAMIC)
I did this
#Problem
When passing a custom HTTP method with spaces using -X or --request, curl sends unexpected pseudo-headers in HTTP/2:
Example:
Observed HTTP/2 request:
The extra tokens after the first word in the method end up in the path, which is non-standard and can confuse servers.
Steps to reproduce
./curl -v -X "GET 123" https://example.com -vObserved behavior
:path: 123 /instead of rejecting the invalid method.Expected behavior
Notes
I expected the following
curl/libcurl version
curl 8.18.0
operating system
Operating System: Linux x86_64, Debian 6.1.76-1, Kernel 6.1.0-18-amd64 (SMP PREEMPT_DYNAMIC)