Skip to content

Rack::Lint SERVER_NAME and HTTP_HOST are insufficiently validated? #2295

@ioquatix

Description

@ioquatix

When we use URI.parse("http://#{http_host}/"), we assume that http_host holds a valid, sanitized hostname. However, URI.parse is fairly permissive in what it accepts. This can lead to unexpected (and potentially unsafe) behavior if http_host is user-controlled or not rigorously validated before parsing. Attackers can craft unusual or malicious values to manipulate the resulting URI in ways that are not obviously valid domain names. The same applies to SERVER_NAME.

Below is a condensed list of potentially unusual or invalid values that URI.parse("http://#{string}/") would still parse:

  1. Userinfo embedded

    • user:[email protected]
      (Parses as http://user:[email protected]/)
  2. Port numbers and paths

    • example.com:8080/path/to/endpoint
      (Parses as http://example.com:8080/path/to/endpoint/)
  3. Query or fragment

    • example.com?foo=bar#frag
      (Parses as http://example.com?foo=bar#frag/)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions