Repository navigation
RabbitMQ related fix - #112479
RabbitMQ related fix#112479
Conversation
`CREATE TABLE ... ENGINE = RabbitMQ` connects to the broker synchronously, so the whole AMQP handshake runs while the statement is being executed. A broker can answer the handshake with a `Connection.Tune` frame proposing a maximum frame size of zero, which in AMQP means "no limit". `AMQP-CPP` stored that verbatim and uses the maximum frame size both as the capacity of its receive buffer and as the bound that incoming frames are validated against, so zero disabled the bound while the buffer stayed at its initial 4096 bytes. The broker could then announce a frame with a payload of up to `0xFFFFFFFF` bytes and have the client read that many bytes into the 4096-byte allocation - a heap out-of-bounds write with remotely controlled length and content. The fix is in the `contrib/AMQP-CPP` submodule: the negotiated maximum frame size is never allowed below the protocol minimum, an oversized frame is rejected even when the negotiated maximum is zero, and the receive buffer now clamps every read to the memory it has actually allocated. `remote_host_filter` is applied to `rabbitmq_address` as well. It used to be checked only for `rabbitmq_host_port`, so an authenticated user could reach a host outside the allowlist just by spelling the same address in the URI form. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Workflow [PR], commit [77938e1] Summary: ❌
AI ReviewSummaryThis PR hardens the PR Metadata
Findings❌ Blockers
Tests
Final VerdictChanges requested: narrow the LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 37/43 (86.05%) · Uncovered code |
…ress `RabbitMQConnection::connectImpl` connects to `rabbitmq_address` (the URI form) whenever it is set, in preference to `rabbitmq_host_port`, and `connection_string` is always filled from `rabbitmq_address`. The constructor, however, validated `rabbitmq_host_port` first and only checked `rabbitmq_address` in the `else` branch, so a user could pair an allowed `rabbitmq_host_port` with a disallowed `rabbitmq_address` (both settings are accepted together) and still connect to the unvalidated host, bypassing `remote_url_allow_hosts`. Validate against `remote_host_filter` by keying off the same condition `connectImpl` uses: check `rabbitmq_address` whenever it is set, falling back to `rabbitmq_host_port` only when there is no address. `connection_string` now reuses the exact validated string. Regression test: an allowed `rabbitmq_host_port` plus a disallowed `rabbitmq_address` is now rejected with `UNACCEPTABLE_URL`. #112479 (comment) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Follow-ups from review of the RabbitMQ malicious-broker fix: * Bump contrib/AMQP-CPP to aba8fac: clamp the negotiated max frame size from above (a peer proposing frame_max close to 2^32-1 could otherwise make us allocate multiple gigabytes for the receive buffer), and stop TcpInBuffer from recording capacity for a buffer that malloc failed to allocate. * Initialize OpenSSL when the connection is TLS because `rabbitmq_address` uses the `amqps` scheme, not only when the `rabbitmq_secure` setting is set. * Strengthen the frame_max=0 test to assert that the library logs the `frame size exceeded` protocol error, a deterministic proof that the guard fired rather than the server merely surviving the overflow by luck on a non-sanitizer build. * Add an `amqps` variant of the malicious-broker test that drives the same overflow through the previously unclamped TLS receive path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
| .secure = (*rabbitmq_settings)[RabbitMQSetting::rabbitmq_secure].value, | ||
| .connection_string = getContext()->getMacros()->expand((*rabbitmq_settings)[RabbitMQSetting::rabbitmq_address]) | ||
| .connection_string = address_string | ||
| }; |
There was a problem hiding this comment.
rabbitmq_secure = 1 is still ignored when rabbitmq_address is set. configuration.secure only reaches AMQP::Address(host, port, ..., secure) in the host/port branch; once connection_string is non-empty, RabbitMQConnection::connectImpl reparses the URI and drops this flag entirely (src/Storages/RabbitMQ/RabbitMQConnection.cpp:94-104). The public docs still say "Use either rabbitmq_secure = 1 or amqps" (docs/en/engines/table-engines/integrations/rabbitmq.md:85), so rabbitmq_address = 'amqp://...' plus rabbitmq_secure = 1 silently stays plaintext.
Please either reject that combination up front, or apply the secure flag when constructing the URI-form AMQP::Address, and add a regression test for the rabbitmq_address + rabbitmq_secure path.
For the `rabbitmq_address` form, `RabbitMQConnection::connectImpl` takes the transport from the URI scheme and never applies `configuration.secure`, so `rabbitmq_address = 'amqp://...'` together with `rabbitmq_secure = 1` silently connected in cleartext despite the user asking for TLS - a silent security downgrade. Reject that contradiction with `BAD_ARGUMENTS` instead of downgrading (rather than trying to "upgrade" the URI, which is ambiguous: `amqp://host` with no port would connect TLS to the plaintext default port 5672). TLS with the address form must be expressed with an `amqps://` scheme. Add a regression test and clarify the docs: `rabbitmq_secure` applies to the `rabbitmq_host_port` form; the address form selects the transport via its scheme. #112479 (comment) Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 24/32 (75.00%) · Uncovered code |
…max-oob # Conflicts: # docs/en/engines/table-engines/integrations/rabbitmq.md
|
|
||
| Required parameters: | ||
|
|
||
| - `rabbitmq_host_port` – host:port (for example, `localhost:5672`). |
There was a problem hiding this comment.
As I understand, rabbitmq_address now becomes an equivalent alternative to rabbitmq_host_port, so it needs to be dragged up here, and we need to state that one of each / or both allowed
The `SSL connection` section of `rabbitmq.mdx` sits inside the `AUTOGENERATED` region of the generated documentation tree, so the edit does not belong in this pull request. Co-Authored-By: Claude Opus 5 <[email protected]>
This reverts commit cedef57.
… truth - The autogenerated rabbitmq.mdx was edited during conflict resolution while its source of truth, the documentation block in StorageRabbitMQ.cpp, still described the old TLS contract. Update the embedded documentation so regeneration is idempotent and the Mintlify docs check passes, and apply the suggested wording for the `rabbitmq_address` description (URI form, precedence over `rabbitmq_host_port`, remote_url_allow_hosts check) and the SSL connection paragraph. #112479 (comment) #112479 (comment) #112479 (comment) - The amqps regression only proved the server survived. Now it records the count of `frame size exceeded` log lines before connecting and requires the count to grow, proving the frame-size guard fired on the TLS receive path as well. Counting (not substring presence) because the plaintext test already logs the same line into the shared log. #112479 (comment) - The malicious broker now parses the client's Connection.TuneOk reply and logs the negotiated frame_max, and the tests assert it against the expected clamp: a frame_max=0 proposal must be answered with 4096 (checked on both the plaintext and TLS paths), and a new test with a broker proposing 2^32-1 checks the reply is capped at 128 MiB. The TuneOk reply is what bounds the receive buffer, so echoing a hostile proposal back would let the broker announce frames of arbitrary size. #112479 (comment) Co-Authored-By: Claude Fable 5 <[email protected]>
… fix-amqp-cpp-frame-max-oob
The edited sections of rabbitmq.mdx sit inside the AUTOGENERATED region of the generated documentation tree, which the Mintlify docs check rejects when edited manually. The wording changes stay in the documentation block of StorageRabbitMQ.cpp, the source of truth from which the page is regenerated. Co-Authored-By: Claude Fable 5 <[email protected]>
…allocated Address review: with the initial 4 KiB TcpInBuffer allocation failed, both receivefrom overloads computed a zero read size but still formed `_data + _size` from a null buffer and passed it to read/SSL_read. Short-circuit before forming the pointer and report the receive failure explicitly (errno = ENOMEM, negative result). #112479 (comment) Co-Authored-By: Claude Fable 5 <[email protected]>
`conn.recv(65536)` is not frame-aware: on TCP/TLS it can return any positive prefix of `Connection.StartOk`. When it returned only a prefix, the following `recv_exactly(7)` for `Connection.TuneOk` started in the middle of `StartOk`, the stream desynced, and the `client_frame_max` assertion became flaky. Factor a `read_frame` helper (7-byte header + payload + end octet, all via `recv_exactly`) and use it for both `StartOk` and `TuneOk` so the broker always consumes exactly one whole frame and stays aligned. Verified with a fragmented-`StartOk` client harness: the old broker fails to parse the subsequent `TuneOk`, the new one parses it correctly. #112479 (comment) Co-Authored-By: Claude Opus 4.8 <[email protected]>
The `rabbitmq_secure = 1` vs plaintext `amqp://` `rabbitmq_address` contradiction is rejected only for a fresh CREATE (`mode <= LoadingStrictnessLevel::CREATE`), so an existing table that used this (previously accepted, silently plaintext) combination still attaches after an upgrade instead of failing to load. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`configuration.secure` was taken straight from the `rabbitmq_secure` setting, so it disagreed with reality when `rabbitmq_secure = 0` but the `rabbitmq_address` URI used the `amqps` scheme. Use `secure_connection`, which reflects the actual transport (setting for the host/port form, URI scheme for the address form). No behavioural change today - `connectImpl` derives the transport from the URI for the address form and this field is only read on the host/port form, where `secure_connection` equals the setting - but it keeps the field truthful. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes5 object files changed (+19.66 KiB total), 0 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units29 translation units recompiled, 78 s compile time in total, 27 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.63 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
|
Backport #112479 to 26.7: RabbitMQ related fix
Backport #112479 to 26.6: RabbitMQ related fix
Cherry pick #112479 to 26.3: RabbitMQ related fix
Backport #112479 to 26.3: RabbitMQ related fix
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
RabbitMQ Security related bugfix.
Version info
26.8.1.1209(included in26.8and later)26.7.4.26,26.6.3.31,26.3.33.12