Sfoglia il codice sorgente

build: vendor curl 8.23.0, and pin the padded-literal premise to a live test

The advisory set was judged item by item once the embargo lifted, and the
severity column pointed away from what matters here. The only HIGH,
CVE-2026-92392, is a use-after-free in HTTP/2 upload handling and is
unreachable for two independent reasons visible in runner/CMakeLists.txt:
CURL_DISABLE_HTTP and USE_NGHTTP2 OFF. The one that does reach us is rated
Low - CVE-2026-92387 names the ping-pong protocols, so it covers exactly the
imap/imaps/smtp/smtps we keep, and it bypasses CURLOPT_TIMEOUT_MS, which is
how MailBudget::totalMs is enforced.

What this run verifies is COMPATIBILITY, not the fix. 448 of 448 runner
tests pass against the vendored 8.23.0, including every live-curl behaviour
the IMAP parsers rest on; curl still reports Protocols: imap imaps smtp
smtps with no HTTP, so the disable list still means what it meant; and ldd
shows the same shared libraries, so the hand-written control.runner Depends
needs nothing added. The stall test still reports curl's own timeout
("bounded after 1501 ms as mail_timeout"), i.e. the healthy path, exactly as
on 8.22.0 - so nothing here measures that the vulnerability is gone, and the
bump is taken on the advisory's word plus the unreachability of its
precondition over loopback.

The padded-literal premise had no live test and now has one. That libcurl
reports CURLE_OK for a server announcing {n} larger than the body it sends -
counting the response's own framing toward n - was measured once on 8.22.0
and recorded in a comment, and a comment cannot notice when curl changes:
had 8.23.0 started refusing the miscount, literalEndsWithFraming would have
become dead code with nothing to say so. The fake server can now overstate,
and the test asserts both halves, curl succeeding and the detector firing on
the bytes curl actually delivered, with the honest response as the control.
Falsified both ways: a detector that never fires and one that always fires
each turn it red. It passes against the vendored 8.23.0 and against the dev
host's system 8.22.0.

No --rebuild-base: curl is vendored at build time rather than baked into the
Docker base image the way DB_CLIENT_VERSION is, so only the runner binary
changes. VERSION is deliberately untouched - this gets its own number and
its own window rather than riding into a payload consumers cleared on the
strength of two unrelated defect fixes.
fszontagh 1 mese fa
parent
commit
c032dd5d8c

File diff suppressed because it is too large
+ 2 - 3
CLAUDE.md


+ 25 - 3
runner/CMakeLists.txt

@@ -83,13 +83,35 @@ FetchContent_MakeAvailable(quickjs)
 #   3. The reachable protocol set is exactly: imaps, imap, smtps, smtp. An
 #      advisory in any other protocol is not our exposure.
 #
-# curl-8_22_0 was released 2 Sep 2026; the next release is due 14 Oct 2026.
-# curl's git tags are underscored, which is why this does not read 8.22.0.
+# curl-8_23_0 was released 14 Oct 2026 and carries 22 advisories.
+# curl's git tags are underscored, which is why this does not read 8.23.0.
+#
+# WHY THIS BUMP WAS TAKEN, AND WHY IT WAS NOT AN EMERGENCY. The one rated HIGH,
+# CVE-2026-92392, is a use-after-free in HTTP/2 UPLOAD handling, and we cannot
+# reach it for two independent reasons visible in this very file:
+# CURL_DISABLE_HTTP and USE_NGHTTP2 OFF. There is no HTTP in this curl at all,
+# let alone HTTP/2. So the severity column pointed away from the thing that
+# actually matters here, which is the whole reason obligation 2 above is worded
+# the way it is.
+#
+# The one that DOES reach us is rated Low: CVE-2026-92387 names the "ping-pong"
+# protocols - FTP, IMAP, POP3 and SMTP - so it covers exactly the two we keep.
+# A server that keeps feeding data at the client's read speed while permanently
+# omitting the final control-response line sends libcurl into a loop whose exit
+# condition can never be met, BYPASSING CURLOPT_TIMEOUT_MS. That option is how
+# MailBudget::totalMs is enforced (net/mail_session.cpp), and because a blocking
+# host call cannot be interrupted the QuickJS wall budget cannot rescue the run
+# either - so the unbounded call would hold its lease on a runtime the whole
+# pool shares. MailStall.AServerThatNeverCompletesACommandIsStillBounded does
+# NOT prove we were safe before this bump: it is bounded by curl's own timeout,
+# i.e. by the option the flaw defeats, so it reached the healthy path rather
+# than the flawed loop. A bounded pass was equally consistent with "immune" and
+# "not reproduced", which is why the fix was taken rather than argued away.
 #
 # SFTP is deliberately NOT in the surface, which is what keeps this to ONE
 # vendored upstream: SFTP would require libssh2 as well, and libssh2 is far
 # less watched than curl while having had remotely reachable issues.
