fix(server): reject over-deep JSON request bodies before parsing - #747
Conversation
Strix found that _coerce_json had no nesting-depth cap: a payload well under max_body_bytes but deeply nested (JSON bomb) burns disproportionate CPU during json.loads. Reject nesting past MAX_JSON_NESTING_DEPTH with a cheap byte scan before parsing, closing the DoS path the fuzz target's RecursionError handling only papered over. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 3 minutes Limit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current headf2b993bfddbfd5cb82bf251065709dba596f90a6. -
Head SHA:
f2b993bfddbfd5cb82bf251065709dba596f90a6 -
Workflow run: 32189622069
-
Workflow attempt: 1
Coverage evidence
Coverage evidence job did not run or did not publish coverage evidence.
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file: server.py"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file: server.py"]
R1 --> V1["required checks"]
Evidence --> S2["Test: test_request_body_json_depth.py"]
S2 --> I2["regression suite"]
I2 --> R2["Review risk: Test: test_request_body_json_depth.py"]
R2 --> V2["targeted test run"]
OpenCode Review Overview
Pull request overviewOpenCode cannot approve yet because required coverage evidence did not pass. Review outcome1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
Coverage evidenceCoverage evidence job did not run or did not publish coverage evidence. Changed-File Evidence Mapflowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file: server.py"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file: server.py"]
R1 --> V1["required checks"]
Evidence --> S2["Test: test_request_body_json_depth.py"]
S2 --> I2["regression suite"]
I2 --> R2["Review risk: Test: test_request_body_json_depth.py"]
R2 --> V2["targeted test run"]
|
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current headf2b993bfddbfd5cb82bf251065709dba596f90a6. -
Head SHA:
f2b993bfddbfd5cb82bf251065709dba596f90a6 -
Workflow run: 32194255112
-
Workflow attempt: 1
Coverage evidence
Coverage evidence job did not run or did not publish coverage evidence.
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file: server.py"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file: server.py"]
R1 --> V1["required checks"]
Evidence --> S2["Test: test_request_body_json_depth.py"]
S2 --> I2["regression suite"]
I2 --> R2["Review risk: Test: test_request_body_json_depth.py"]
R2 --> V2["targeted test run"]
…-depth-guard-strix-20260818
Dismissing: mechanical 'coverage-evidence result was failure' rejection (root cause: atheris==3.0.0 has no Python 3.14 wheel, breaking the central coverage-sandbox build for every PR org-wide regardless of diff; real fix in #752, merging shortly). Not a content objection to this PR.
Summary
_coerce_jsonparses request bodies withjson.loadswith no nesting-depth cap, so a deeply nested payload well undermax_body_bytescan still burn disproportionate CPU/stack during parsing (JSON bomb DoS)._reject_excessive_json_nesting: a cheap, stdlib-only byte scan (skips over string contents correctly) that rejects nesting pastMAX_JSON_NESTING_DEPTH(32) beforejson.loadsever runs.fuzz/targets.py::exercise_request_bodyalready treatedRecursionErroras an expected/benign outcome of deep nesting; this fix removes that failure mode entirely by rejecting it earlier with a properRequestError.Test plan
python tests/test_request_body_json_depth.pypython -m pytest tests/test_request_body_json_depth.py -qpython -m pytest tests/fuzz -qpython -m pytest tests -q --ignore=tests/fuzz(296 passed)