Skip to content

Invalid HTTP method with whitespace in -X / --request ends up in HTTP/2 path #19543

@Omdahake

Description

@Omdahake

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

  1. Build curl (latest master or release branch).
  2. Run: ./curl -v -X "GET 123" https://example.com -v
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions