Repository navigation
Conversation
An untrusted RFC 6902 patch can graft duplicated subtrees via add/copy (or replace the root) to amplify the document past CJSON_NESTING_LIMIT, setting up stack exhaustion in recursive passes. Refuse grafts whose parent depth plus value depth would reach the limit (status 12), including root replacement with an over-limit value. Depth helpers are self-bounding: value depth never recurses past the limit, and parent depth is counted from pointer separators. Add regression tests for rejection and the shallow success path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An untrusted RFC 6902 patch can graft duplicated subtrees via add/copy (or replace the root) to amplify the document past CJSON_NESTING_LIMIT -- e.g. one copy op taking a depth-602 document to depth 1202 -- setting up stack exhaustion in recursive passes.
This refuses grafts whose parent depth plus value depth would reach the limit (new status 12), including root replacement with an over-limit value. The depth helpers are self-bounding: value depth never recurses past the limit, and parent depth is counted from pointer separators (a raw '/' is always a separator since '/' in a key is escaped as ~1).
Evidence:
Residual note: pure breadth amplification (many small grafts) is memory pressure, not stack exhaustion, and is intentionally out of scope here.