🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Honor unlimited negotiated frame_max when capping inbound message size (backport #2015) - #2016

Merged
acogoluegnes merged 2 commits into
v5.xfrom
mergify/bp/v5.x/pr-2015
Jul 8, 2026
Merged

Honor unlimited negotiated frame_max when capping inbound message size (backport #2015)#2016
acogoluegnes merged 2 commits into
v5.xfrom
mergify/bp/v5.x/pr-2015

Conversation

@mergify

@mergify mergify Bot commented Jul 8, 2026

Copy link
Copy Markdown

This is an automatic backport of pull request #2015 done by [Mergify](https://mergify.com).

AMQConnection derived the inbound frame payload limit with
Math.min(maxInboundMessageBodySize, frameMax), but a negotiated
frame_max of 0 means "no limit" (see negotiatedMaxValue and
AMQCommand#transmit), not a literal zero. Math.min silently turned
that into a limit of 0, which Utils.framePayloadLimit then treated
as "no limit" again, so the configured message body cap was
discarded in favor of an effectively unbounded frame size.

A frame_max of 0 is reachable via the client's own default
(requestedFrameMax is 0 unless overridden) whenever the broker also
negotiates 0, so maxInboundMessageBodySize could end up unenforced
without any non-default client configuration.

Add Utils.inboundFrameMax to compute the effective limit correctly,
with a UtilsTest covering the arithmetic directly and two
InboundFrameMax cases exercising it end to end against a fake broker
that negotiates frame_max=0.

(cherry picked from commit 6d7c2bf)
connection.tune's frame_max is parsed via a signed 32-bit read, so a
broker can send a value with the high bit set and have it come back
negative once negotiated. Unlike negotiatedChannelMax and
negotiatedHeartbeat, the negotiated frameMax was never validated
afterwards.

A negative frameMax reaching Utils.inboundFrameMax defeats the
Math.min against maxInboundMessageBodySize, since the negative value
is always the smaller one, then trips the same "frame_max <= 0 means
no limit" fallback in Utils.framePayloadLimit that frame_max=0
relies on for its legitimate meaning, reintroducing the size-cap
bypass without a broker ever needing to negotiate a literal 0.

A non-default, positive requestedFrameMax is also enough to reach
this on its own, with an otherwise honest broker, since
negotiatedMaxValue only launders a negative value back to 0 when one
side's value is exactly 0.

Reject the negotiated frame max outright when negative, the same way
the sibling channel max and heartbeat checks already do.

(cherry picked from commit 89ed7ea)
@acogoluegnes acogoluegnes added this to the 5.34.0 milestone Jul 8, 2026
@acogoluegnes
acogoluegnes merged commit 4aee133 into v5.x Jul 8, 2026
4 checks passed
@acogoluegnes
acogoluegnes deleted the mergify/bp/v5.x/pr-2015 branch July 8, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant