From 67eebc686a4e3c4c885d08e92ec1a7411cf07da2 Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Wed, 10 Jun 2026 17:14:46 +0700 Subject: [PATCH] fix: cap webhook delivery response buffer at 1MB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RPCCall::fromNetwork hardcoded a 256MB read budget for responses with no Content-Length. Webhook deliveries (method "event") ignore the response body, but each in-flight delivery still pre-allocated a ~256MB streambuf on the EOF path — up to 32 (maxInFlight) x 256MB = 8GB transient, on exactly the no-Content-Length error shape this branch targets. Cap the "event" method at 1MB; genuine RPC replies (CLI) keep the 256MB budget. --- src/xrpld/net/detail/RPCCall.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/xrpld/net/detail/RPCCall.cpp b/src/xrpld/net/detail/RPCCall.cpp index 1c6d9404e..123a8208b 100644 --- a/src/xrpld/net/detail/RPCCall.cpp +++ b/src/xrpld/net/detail/RPCCall.cpp @@ -1883,9 +1883,14 @@ fromNetwork( // Send request - // Number of bytes to try to receive if no - // Content-Length header received - constexpr auto RPC_REPLY_MAX_BYTES = megabytes(256); + // Number of bytes to try to receive if no Content-Length header is + // received. Webhook event deliveries ("event") ignore the response + // body, so a missing Content-Length must not pre-allocate the full + // 256MB RPC reply budget per in-flight delivery (maxInFlight can be + // 32 -> 8GB). Cap those small; genuine RPC replies (CLI) keep the + // large budget. + auto const RPC_REPLY_MAX_BYTES = + (strMethod == "event") ? megabytes(1) : megabytes(256); using namespace std::chrono_literals; // auto constexpr RPC_NOTIFY = 10min; // Wietse: lolwut 10 minutes for one