Skip to content

json parser: add a configurable maximum nesting depth to the JSON parser #669

Open

Description

@mihajlo-k

What

The JSON library currently accepts documents of arbitrary nesting depth.

Add a bounded nesting depth to the parser, with a sane default and the ability to configure it, so that documents exceeding the limit are rejected with a regular parse error instead of being accepted.

If not implemented there is a risk of stack exhaustion from untrusted input. Parsing itself is iterative, but traversal, comparison, cloning, serialization and destruction of the resulting tree are recursive. A deeply nested document is accepted at parse time and then crashes the process later, in unrelated code.

Acceptance Criteria (DoD)

  • The parser rejects documents whose nesting depth exceeds the configured limit, returning a normal parse error.
  • A default limit is defined and documented.
  • The limit is configurable by the integrator.

How

No response

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

    comp-jsonRelated to score/json component

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions