thrift: fix CVE-2026-41608
PATCH 1/4 thrift: fix CVE-2026-41608
Backport patch to fix CVE-2026-41608.
References:
https://nvd.nist.gov/vuln/detail/CVE-2026-41608
Upstream fix:
https://github.com/apache/thrift/commit/8c605880ea4ef050a689c859de3b702ad8d4ce7b
--- .../thrift/thrift/CVE-2026-41608.patch | 176 ++++++++++++++++++ .../thrift/thrift_0.22.0.bb | 1 + 2 files changed, 177 insertions(+) create mode 100644 meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-41608.patch
meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-41608.patch new file +176 -0
@@ -0,0 +1,176 @@ +From d6ef4cd811666ce8c72dd5417d95debce52f490b Mon Sep 17 00:00:00 2001 +From: Jens Geyer <[email protected]> +Date: Sun, 19 Apr 2026 10:10:35 +0200 +Subject: [PATCH] Add decompressed payload size limit to Python + THeaderTransport Client: py + +Adds _max_decompressed_size (default: HARD_MAX_FRAME_SIZE) and +set_max_decompressed_size() to THeaderTransport. ZLIB decompression +now uses decompressobj with a size cap instead of unbounded +zlib.decompress(), consistent with the C++ implementation. + +Refactor THeaderTransport read-transform dispatch into _apply_read_transform + +Co-Authored-By: Claude Sonnet 4.6 <[email protected]> + +CVE: CVE-2026-41608 +Upstream-Status: Backport [https://github.com/apache/thrift/commit/8c605880ea4ef050a689c859de3b702ad8d4ce7b] + +Signed-off-by: Adarsh Jagadish Kamini <[email protected]> +--- + lib/py/src/transport/THeaderTransport.py | 26 +++++++--- + lib/py/test/thrift_transport.py | 65 ++++++++++++++++++++++++ + 2 files changed, 85 insertions(+), 6 deletions(-) + +diff --git a/lib/py/src/transport/THeaderTransport.py b/lib/py/src/transport/THeaderTransport.py +index 4fb203430..51bc43cf7 100644 +--- a/lib/py/src/transport/THeaderTransport.py ++++ b/lib/py/src/transport/THeaderTransport.py +@@ -60,9 +60,7 @@ class THeaderTransformID(object): + ZLIB = 0x01 + + +-READ_TRANSFORMS_BY_ID = { +- THeaderTransformID.ZLIB: zlib.decompress, +-} ++KNOWN_READ_TRANSFORM_IDS = frozenset({THeaderTransformID.ZLIB}) + + + WRITE_TRANSFORMS_BY_ID = { +@@ -102,6 +100,7 @@ class THeaderTransport(TTransportBase, CReadableTransport): + self.sequence_id = 0 + self._protocol_id = default_protocol + self._max_frame_size = HARD_MAX_FRAME_SIZE ++ self._max_decompressed_size = HARD_MAX_FRAME_SIZE + + def isOpen(self): + return self._transport.isOpen() +@@ -135,6 +134,22 @@ class THeaderTransport(TTransportBase, CReadableTransport): + raise ValueError("maximum frame size should be < %d and > 0" % HARD_MAX_FRAME_SIZE) + self._max_frame_size = size + ++ def set_max_decompressed_size(self, size): ++ if not 0 < size <= HARD_MAX_FRAME_SIZE: ++ raise ValueError("maximum decompressed size should be <= %d and > 0" % HARD_MAX_FRAME_SIZE) ++ self._max_decompressed_size = size ++ ++ def _apply_read_transform(self, transform_id, payload): ++ if transform_id == THeaderTransformID.ZLIB: ++ decompressor = zlib.decompressobj() ++ payload = decompressor.decompress(payload, self._max_decompressed_size) ++ if decompressor.unconsumed_tail: ++ raise TTransportException( ++ TTransportException.SIZE_LIMIT, ++ "Decompressed payload exceeds maximum allowed size.", ++ ) ++ return payload ++ + @property + def protocol_id(self): + if self._client_type == THeaderClientType.HEADERS: +@@ -250,7 +265,7 @@ class THeaderTransport(TTransportBase, CReadableTransport): + transform_count = readVarint(buffer_transport) + for _ in range(transform_count): + transform_id = readVarint(buffer_transport) +- if transform_id not in READ_TRANSFORMS_BY_ID: ++ if transform_id not in KNOWN_READ_TRANSFORM_IDS: + raise TApplicationException( + TApplicationException.INVALID_TRANSFORM, + "Unknown transform: %d" % transform_id, +@@ -276,8 +291,7 @@ class THeaderTransport(TTransportBase, CReadableTransport): + + payload = buffer.read() + for transform_id in transforms: +- transform_fn = READ_TRANSFORMS_BY_ID[transform_id] +- payload = transform_fn(payload) ++ payload = self._apply_read_transform(transform_id, payload) + return BytesIO(payload) + + def write(self, buf): +diff --git a/lib/py/test/thrift_transport.py b/lib/py/test/thrift_transport.py +index cb1bb0ce7..cb0d815cb 100644 +--- a/lib/py/test/thrift_transport.py ++++ b/lib/py/test/thrift_transport.py +@@ -17,11 +17,17 @@ + # under the License. + # + ++import struct + import unittest ++import zlib + import os + + import _import_local_thrift # noqa + from thrift.transport import TTransport ++from thrift.transport.THeaderTransport import ( ++ THeaderTransport, THeaderClientType, THeaderTransformID, HEADER_MAGIC, ++) ++from thrift.transport.TTransport import TTransportException + + + class TestTFileObjectTransport(unittest.TestCase): +@@ -66,5 +72,64 @@ class TestMemoryBuffer(unittest.TestCase): + buffer_r.close() + + ++def _craft_zlib_header_frame(plain_payload): ++ """Return a complete THeaderTransport frame with a ZLIB-compressed payload.""" ++ compressed = zlib.compress(plain_payload) ++ # proto_id=0, 1 transform; values <128 encode as single varint bytes ++ hdr_content = bytes([0, 1, THeaderTransformID.ZLIB]) ++ padding = (4 - len(hdr_content) % 4) % 4 ++ hdr_bytes = hdr_content + b'\x00' * padding ++ header_len_u16 = len(hdr_bytes) // 4 ++ # 10 fixed bytes: 2(magic)+2(flags)+4(seqid)+2(hdr_len_u16) ++ frame_size = 10 + len(hdr_bytes) + len(compressed) ++ frame = struct.pack('!i', frame_size) ++ frame += struct.pack('!H', HEADER_MAGIC) ++ frame += struct.pack('!H', 0) # flags ++ frame += struct.pack('!i', 0) # sequence_id ++ frame += struct.pack('!H', header_len_u16) ++ frame += hdr_bytes ++ frame += compressed ++ return frame ++ ++ ++class TestTHeaderTransportDecompressionLimit(unittest.TestCase): ++ ++ def _make_transport(self, payload, max_decompressed_size=None): ++ frame = _craft_zlib_header_frame(payload) ++ inner = TTransport.TMemoryBuffer(frame) ++ transport = THeaderTransport(inner, [THeaderClientType.HEADERS]) ++ if max_decompressed_size is not None: ++ transport.set_max_decompressed_size(max_decompressed_size) ++ return transport ++ ++ def test_zlib_roundtrip(self): ++ payload = b'Hello Thrift! ' * 100 ++ t = self._make_transport(payload) ++ t.readFrame(1) ++ self.assertEqual(t._read_buffer.read(), payload) ++ ++ def test_decompression_bomb_blocked(self): ++ # 10,000 bytes decompressed; limit set to 1,000 ++ payload = b'A' * 10000 ++ t = self._make_transport(payload, max_decompressed_size=1000) ++ with self.assertRaises(TTransportException) as ctx: ++ t.readFrame(1) ++ self.assertEqual(ctx.exception.type, TTransportException.SIZE_LIMIT) ++ ++ def test_payload_at_limit_passes(self): ++ payload = b'B' * 5000 ++ t = self._make_transport(payload, max_decompressed_size=5000) ++ t.readFrame(1) ++ self.assertEqual(t._read_buffer.read(), payload) ++ ++ def test_set_max_decompressed_size_rejects_invalid(self): ++ inner = TTransport.TMemoryBuffer(b'') ++ t = THeaderTransport(inner, [THeaderClientType.HEADERS]) ++ with self.assertRaises(ValueError): ++ t.set_max_decompressed_size(0) ++ with self.assertRaises(ValueError): ++ t.set_max_decompressed_size(-1) ++ ++ + if __name__ == '__main__': + unittest.main()
meta-oe/recipes-connectivity/thrift/thrift_0.22.0.bb +1 -0
@@ -17,6 +17,7 @@ SRC_URI = "https://downloads.apache.org/${BPN}/${PV}/${BP}.tar.gz \ file://CVE-2026-58023.patch \ file://CVE-2026-48144.patch \ file://CVE-2026-58389.patch \ + file://CVE-2026-41608.patch \ " SRC_URI[sha256sum] = "794a0e455787960d9f27ab92c38e34da27e8deeda7a5db0e59dc64a00df8a1e5"
PATCH 2/4 thrift: fix CVE-2026-45112
Backport patch to fix CVE-2026-45112.
References:
https://nvd.nist.gov/vuln/detail/CVE-2026-45112
Upstream fix:
https://github.com/apache/thrift/commit/16b3673827498d1f4b05f8026d5d580b8e8f5aa2
--- .../thrift/thrift/CVE-2026-45112.patch | 306 ++++++++++++++++++ .../thrift/thrift_0.22.0.bb | 1 + 2 files changed, 307 insertions(+) create mode 100644 meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-45112.patch
meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-45112.patch new file +306 -0
@@ -0,0 +1,306 @@ +From 4d68f215f05905a19dd43865fb97d170b4fc1a3b Mon Sep 17 00:00:00 2001 +From: Jens Geyer <[email protected]> +Date: Fri, 8 May 2026 21:24:30 +0200 +Subject: [PATCH] Add message byte tracking to consumeBuffer() in Java + transports Client: java + +- consumeBuffer() in TMemoryInputTransport and AutoExpandingBufferReadTransport + now decrements remainingMessageSize inline so fast-path buffer reads are + counted toward the per-message size limit +- AutoExpandingBufferReadTransport.fill() resets remainingMessageSize at the + start of each frame, matching TMemoryInputTransport.reset() behavior in + TFramedTransport +- TBinaryProtocol.readString() now checks stringLengthLimit before the + fast-path branch +- Add TestMessageSizeLimits covering all fixed code paths + +Co-Authored-By: Claude Sonnet 4.6 <[email protected]> + +CVE: CVE-2026-45112 +Upstream-Status: Backport [https://github.com/apache/thrift/commit/16b3673827498d1f4b05f8026d5d580b8e8f5aa2] + +Signed-off-by: Adarsh Jagadish Kamini <[email protected]> +--- + .../thrift/protocol/TBinaryProtocol.java | 6 +- + .../AutoExpandingBufferReadTransport.java | 6 + + .../transport/TMemoryInputTransport.java | 7 +- + .../protocol/TestMessageSizeLimits.java | 196 ++++++++++++++++++ + 4 files changed, 213 insertions(+), 2 deletions(-) + create mode 100644 lib/java/src/test/java/org/apache/thrift/protocol/TestMessageSizeLimits.java + +diff --git a/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java b/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java +index 99c3e9302..49e82ee8a 100644 +--- a/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java ++++ b/lib/java/src/main/java/org/apache/thrift/protocol/TBinaryProtocol.java +@@ -458,6 +458,8 @@ public class TBinaryProtocol extends TProtocol { + public String readString() throws TException { + int size = readI32(); + ++ checkStringReadLength(size); ++ + if (trans_.getBytesRemainingInBuffer() >= size) { + String s = + new String(trans_.getBuffer(), trans_.getBufferPosition(), size, StandardCharsets.UTF_8); +@@ -465,7 +467,9 @@ public class TBinaryProtocol extends TProtocol { + return s; + } + +- return readStringBody(size); ++ byte[] buf = new byte[size]; ++ trans_.readAll(buf, 0, size); ++ return new String(buf, StandardCharsets.UTF_8); + } + + public String readStringBody(int size) throws TException { +diff --git a/lib/java/src/main/java/org/apache/thrift/transport/AutoExpandingBufferReadTransport.java b/lib/java/src/main/java/org/apache/thrift/transport/AutoExpandingBufferReadTransport.java +index d59c657db..53b35c207 100644 +--- a/lib/java/src/main/java/org/apache/thrift/transport/AutoExpandingBufferReadTransport.java ++++ b/lib/java/src/main/java/org/apache/thrift/transport/AutoExpandingBufferReadTransport.java +@@ -39,6 +39,7 @@ public class AutoExpandingBufferReadTransport extends TEndpointTransport { + inTrans.readAll(buf.array(), 0, length); + pos = 0; + limit = length; ++ resetConsumedMessageSize(-1); + } + + @Override +@@ -70,6 +71,11 @@ public class AutoExpandingBufferReadTransport extends TEndpointTransport { + @Override + public final void consumeBuffer(int len) { + pos += len; ++ if (remainingMessageSize >= len) { ++ remainingMessageSize -= len; ++ } else { ++ remainingMessageSize = 0; ++ } + } + + @Override +diff --git a/lib/java/src/main/java/org/apache/thrift/transport/TMemoryInputTransport.java b/lib/java/src/main/java/org/apache/thrift/transport/TMemoryInputTransport.java +index 375e2b72a..2fff0dacc 100644 +--- a/lib/java/src/main/java/org/apache/thrift/transport/TMemoryInputTransport.java ++++ b/lib/java/src/main/java/org/apache/thrift/transport/TMemoryInputTransport.java +@@ -96,7 +96,6 @@ public final class TMemoryInputTransport extends TEndpointTransport { + if (amtToRead > 0) { + System.arraycopy(buf_, pos_, buf, off, amtToRead); + consumeBuffer(amtToRead); +- countConsumedMessageBytes(amtToRead); + } + return amtToRead; + } +@@ -119,7 +118,13 @@ public final class TMemoryInputTransport extends TEndpointTransport { + return endPos_ - pos_; + } + ++ @Override + public void consumeBuffer(int len) { + pos_ += len; ++ if (remainingMessageSize >= len) { ++ remainingMessageSize -= len; ++ } else { ++ remainingMessageSize = 0; ++ } + } + } +diff --git a/lib/java/src/test/java/org/apache/thrift/protocol/TestMessageSizeLimits.java b/lib/java/src/test/java/org/apache/thrift/protocol/TestMessageSizeLimits.java +new file mode 100644 +index 000000000..ab12a0f70 +--- /dev/null ++++ b/lib/java/src/test/java/org/apache/thrift/protocol/TestMessageSizeLimits.java +@@ -0,0 +1,196 @@ ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, ++ * software distributed under the License is distributed on an ++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ++ * KIND, either express or implied. See the License for the ++ * specific language governing permissions and limitations ++ * under the License. ++ */ ++package org.apache.thrift.protocol; ++ ++import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; ++import static org.junit.jupiter.api.Assertions.assertThrows; ++ ++import java.util.Arrays; ++import org.apache.thrift.TConfiguration; ++import org.apache.thrift.transport.AutoExpandingBufferReadTransport; ++import org.apache.thrift.transport.TMemoryInputTransport; ++import org.apache.thrift.transport.TTransportException; ++import org.junit.jupiter.api.Test; ++ ++/** ++ * Tests that message size limits are enforced in the fast-path buffer reads of ++ * TBinaryProtocol/TCompactProtocol and that consumeBuffer() correctly tracks consumed bytes. ++ */ ++public class TestMessageSizeLimits { ++ ++ /** Build TBinaryProtocol-encoded bytes for a string: 4-byte big-endian length + raw bytes. */ ++ private byte[] encodeBinaryString(String s) { ++ byte[] data = s.getBytes(java.nio.charset.StandardCharsets.UTF_8); ++ byte[] out = new byte[4 + data.length]; ++ int len = data.length; ++ out[0] = (byte) (len >> 24); ++ out[1] = (byte) (len >> 16); ++ out[2] = (byte) (len >> 8); ++ out[3] = (byte) len; ++ System.arraycopy(data, 0, out, 4, data.length); ++ return out; ++ } ++ ++ /** ++ * Build TCompactProtocol-encoded bytes for a string: varint length + raw bytes. Assumes length < ++ * 128 so it fits in one varint byte. ++ */ ++ private byte[] encodeCompactString(String s) { ++ byte[] data = s.getBytes(java.nio.charset.StandardCharsets.UTF_8); ++ assert data.length < 128 : "test helper only handles single-byte varints"; ++ byte[] out = new byte[1 + data.length]; ++ out[0] = (byte) data.length; ++ System.arraycopy(data, 0, out, 1, data.length); ++ return out; ++ } ++ ++ private static String repeat(char c, int n) { ++ char[] chars = new char[n]; ++ Arrays.fill(chars, c); ++ return new String(chars); ++ } ++ ++ @Test ++ public void testBinaryProtocol_stringLengthLimitEnforcedInFastPath() throws Exception { ++ // 100-char string encoded for TBinaryProtocol - all bytes in transport so fast path fires ++ byte[] buf = encodeBinaryString(repeat('A', 100)); ++ TMemoryInputTransport transport = new TMemoryInputTransport(buf); ++ ++ // Protocol limited to 10 bytes per string ++ TBinaryProtocol proto = new TBinaryProtocol(transport, 10L, -1L, false, true); ++ ++ assertThrows( ++ TProtocolException.class, ++ proto::readString, ++ "stringLengthLimit must be enforced even when the fast path is taken"); ++ } ++ ++ @Test ++ public void testBinaryProtocol_stringLengthLimitAllowsValidString() throws Exception { ++ byte[] buf = encodeBinaryString("Hello"); ++ TMemoryInputTransport transport = new TMemoryInputTransport(buf); ++ ++ TBinaryProtocol proto = new TBinaryProtocol(transport, 10L, -1L, false, true); ++ ++ assertDoesNotThrow( ++ proto::readString, "string within stringLengthLimit must be readable via fast path"); ++ } ++ ++ @Test ++ public void testCompactProtocol_stringLengthLimitEnforcedInFastPath() throws Exception { ++ byte[] buf = encodeCompactString(repeat('A', 100)); ++ TMemoryInputTransport transport = new TMemoryInputTransport(buf); ++ ++ TCompactProtocol proto = new TCompactProtocol(transport, 10L, -1L); ++ ++ assertThrows( ++ TProtocolException.class, ++ proto::readString, ++ "TCompactProtocol stringLengthLimit must reject oversized strings in fast path"); ++ } ++ ++ @Test ++ public void testConsumeBuffer_decrementsRemainingMessageSize() throws Exception { ++ // 20-byte transport; updateKnownMessageSize sets remainingMessageSize = 20 ++ byte[] buf = new byte[20]; ++ TMemoryInputTransport transport = new TMemoryInputTransport(buf); ++ ++ transport.consumeBuffer(15); ++ ++ // 5 bytes remain; requesting 5 must succeed ++ assertDoesNotThrow(() -> transport.checkReadBytesAvailable(5)); ++ ++ // requesting 6 must fail ++ assertThrows( ++ TTransportException.class, ++ () -> transport.checkReadBytesAvailable(6), ++ "checkReadBytesAvailable must reflect bytes consumed via consumeBuffer"); ++ } ++ ++ @Test ++ public void testBinaryProtocol_fastPathReadsDrainRemainingMessageSize() throws Exception { ++ // 10 i32 values = 40 bytes; maxMessageSize exactly 40 ++ byte[] buf = new byte[40]; ++ TConfiguration config = TConfiguration.custom().setMaxMessageSize(40).build(); ++ TMemoryInputTransport transport = new TMemoryInputTransport(config, buf); ++ TBinaryProtocol proto = new TBinaryProtocol(transport); ++ ++ // Reading 8 i32 values via fast path consumes 32 bytes ++ for (int i = 0; i < 8; i++) { ++ proto.readI32(); ++ } ++ ++ // 8 bytes remain — requesting exactly 8 must succeed ++ assertDoesNotThrow( ++ () -> transport.checkReadBytesAvailable(8), ++ "8 bytes should still be available after 32 consumed via fast path"); ++ ++ // requesting 9 must fail — size limit is properly tracked ++ assertThrows( ++ TTransportException.class, ++ () -> transport.checkReadBytesAvailable(9), ++ "fast-path reads must decrement remaining message size so limits can be enforced"); ++ } ++ ++ @Test ++ public void testRead_doesNotDoubleCountConsumedBytes() throws Exception { ++ // If read() double-counted, consuming 10 bytes via read() on a 20-byte transport ++ // would wrongly decrement remainingMessageSize by 20 instead of 10. ++ byte[] buf = new byte[20]; ++ TMemoryInputTransport transport = new TMemoryInputTransport(buf); ++ byte[] dest = new byte[10]; ++ transport.read(dest, 0, 10); ++ ++ // 10 bytes remain; requesting 10 must succeed ++ assertDoesNotThrow(() -> transport.checkReadBytesAvailable(10)); ++ ++ // requesting 11 must fail ++ assertThrows( ++ TTransportException.class, ++ () -> transport.checkReadBytesAvailable(11), ++ "read() must not double-count consumed bytes after consumeBuffer fix"); ++ } ++ ++ @Test ++ public void testAutoExpandingBufferReadTransport_fillResetsMessageSizePerFrame() ++ throws Exception { ++ // fill() must reset remainingMessageSize so that consumption across frames on a long-lived ++ // TFastFramedTransport connection does not accumulate toward the per-message limit. ++ TConfiguration config = TConfiguration.custom().setMaxMessageSize(80).build(); ++ AutoExpandingBufferReadTransport readBuf = new AutoExpandingBufferReadTransport(config, 100); ++ TMemoryInputTransport source = new TMemoryInputTransport(new byte[200]); ++ ++ // Frame 1: fill and consume 70 bytes ++ readBuf.fill(source, 70); ++ readBuf.consumeBuffer(70); ++ ++ // Frame 2: fill resets remainingMessageSize to maxMessageSize (80) before new frame ++ readBuf.fill(source, 70); ++ readBuf.consumeBuffer(70); ++ ++ // After two frames of 70 bytes each, 10 bytes of budget must still be available ++ assertDoesNotThrow( ++ () -> readBuf.checkReadBytesAvailable(10), ++ "fill() must reset remainingMessageSize so multi-frame connections stay functional"); ++ assertThrows( ++ TTransportException.class, ++ () -> readBuf.checkReadBytesAvailable(11), ++ "remaining budget after fill-reset and 70-byte consume should be exactly 10"); ++ } ++}
meta-oe/recipes-connectivity/thrift/thrift_0.22.0.bb +1 -0
@@ -18,6 +18,7 @@ SRC_URI = "https://downloads.apache.org/${BPN}/${PV}/${BP}.tar.gz \ file://CVE-2026-48144.patch \ file://CVE-2026-58389.patch \ file://CVE-2026-41608.patch \ + file://CVE-2026-45112.patch \ " SRC_URI[sha256sum] = "794a0e455787960d9f27ab92c38e34da27e8deeda7a5db0e59dc64a00df8a1e5"
PATCH 3/4 thrift: fix CVE-2026-55969
In reply to Adarsh Jagadish KaminiBackport patch to fix CVE-2026-55969.
References:
https://nvd.nist.gov/vuln/detail/CVE-2026-55969
Upstream fix:
https://github.com/apache/thrift/commit/983c813c9a1a2302d9a3ae23d7368beceaac2d0a
--- .../thrift/thrift/CVE-2026-55969.patch | 295 ++++++++++++++++++ .../thrift/thrift_0.22.0.bb | 1 + 2 files changed, 296 insertions(+) create mode 100644 meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-55969.patch
meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-55969.patch new file +295 -0
@@ -0,0 +1,295 @@ +From f288d1a7bdd994872d6ac1e7f2d7eb60b5beb1e5 Mon Sep 17 00:00:00 2001 +From: dxbjavid <[email protected]> +Date: Tue, 9 Jun 2026 16:35:58 +0530 +Subject: [PATCH] Widen multiplication operands in container size prechecks to + prevent arithmetic overflow on LLP64 platforms Client: cpp,c_glib Patch: + Javid Khan + +This closes #3590 + +Backport note: in thrift_binary_protocol.c the 0.22.0 tree lacks the +container_limit property infrastructure present upstream (unrelated to this +CVE), so only the intended change was applied: widening the sizei/msize +multiplication operands to gint64 in the checkReadBytesAvailable calls. + +Assisted-by: kiro:claude-sonnet-5 + +CVE: CVE-2026-55969 +Upstream-Status: Backport [https://github.com/apache/thrift/commit/983c813c9a1a2302d9a3ae23d7368beceaac2d0a] + +Signed-off-by: Adarsh Jagadish Kamini <[email protected]> +--- + .../c_glib/protocol/thrift_binary_protocol.c | 6 +-- + .../c_glib/protocol/thrift_compact_protocol.c | 10 ++-- + .../c_glib/transport/thrift_transport.c | 2 +- + .../c_glib/transport/thrift_transport.h | 2 +- + lib/cpp/src/thrift/protocol/TBinaryProtocol.h | 6 +-- + .../src/thrift/protocol/TCompactProtocol.h | 6 +-- + lib/cpp/src/thrift/protocol/TJSONProtocol.h | 6 +-- + lib/cpp/src/thrift/protocol/TProtocol.h | 6 +-- + lib/cpp/src/thrift/transport/TTransport.h | 3 +- + lib/cpp/test/ThrifttReadCheckTests.cpp | 48 +++++++++++++++++++ + 10 files changed, 72 insertions(+), 23 deletions(-) + +diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c +index 9e80e107c..3bad603c3 100644 +--- a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c ++++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c +@@ -562,8 +562,8 @@ thrift_binary_protocol_read_map_begin (ThriftProtocol *protocol, + } + + if(!ttc->checkReadBytesAvailable (THRIFT_TRANSPORT(tp->transport), +- sizei * thrift_binary_protocol_get_min_serialized_size(protocol, k, error) + +- sizei * thrift_binary_protocol_get_min_serialized_size(protocol, v, error), ++ (gint64) sizei * thrift_binary_protocol_get_min_serialized_size(protocol, k, error) + ++ (gint64) sizei * thrift_binary_protocol_get_min_serialized_size(protocol, v, error), + error)) + { + return -1; +@@ -619,7 +619,7 @@ thrift_binary_protocol_read_list_begin (ThriftProtocol *protocol, + } + + if(!ttc->checkReadBytesAvailable (THRIFT_TRANSPORT(tp->transport), +- (sizei * thrift_binary_protocol_get_min_serialized_size(protocol, e, error)), ++ ((gint64) sizei * thrift_binary_protocol_get_min_serialized_size(protocol, e, error)), + error)) + { + return -1; +diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_compact_protocol.c b/lib/c_glib/src/thrift/c_glib/protocol/thrift_compact_protocol.c +index 0aa9a6fe6..f6ad36b36 100644 +--- a/lib/c_glib/src/thrift/c_glib/protocol/thrift_compact_protocol.c ++++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_compact_protocol.c +@@ -1108,9 +1108,9 @@ thrift_compact_protocol_read_map_begin (ThriftProtocol *protocol, + return -1; + } + +- if(!ttc->checkReadBytesAvailable (THRIFT_TRANSPORT (tp->transport), +- msize * thrift_protocol_get_min_serialized_size (protocol, *key_type, error) + +- msize * thrift_protocol_get_min_serialized_size (protocol, *value_type, error), ++ if(!ttc->checkReadBytesAvailable (THRIFT_TRANSPORT (tp->transport), ++ (gint64) msize * thrift_protocol_get_min_serialized_size (protocol, *key_type, error) + ++ (gint64) msize * thrift_protocol_get_min_serialized_size (protocol, *value_type, error), + error)) + { + return -1; +@@ -1183,8 +1183,8 @@ thrift_compact_protocol_read_list_begin (ThriftProtocol *protocol, + *element_type = ret; + *size = (guint32) lsize; + +- if(!ttc->checkReadBytesAvailable (THRIFT_TRANSPORT (tp->transport), +- (lsize * thrift_protocol_get_min_serialized_size (protocol, *element_type, error)), ++ if(!ttc->checkReadBytesAvailable (THRIFT_TRANSPORT (tp->transport), ++ ((gint64) lsize * thrift_protocol_get_min_serialized_size (protocol, *element_type, error)), + error)) + { + return -1; +diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c +index 9d3f25e75..7e18f712a 100644 +--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c ++++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c +@@ -160,7 +160,7 @@ thrift_transport_updateKnownMessageSize(ThriftTransport *transport, glong size, + } + + gboolean +-thrift_transport_checkReadBytesAvailable(ThriftTransport *transport, glong numBytes, GError **error) ++thrift_transport_checkReadBytesAvailable(ThriftTransport *transport, gint64 numBytes, GError **error) + { + gboolean boolean = TRUE; + ThriftTransport *tt = THRIFT_TRANSPORT (transport); +diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h b/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h +index 83fb5da19..01365ba7f 100644 +--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h ++++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h +@@ -83,7 +83,7 @@ struct _ThriftTransportClass + gint32 (*read_all) (ThriftTransport *transport, gpointer buf, + guint32 len, GError **error); + gboolean (*updateKnownMessageSize) (ThriftTransport *transport, glong size, GError **error); +- gboolean (*checkReadBytesAvailable) (ThriftTransport *transport, glong numBytes, GError **error); ++ gboolean (*checkReadBytesAvailable) (ThriftTransport *transport, gint64 numBytes, GError **error); + gboolean (*resetConsumedMessageSize) (ThriftTransport *transport, glong newSize, GError **error); + gboolean (*countConsumedMessageBytes) (ThriftTransport *transport, glong numBytes, GError **error); + }; +diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h +index cba6e6948..1a7410c86 100644 +--- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h ++++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h +@@ -174,18 +174,18 @@ public: + + void checkReadBytesAvailable(TSet& set) override + { +- trans_->checkReadBytesAvailable(set.size_ * getMinSerializedSize(set.elemType_)); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(set.size_) * getMinSerializedSize(set.elemType_)); + } + + void checkReadBytesAvailable(TList& list) override + { +- trans_->checkReadBytesAvailable(list.size_ * getMinSerializedSize(list.elemType_)); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(list.size_) * getMinSerializedSize(list.elemType_)); + } + + void checkReadBytesAvailable(TMap& map) override + { + int elmSize = getMinSerializedSize(map.keyType_) + getMinSerializedSize(map.valueType_); +- trans_->checkReadBytesAvailable(map.size_ * elmSize); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(map.size_) * elmSize); + } + + protected: +diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h +index c7d81eea6..97ca460a7 100644 +--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h ++++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h +@@ -146,18 +146,18 @@ public: + + void checkReadBytesAvailable(TSet& set) override + { +- trans_->checkReadBytesAvailable(set.size_ * getMinSerializedSize(set.elemType_)); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(set.size_) * getMinSerializedSize(set.elemType_)); + } + + void checkReadBytesAvailable(TList& list) override + { +- trans_->checkReadBytesAvailable(list.size_ * getMinSerializedSize(list.elemType_)); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(list.size_) * getMinSerializedSize(list.elemType_)); + } + + void checkReadBytesAvailable(TMap& map) override + { + int elmSize = getMinSerializedSize(map.keyType_) + getMinSerializedSize(map.valueType_); +- trans_->checkReadBytesAvailable(map.size_ * elmSize); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(map.size_) * elmSize); + } + + /** +diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h +index 09eb6eab1..265b33922 100644 +--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h ++++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h +@@ -253,18 +253,18 @@ public: + + void checkReadBytesAvailable(TSet& set) override + { +- trans_->checkReadBytesAvailable(set.size_ * getMinSerializedSize(set.elemType_)); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(set.size_) * getMinSerializedSize(set.elemType_)); + } + + void checkReadBytesAvailable(TList& list) override + { +- trans_->checkReadBytesAvailable(list.size_ * getMinSerializedSize(list.elemType_)); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(list.size_) * getMinSerializedSize(list.elemType_)); + } + + void checkReadBytesAvailable(TMap& map) override + { + int elmSize = getMinSerializedSize(map.keyType_) + getMinSerializedSize(map.valueType_); +- trans_->checkReadBytesAvailable(map.size_ * elmSize); ++ trans_->checkReadBytesAvailable(static_cast<int64_t>(map.size_) * elmSize); + } + + class LookaheadReader { +diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h +index 37b0db711..4eedc5e82 100644 +--- a/lib/cpp/src/thrift/protocol/TProtocol.h ++++ b/lib/cpp/src/thrift/protocol/TProtocol.h +@@ -604,18 +604,18 @@ protected: + + virtual void checkReadBytesAvailable(TSet& set) + { +- ptrans_->checkReadBytesAvailable(set.size_ * getMinSerializedSize(set.elemType_)); ++ ptrans_->checkReadBytesAvailable(static_cast<int64_t>(set.size_) * getMinSerializedSize(set.elemType_)); + } + + virtual void checkReadBytesAvailable(TList& list) + { +- ptrans_->checkReadBytesAvailable(list.size_ * getMinSerializedSize(list.elemType_)); ++ ptrans_->checkReadBytesAvailable(static_cast<int64_t>(list.size_) * getMinSerializedSize(list.elemType_)); + } + + virtual void checkReadBytesAvailable(TMap& map) + { + int elmSize = getMinSerializedSize(map.keyType_) + getMinSerializedSize(map.valueType_); +- ptrans_->checkReadBytesAvailable(map.size_ * elmSize); ++ ptrans_->checkReadBytesAvailable(static_cast<int64_t>(map.size_) * elmSize); + } + + std::shared_ptr<TTransport> ptrans_; +diff --git a/lib/cpp/src/thrift/transport/TTransport.h b/lib/cpp/src/thrift/transport/TTransport.h +index 52b3a0a4d..1269593ac 100644 +--- a/lib/cpp/src/thrift/transport/TTransport.h ++++ b/lib/cpp/src/thrift/transport/TTransport.h +@@ -23,6 +23,7 @@ + #include <thrift/Thrift.h> + #include <thrift/TConfiguration.h> + #include <thrift/transport/TTransportException.h> ++#include <cstdint> + #include <memory> + #include <string> + +@@ -272,7 +273,7 @@ public: + * + * @param numBytes numBytes bytes of data + */ +- void checkReadBytesAvailable(long int numBytes) ++ void checkReadBytesAvailable(int64_t numBytes) + { + if (remainingMessageSize_ < numBytes) + throw TTransportException(TTransportException::END_OF_FILE, "MaxMessageSize reached"); +diff --git a/lib/cpp/test/ThrifttReadCheckTests.cpp b/lib/cpp/test/ThrifttReadCheckTests.cpp +index 963286100..72e798bc1 100644 +--- a/lib/cpp/test/ThrifttReadCheckTests.cpp ++++ b/lib/cpp/test/ThrifttReadCheckTests.cpp +@@ -243,6 +243,54 @@ BOOST_AUTO_TEST_CASE(test_tthriftcompactprotocol_read_check_pass) { + BOOST_CHECK_NO_THROW(protocol->readString(eleven)); + } + ++BOOST_AUTO_TEST_CASE(test_tthriftbinaryprotocol_container_size_overflow) { ++ std::shared_ptr<TConfiguration> config (new TConfiguration(1024)); ++ std::shared_ptr<TMemoryBuffer> transport(new TMemoryBuffer(config)); ++ std::shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport)); ++ ++ uint32_t val = 0; ++ TType elemType = apache::thrift::protocol::T_STOP; ++ // 0x40000000 elements of min size 4 require 4 GiB; the product wraps to 0 in ++ // 32-bit math and used to slip past the MaxMessageSize check. ++ TList list(T_I32, 0x40000000); ++ protocol->writeListBegin(list.elemType_, list.size_); ++ protocol->writeListEnd(); ++ BOOST_CHECK_THROW(protocol->readListBegin(elemType, val), TTransportException); ++ protocol->readListEnd(); ++} ++ ++BOOST_AUTO_TEST_CASE(test_tthriftcompactprotocol_container_size_overflow) { ++ std::shared_ptr<TConfiguration> config (new TConfiguration(1024)); ++ std::shared_ptr<TMemoryBuffer> transport(new TMemoryBuffer(config)); ++ std::shared_ptr<TCompactProtocol> protocol(new TCompactProtocol(transport)); ++ ++ uint32_t val = 0; ++ TType elemType = apache::thrift::protocol::T_STOP; ++ // 0x10000000 elements of min size 16 (UUID) require 4 GiB; the product wraps ++ // to 0 in 32-bit math and used to slip past the MaxMessageSize check. ++ TList list(T_UUID, 0x10000000); ++ protocol->writeListBegin(list.elemType_, list.size_); ++ protocol->writeListEnd(); ++ BOOST_CHECK_THROW(protocol->readListBegin(elemType, val), TTransportException); ++ protocol->readListEnd(); ++} ++ ++BOOST_AUTO_TEST_CASE(test_tthriftjsonprotocol_container_size_overflow) { ++ std::shared_ptr<TConfiguration> config (new TConfiguration(1024)); ++ std::shared_ptr<TMemoryBuffer> transport(new TMemoryBuffer(config)); ++ std::shared_ptr<TJSONProtocol> protocol(new TJSONProtocol(transport)); ++ ++ uint32_t val = 0; ++ TType elemType = apache::thrift::protocol::T_STOP; ++ // 0x10000000 elements of min size 16 (UUID) require 4 GiB; the product wraps ++ // to 0 in 32-bit math and used to slip past the MaxMessageSize check. ++ TList list(T_UUID, 0x10000000); ++ protocol->writeListBegin(list.elemType_, list.size_); ++ protocol->writeListEnd(); ++ BOOST_CHECK_THROW(protocol->readListBegin(elemType, val), TTransportException); ++ protocol->readListEnd(); ++} ++ + BOOST_AUTO_TEST_CASE(test_tthriftjsonprotocol_read_check_exception) { + std::shared_ptr<TConfiguration> config (new TConfiguration(MAX_MESSAGE_SIZE)); + std::shared_ptr<TMemoryBuffer> transport(new TMemoryBuffer(config));
meta-oe/recipes-connectivity/thrift/thrift_0.22.0.bb +1 -0
@@ -19,6 +19,7 @@ SRC_URI = "https://downloads.apache.org/${BPN}/${PV}/${BP}.tar.gz \ file://CVE-2026-58389.patch \ file://CVE-2026-41608.patch \ file://CVE-2026-45112.patch \ + file://CVE-2026-55969.patch \ " SRC_URI[sha256sum] = "794a0e455787960d9f27ab92c38e34da27e8deeda7a5db0e59dc64a00df8a1e5"
PATCH 4/4 thrift: fix CVE-2026-55970
In reply to Adarsh Jagadish KaminiBackport patch to fix CVE-2026-55970.
References:
https://nvd.nist.gov/vuln/detail/CVE-2026-55970
Upstream fix:
https://github.com/apache/thrift/commit/4da36faeef0b7db4b1dea560b01eb15957335934
--- .../thrift/thrift/CVE-2026-55970.patch | 67 +++++++++++++++++++ .../thrift/thrift_0.22.0.bb | 1 + 2 files changed, 68 insertions(+) create mode 100644 meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-55970.patch
meta-oe/recipes-connectivity/thrift/thrift/CVE-2026-55970.patch new file +67 -0
@@ -0,0 +1,67 @@ +From 0fe80cef02c1d3260d3ce278f072ce7e04788c13 Mon Sep 17 00:00:00 2001 +From: dxbjavid <[email protected]> +Date: Sat, 13 Jun 2026 17:39:53 +0530 +Subject: [PATCH] fix off-by-ten header bounds check in readHeaderFormat + +Backport note: additive test conflict in ThrifttReadCheckTests.cpp; the 0.22.0 +tree already carries test_theadertransport_zlib_roundtrip from CVE-2026-55971, +so both tests were kept. + +Assisted-by: kiro:claude-sonnet-5 + +CVE: CVE-2026-55970 +Upstream-Status: Backport [https://github.com/apache/thrift/commit/4da36faeef0b7db4b1dea560b01eb15957335934] + +Signed-off-by: Adarsh Jagadish Kamini <[email protected]> +--- + .../src/thrift/transport/THeaderTransport.cpp | 5 ++++- + lib/cpp/test/ThrifttReadCheckTests.cpp | 22 +++++++++++++++++++ + 2 files changed, 26 insertions(+), 1 deletion(-) + +diff --git a/lib/cpp/src/thrift/transport/THeaderTransport.cpp b/lib/cpp/src/thrift/transport/THeaderTransport.cpp +index 117c8edd5..0711a547e 100644 +--- a/lib/cpp/src/thrift/transport/THeaderTransport.cpp ++++ b/lib/cpp/src/thrift/transport/THeaderTransport.cpp +@@ -206,7 +206,10 @@ void THeaderTransport::readHeaderFormat(uint16_t headerSize, uint32_t sz) { + } + headerSize *= 4; + const uint8_t* const headerBoundary = ptr + headerSize; +- if (headerSize > sz) { ++ // ptr already skips the 10-byte common header, so the header section has to ++ // fit in the remaining sz - 10 bytes; comparing against sz alone let the ++ // boundary sit up to 10 bytes past the receive buffer. ++ if (headerSize > sz - 10) { + throw TTransportException(TTransportException::CORRUPTED_DATA, + "Header size is larger than frame"); + } +diff --git a/lib/cpp/test/ThrifttReadCheckTests.cpp b/lib/cpp/test/ThrifttReadCheckTests.cpp +index 72e798bc1..4645a9e14 100644 +--- a/lib/cpp/test/ThrifttReadCheckTests.cpp ++++ b/lib/cpp/test/ThrifttReadCheckTests.cpp +@@ -341,4 +341,26 @@ BOOST_AUTO_TEST_CASE(test_theadertransport_zlib_roundtrip) { + BOOST_CHECK(out == payload); + } + ++BOOST_AUTO_TEST_CASE(test_theadertransport_header_size_exceeds_frame) { ++ using apache::thrift::transport::THeaderTransport; ++ // Header-format frame whose declared header size (3 * 4 = 12) leaves fewer ++ // than the 10 common-header bytes inside the 14-byte frame. The trailing ++ // varint bytes are all continuation bytes, so the reader used to run off the ++ // end of the receive buffer. ++ uint8_t frame[] = { ++ 0x00, 0x00, 0x00, 0x0E, // frame length = 14 ++ 0x0F, 0xFF, 0x00, 0x00, // header magic ++ 0x00, 0x00, 0x00, 0x00, // seqId ++ 0x00, 0x03, // header size field (3 -> 12 bytes) ++ 0x02, // protocol id varint ++ 0x00, // num transforms = 0 ++ 0x80, 0x80 // info-header varint, all continuation ++ }; ++ std::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer(frame, sizeof(frame))); ++ std::shared_ptr<THeaderTransport> trans(new THeaderTransport(buffer)); ++ ++ uint8_t out[1]; ++ BOOST_CHECK_THROW(trans->read(out, sizeof(out)), TTransportException); ++} ++ + BOOST_AUTO_TEST_SUITE_END()
meta-oe/recipes-connectivity/thrift/thrift_0.22.0.bb +1 -0
@@ -20,6 +20,7 @@ SRC_URI = "https://downloads.apache.org/${BPN}/${PV}/${BP}.tar.gz \ file://CVE-2026-41608.patch \ file://CVE-2026-45112.patch \ file://CVE-2026-55969.patch \ + file://CVE-2026-55970.patch \ " SRC_URI[sha256sum] = "794a0e455787960d9f27ab92c38e34da27e8deeda7a5db0e59dc64a00df8a1e5"