-set(SVAPI_CURL_TAG "curl-8_22_0" CACHE STRING "curl git tag to vendor")
+set(SVAPI_CURL_TAG "curl-8_23_0" CACHE STRING "curl git tag to vendor")
 option(SVAPI_VENDOR_CURL "Vendor libcurl rather than linking the system one" ON)
 
 if(SVAPI_VENDOR_CURL)

+ 6 - 1
runner/src/net/imap_fetch.hpp

@@ -390,7 +390,12 @@ const ImapFetchRecord* findByUid(const std::vector<ImapFetchRecord>& messages, u
 /// libcurl count the trailing protocol text toward N, so the literal libcurl
 /// delivers is padded with the response's own framing. curl reports success:
 /// measured against 8.22.0, an announce of 50 for a 40-byte body yielded
-/// `CURLE_OK` and a 50-byte literal whose tail was `)<CRLF>A003 OK`.
+/// `CURLE_OK` and a 50-byte literal whose tail was `)<CRLF>A003 OK`. Re-measured
+/// against 8.23.0 when the pin moved, and now pinned by a live test rather
+/// than by this comment: `ImapFixture.AnOverstatedLiteralIsDELIVEREDasSuccess
+/// AndCaughtOnlyByItsCONTENT` drives a real curl against a server that
+/// overstates, so if a later curl ever starts refusing the miscount this
+/// function becomes dead code and the suite says so instead of staying green.
 ///
 /// It cannot be caught structurally. curl consumes the real `)` and the tagged
 /// line in the HEALTHY case too, so a padded response and a correct one are

+ 11 - 1
runner/tests/fake_mail_server.hpp

@@ -156,6 +156,15 @@ class FakeImapServer : public FakeLineServer {
 public:
     /// What a UID FETCH returns as the message body.
     std::string messageBody = "From: a@example.com\r\nSubject: hello\r\n\r\nbody text\r\n";
+    /// Announce `{n}` this many bytes LARGER than the body actually sent, to
+    /// model the server that corrupts silently: libcurl counts the response's
+    /// own framing toward the announced count and reports SUCCESS, so the
+    /// literal it delivers is padded with `)<CRLF>A<digits> OK`. This is the
+    /// only way to exercise `literalEndsWithFraming` against real curl rather
+    /// than against a hand-written buffer, which matters on every pin bump -
+    /// if curl ever started refusing the miscount, the detector would be dead
+    /// code and nothing else would say so.
+    size_t literalOverstateBytes = 0;
     /// Untagged lines emitted on SELECT/EXAMINE. These exist so a test can
     /// observe WHERE they end up: whether curl hands a custom request's caller
     /// the SELECT chatter as well as the command's own response.
@@ -185,7 +194,8 @@ protected:
             // The response to a BODY.PEEK[] fetch comes back labelled BODY[],
             // without the .PEEK. A parser that looks for the string it sent
             // will not find it, which is a real and easily missed trap.
-            std::string out = "* 1 FETCH (UID 7 BODY[] {" + std::to_string(messageBody.size()) +
+            std::string out = "* 1 FETCH (UID 7 BODY[] {" +
+                              std::to_string(messageBody.size() + literalOverstateBytes) +
                               "}\r\n" + messageBody + ")\r\n";
             return out + tag + " OK fetched\r\n";
         }

+ 76 - 0
runner/tests/mail_session_test.cpp

@@ -7,6 +7,7 @@
 #include <thread>
 
 #include "fake_mail_server.hpp"
+#include "net/imap_fetch.hpp"
 #include "net/mail_session.hpp"
 
 using namespace svapi::runner::net;
@@ -129,6 +130,81 @@ TEST_F(ImapFixture, CurlConsumesTheClosingParenAndTheTaggedCompletionLine) {
     mailGlobalCleanup();
 }
 
+TEST_F(ImapFixture, AnOverstatedLiteralIsDELIVEREDasSuccessAndCaughtOnlyByItsCONTENT) {
+    // The premise the whole padded-literal defence rests on, pinned against
+    // REAL curl rather than a hand-written buffer.
+    //
+    // A server announcing `{n}` larger than the body it sends is not refused by
+    // libcurl: curl counts the response's own framing toward n and reports
+    // CURLE_OK, so the literal handed to the write callback is the body plus
+    // `)<CRLF>` plus the first bytes of the tagged completion. There is no
+    // structural signal - curl strips the real framing in the healthy case too,
+    // so this response and a correct one are byte-for-byte the same SHAPE. Only
+    // the CONTENT differs, which is why `literalEndsWithFraming` exists.
+    //
+    // This is a PIN-BUMP test. It was measured once on 8.22.0 and recorded in a
+    // comment, and a comment cannot notice when curl changes: were a later curl
+    // to start rejecting the miscount, the detector would become dead code and
+    // nothing in the suite would say so. If this test ever fails because the
+    // command itself failed, that is the news - read it as "curl now catches
+    // this", not as a broken test.
+    ASSERT_EQ(mailGlobalInit(), std::string());
+    server.messageBody = "0123456789";       // 10 bytes
+    server.literalOverstateBytes = 10;       // ... announced as 20
+    ImapSession session;
+    ASSERT_TRUE(session.open(accountFor(server.port()), optionsFor()).ok());
+
+    std::string response;
+    const MailFailure f = session.command("INBOX", "UID FETCH 7 BODY.PEEK[]", response);
+
+    // Half one: curl did NOT notice. Stated as its own assertion because it is
+    // the surprising half and the reason the content check has to exist.
+    ASSERT_TRUE(f.ok()) << "curl refused the overstated literal itself (" << f.slug << ": "
+                        << f.message << ") - if that is now curl's behaviour, "
+                        << "literalEndsWithFraming has become dead code and this test should say "
+                        << "so rather than be deleted";
+    // Exactly 20 bytes of "literal", the last ten of them protocol text. The
+    // header is asserted whole and the tail by SHAPE, because the tag is
+    // curl's own and its NUMBER depends on how many commands preceded this one
+    // on the session - pinning "A003" would make the test fail if a login or a
+    // SELECT were ever added ahead of it, which is not what it is testing.
+    const std::string header = "* 1 FETCH (UID 7 BODY[] {20}\r\n";
+    ASSERT_EQ(response.rfind(header, 0), 0u) << "unexpected response: " << response;
+    const std::string literal = response.substr(header.size());
+    EXPECT_EQ(literal.size(), 20u) << "curl delivered a different count than it was announced";
+    EXPECT_EQ(literal.rfind("0123456789)\r\nA", 0), 0u)
+        << "the padding was not the response's own framing: " << literal;
+    EXPECT_NE(literal.find(" OK"), std::string::npos) << literal;
+
+    // Half two: the detector fires on what curl ACTUALLY delivered. The two
+    // parses mirror `parseCurlFetch` in host_context.cpp - the direct parse is
+    // short of its own announced count, and the framed re-parse is what reaches
+    // the content check.
+    const ImapFetchResult direct = parseFetchResponse(response);
+    EXPECT_NE(direct.status, ImapParse::Ok) << "the direct parse should still be short";
+    const ImapFetchResult framed = parseFetchResponse(response + ")\r\n");
+    ASSERT_EQ(framed.status, ImapParse::Ok);
+    ASSERT_EQ(framed.messages.size(), 1u);
+    ASSERT_FALSE(framed.messages.front().bodyParts.empty());
+    EXPECT_TRUE(literalEndsWithFraming(framed.messages.front().bodyParts.begin()->second))
+        << "curl's padding was not recognised as framing, so a function would have received "
+           "protocol text welded to the end of a message body";
+
+    // The CONTROL, and it is what makes the assertion above mean anything: the
+    // same server without the overstatement delivers a literal the detector
+    // does NOT flag. Without this, the test would pass just as well against a
+    // detector that flagged everything.
+    server.literalOverstateBytes = 0;
+    std::string honest;
+    ASSERT_TRUE(session.command("INBOX", "UID FETCH 7 BODY.PEEK[]", honest).ok());
+    const ImapFetchResult good = parseFetchResponse(honest + ")\r\n");
+    ASSERT_EQ(good.status, ImapParse::Ok);
+    ASSERT_FALSE(good.messages.front().bodyParts.empty());
+    EXPECT_FALSE(literalEndsWithFraming(good.messages.front().bodyParts.begin()->second))
+        << "a correct response was flagged as padded, which would refuse every good fetch";
+    mailGlobalCleanup();
+}
+
 TEST_F(ImapFixture, TheSessionReusesOneConnectionForSeveralCommands) {
     // One handle per (run, account): a fresh handle per command would mean a
     // TCP connect, a TLS handshake and a LOGIN every time, which is both slow

Some files were not shown because too many files changed in this diff