Skip to content

Literal Scalar Parsing should not panic #427

Closed
@dreamcodez

Description

@dreamcodez

Describe the bug
Literal Scalar Parsing should not panic. Sending badly shaped data is a thing that Denial-Of-Service attackers like to do -- and being able to panic the thread this easy is a smell in my opinion.

To Reproduce
Steps to reproduce the behavior:

  1. Define a schema with a scalar String, Int, or Float type
  2. Query the schema with query literals which violate the contract in step (1)
  3. Notice that the thread panics
  4. Code reference here: https://github.com/graphql-rust/juniper/blob/master/juniper/src/parser/value.rs ... look for parse_scalar_literal_by_infered_type and then look for the panics.

Expected behavior
The framework should handle this class of error gracefully without a panic. It should return in this case a proper 400 Bad Request HTTP Response with the standard graphql json error reporting array format: { "errors": [ "... must be an Int" ] }

Additional context
Violating the api shape is one of the easiest things a would-be denial-of-service attacker can try to attempt to crash your service and/or waste cpu cycles/compute resources/network resources.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions