Skip to content

fix(server): bound Claude Desktop apply bodies - #1272

Draft
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/fix-claude-apply-body-bound
Draft

fix(server): bound Claude Desktop apply bodies#1272
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/fix-claude-apply-body-bound

Conversation

@luvs01

@luvs01 luvs01 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route POST /api/claude-desktop/apply through the shared 4 MiB management JSON reader instead of unbounded req.text();
  • enforce both raw wire-byte and decompressed-byte limits before JSON parsing;
  • preserve the existing empty-body behavior with an explicit optional-body fallback;
  • validate JSON, mode, and profile before writing the Claude Desktop desired state;
  • add regressions for malformed input, invalid mode/profile, compressed oversize, missing Content-Length, and no-mutation failures.

Why

The Claude Desktop apply route was the remaining management endpoint that parsed its body with req.text(). A compressed or chunked request could bypass the management-body contract, and invalid input could set the persistent desired state to ON before the route returned 400.

The route now shares the same bounded decode and 413 mapping used by other management endpoints. Invalid input is rejected before any desired-state or profile write.

Behavior and bounds

  • An honest over-limit Content-Length is rejected before reading the body.
  • Missing, malformed, or dishonest declarations are checked immediately after the platform body read; raw compressed bytes and decompressed bytes must each fit the caller's limit before parse.
  • The Fetch arrayBuffer() API still materializes a body with no trustworthy length before the post-read raw-byte check. This change bounds admission, decompression, parsing, and retention; it does not replace the platform read with a streaming transport.
  • Empty or whitespace-only bodies still mean the existing default apply request.
  • Malformed JSON and unsupported encodings retain the management-plane 400 behavior; raw/decompressed size overflow uses the existing 413 response.
  • No authentication, credential, or successful apply response contract changes.

Verification

  • Bun 1.3.14: tests/request-decompress.test.ts 26/26 passed.
  • Bun 1.4.0-canary.1 (b22e0e6d0): the same suite 26/26 passed.
  • Bun 1.3.14: tests/claude-management-api.test.ts -t "Claude Desktop apply" 4/4 passed.
  • Bun 1.4.0-canary.1 (b22e0e6d0): the same focused apply set 4/4 passed.
  • bun x tsc --noEmit: passed.
  • bun scripts/privacy-scan.ts: passed.
  • git diff --check: passed.
  • Windows full suite: attempted, not passed and not counted as verification. The Bun 1.3.14 --isolate run hit an EBUSY storage-fixture cleanup, an unrelated management-auth 401 cascade, and then Bun's Internal assertion failure. This matches the repository's documented dispatch-only Windows/storage-runtime class in Windows test suite remains dispatch-only until full suite is green #1059; no storage, auth-admission, or Worker-lifecycle file is changed here.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes are not required because no user-facing configuration or successful response contract changes.
  • Focused security review covered wire/decompressed bounds, empty-body compatibility, error mapping, mutation ordering, secrets, and unsafe defaults.
  • Upstream CI and explicit maintainer security review remain pending.

Draft pending upstream CI and the repository-required maintainer security review for management-boundary changes.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8fb7ed1b-2f95-48dc-a762-78b98265de3d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ All CI tests are green on my local testing.
  • ⬜ I pushed my PR to the latest dev commit.
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant