Skip to content

Bound JSON nesting before recursive metadata parsing exhausts the stack #540

Description

@LunaStev

parse_value recursively calls parse_array/parse_object, which recursively parse their elements without tracking a depth limit. Nested metadata can therefore consume call stack proportional to input nesting rather than returning a bounded parse error. The compiler uses this parser for the std manifest, so malformed or extreme input should remain an ordinary diagnostic.

No stack-overflow reproducer was run in this audit.

Source evidence at the head of #520:

Acceptance:

  • Enforce a deliberate nesting bound before recursive descent, or use an iterative parser with bounded resource handling.
  • Cover arrays, objects and alternating nesting immediately below/at/above the chosen limit.
  • Return an error instead of a panic or process abort; include a subprocess test for very deep input where appropriate.
  • Ensure accepted trees can also be safely serialized/dropped and keep the parser dependency-free.

Related: #351 addresses string decoding, not recursion/resource limits.

Audit status: identified by static source inspection; the scenarios above have not been executed during this audit. The permalink fixes the reviewed revision; this report does not claim the defect was introduced by #520.

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

    bugA problem that causes incorrect behavior or crashes.help wantedThe issue requires extra attention or help from others.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions