Skip to content

fix: enforce max_string_length on JSON escape/unicode appends - #24

Merged
ruoka merged 2 commits into
masterfrom
cursor/critical-bug-management-70af
Jul 27, 2026
Merged

fix: enforce max_string_length on JSON escape/unicode appends#24
ruoka merged 2 commits into
masterfrom
cursor/critical-bug-management-70af

Conversation

@cursor

@cursor cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

max_string_length (100MB DoS cap) was only checked on raw string/name characters. Escape sequences (\n, \", …) and \uXXXX UTF-8 writes appended unchecked, so escape-only payloads could grow the decoded string without bound.

Bug and impact

  • Trigger: JSON string/name composed mainly of escapes, e.g. repeated \n or \u0041, past 100MB decoded length.
  • Impact: DoS / unbounded memory growth; documented limit was not actually enforced on those paths.

Fix

  • Route all string appends (raw, escape, unicode, object names) through a shared length check.
  • Allow a custom limit on decoder for fast regressions.

Validation

  • Added StringLengthLimitAppliesToEscapes covering short escapes, BMP unicode, multi-byte UTF-8, and object names.
  • ./tools/CB.sh debug test --tags='\[xson\]' — 422/422 passed.
Open in Web View Automation 

cursoragent and others added 2 commits July 24, 2026 16:51
Escape and \uXXXX decode paths appended to the accumulating string
without checking max_string_length, so escape-only payloads could bypass
the 100MB DoS cap. Route all appends through a shared length check; add
a small-limit decoder regression covering escapes, unicode, and names.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
Escape and \uXXXX decode paths appended without checking max_string_length.
Route all appends through a shared length check that rejects when the next
append would exceed the remaining budget (no size_t underflow).

Co-authored-by: Cursor <cursoragent@cursor.com>
@ruoka
ruoka marked this pull request as ready for review July 27, 2026 14:55
@ruoka
ruoka merged commit 20c2e48 into master Jul 27, 2026
@ruoka
ruoka deleted the cursor/critical-bug-management-70af branch July 27, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants