Skip to content

Requests with a literal space in the request-target are accepted instead of rejected #99

Description

@kugland

RFC 9112 §3.1 defines the request-line as:

method SP request-target SP HTTP-version CRLF

A literal (unencoded) space is not a valid character in a request-target. A server receiving such a request should respond with 400 Bad Request.

darkhttpd's parse_request() stops URL parsing at the first space, silently truncates the URL there, and treats the next token as the HTTP version. For a request like:

GET /foo bar HTTP/1.1

…it parses /foo as the URL and bar as the protocol version, returning 404 instead of 400.

This has a secondary security implication: a field name embedded in the URL (e.g. GET /X-Forwarded-For: evil HTTP/1.1) is present in the raw request buffer and could be matched by code doing substring searches over the full buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions