Skip to content

fix(rmqctl): reject studio responses that exceed the size cap - #5145

Open
89799969 wants to merge 1 commit into
apache:masterfrom
89799969:fix/rmqctl-studio-response-size-cap
Open

89799969 wants to merge 1 commit into
apache:masterfrom
89799969:fix/rmqctl-studio-response-size-cap

Conversation

@89799969

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

Client.request in rmqctl/internal/studio/client.go read the Studio API response body with an unbounded io.ReadAll. Every Studio response is a small JSON envelope, so nothing justified buffering an arbitrary stream before validation.

  • Add a 64 MiB cap (maxResponseBytes) and read through io.LimitReader.
  • Fail with a clear studio response exceeds N bytes error once the cap is exceeded.
  • Keep the limit on Client so tests can inject a small value without changing production defaults.

How Did You Test This Change?

cd rmqctl && go test ./internal/studio -count=1 -v

All existing studio tests plus the new cases pass:

  • TestReadBounded — accepts a body at the limit, rejects one byte over
  • TestRequestRejectsOversizedStudioResponse — Client.request returns the size-cap error
  • TestRequestAcceptsNormalStudioEnvelope — normal small envelopes still decode

Checklist

  • One coherent change; unrelated modifications are not bundled in
  • Commit subject follows Conventional Commits (feat: / fix: / refactor: / chore: / docs: / perf:)
  • Tests added or updated for non-trivial changes, test methods named ...Test
  • New UI text has both Chinese and English entries under web/src/i18n/ (N/A — CLI only)
  • Architecture constraints stay green (mvn test runs the ArchUnit checks) (N/A — Go-only change; no Java)
  • New source files carry the ASF license header (no new source files)
  • Documentation touched where behaviour changed (README / docs/ / in-app help) (N/A — internal client bound)

Client.request buffered Studio API bodies with an unbounded io.ReadAll. A misbehaving or compromised endpoint could exhaust the CLI before JSON validation ran. Cap the accepted body at 64 MiB and fail with a clear error once the limit is exceeded.

Fixes apache#4640
@89799969

89799969 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Keep-alive: rebased state unchanged and the fix is still current against master. Ready for review when a maintainer has time.

1 similar comment
@89799969

Copy link
Copy Markdown
Contributor Author

Keep-alive: rebased state unchanged and the fix is still current against master. Ready for review when a maintainer has time.

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.

[Bug] rmqctl Studio client buffers response bodies without a size cap

1 participant