Skip to content

Bug: Server crashes on malformed URL path #2

Description

@ascerra

Description

If a client sends a request with a URL containing characters that new URL() cannot parse, the server crashes with an unhandled exception because there's no try/catch around the URL constructor in the request handler.

Steps to reproduce

curl --path-as-is "http://localhost:3000/%%%invalid"

Expected behavior

Should return 400 Bad Request with an error message, and the server should continue running.

Actual behavior

The server process crashes with TypeError: Invalid URL and must be restarted manually. This means a single malformed request takes down the entire service.

Suggested fix

Wrap the URL parsing in a try/catch at the top of the request handler, returning a 400 response on failure.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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