This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new c84a8424 fix: Apply flatcc's verifier overflow guard fix
(CVE-2026-116734) (#1025)
c84a8424 is described below
commit c84a84247a82636d81eb47e04d15cf90362214f9
Author: Jacob Ablowitz <[email protected]>
AuthorDate: Thu Nov 19 07:40:57 2026 -0700
fix: Apply flatcc's verifier overflow guard fix (CVE-2026-116734) (#1025)
Closes #1024.
Applies
[dvidelabs/flatcc@0df9c097](https://github.com/dvidelabs/flatcc/commit/0df9c097a19badc8bd22d93af8fd47bd291e5d9f)
to the vendored `check_header()` in
`thirdparty/flatcc/src/runtime/verifier.c`. The old guard was
`uoffset_size <= voffset_size && k + offset_size < k`. With flatcc's
default offset sizes the first condition is false, so the wrap check
never ran.
`offset_size` is a `sizeof`, so `k + offset_size` only wraps where
`size_t` is 32 bits (i386, wasm32). There, a root offset of `0xFFFFFFFC`
passes `check_header()`, and the verifier then reads the vtable offset
from the 4 bytes before the flatbuffer. On 64-bit platforms the sum
doesn't wrap and the existing bounds check rejects the offset.
This cherry-picks only that one line, so the next revendor will carry
the same code. The vendored copy differs from flatcc `master` in other
places, and flatcc has no release containing this fix yet, so I've left
a full revendor out of this PR. Happy to do that instead if you prefer.
Testing:
- New test `NanoarrowIpcVerifyRootOffsetOverflow`. It checks the error
message because, without the fix, this particular message is still
rejected on 32-bit, only later and for a different reason (`vtable
offset out of range or unaligned`). On 64-bit it passes with or without
the fix.
- i386 (Debian 12, GCC, `RelWithDebInfo`): the new test fails without
the fix and passes with it, and `nanoarrow_ipc_decoder_test` passes.
- arm64 Linux (Ubuntu 24.04, GCC, Debug with ASan): all 432 `ctest`
tests pass.
The change, the test and this description were prepared with Claude
Code. I reviewed them and can answer for them.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Jacob Ablowitz
<[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
src/nanoarrow/ipc/decoder_test.cc | 20 ++++++++++++++++++++
thirdparty/flatcc/src/runtime/verifier.c | 2 +-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/nanoarrow/ipc/decoder_test.cc
b/src/nanoarrow/ipc/decoder_test.cc
index 3c18746c..0eded0ed 100644
--- a/src/nanoarrow/ipc/decoder_test.cc
+++ b/src/nanoarrow/ipc/decoder_test.cc
@@ -1395,6 +1395,26 @@ TEST(NanoarrowIpcTest, NanoarrowIpcFooterSizeOverflow) {
EXPECT_EQ(ArrowIpcDecoderDecodeFooter(decoder.get(), data, &error), ESPIPE);
}
+TEST(NanoarrowIpcTest, NanoarrowIpcVerifyRootOffsetOverflow) {
+ struct ArrowError error;
+
+ nanoarrow::ipc::UniqueDecoder decoder;
+ ArrowIpcDecoderInit(decoder.get());
+
+ // A message whose flatbuffer root offset is 0xFFFFFFFC: where size_t is 32
bits,
+ // adding the size of the offset wraps to zero, which must not pass the
bounds check
+ alignas(8) const uint8_t message[] = {0xFF, 0xFF, 0xFF, 0xFF, 8, 0, 0, 0,
+ 0xFC, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0};
+ struct ArrowBufferView data;
+ data.data.as_uint8 = message;
+ data.size_bytes = sizeof(message);
+
+ EXPECT_EQ(ArrowIpcDecoderVerifyHeader(decoder.get(), data, &error), EINVAL);
+ EXPECT_STREQ(error.message,
+ "Message flatbuffer verification failed (15) table header out
of range "
+ "or unaligned");
+}
+
TEST(NanoarrowIpcTest, NanoarrowIpcFooterMissingSchema) {
struct ArrowError error;
diff --git a/thirdparty/flatcc/src/runtime/verifier.c
b/thirdparty/flatcc/src/runtime/verifier.c
index d92b2b2d..1df77598 100644
--- a/thirdparty/flatcc/src/runtime/verifier.c
+++ b/thirdparty/flatcc/src/runtime/verifier.c
@@ -127,7 +127,7 @@ static inline int check_header(uoffset_t end, uoffset_t
base, uoffset_t offset)
{
uoffset_t k = base + offset;
- if (uoffset_size <= voffset_size && k + offset_size < k) {
+ if (k + offset_size < k) {
return 0;
}