Skip to content

Bug: Heap-buffer-overflow in Q3DImporter::InternReadFile #6358

Closed

Description

@ahuo1

Environment

  • OS: Ubuntu 22.04
  • Compiler: clang 13.0.1
  • C++ Standard: C++17
  • Sanitizers: AddressSanitizer (ASan) + UndefinedBehaviorSanitizer (UBSan)
  • Assimp Version: 6.0.2 / master commit 0581ed5

Build Instructions

export CC=clang-13
export CXX=clang++-13
export CFLAGS="${CFLAGS} -fsanitize=address -O1 -g"
export CXXFLAGS="${CXXFLAGS} -fsanitize=address -O1 -g"
export LDFLAGS="${LDFLAGS} -fsanitize=address"

export LIB_FUZZING_ENGINE="-fsanitize=fuzzer"

cmake CMakeLists.txt -G "Ninja" -DBUILD_SHARED_LIBS=OFF -DASSIMP_BUILD_ZLIB=ON \
                                -DASSIMP_BUILD_TESTS=ON -DASSIMP_BUILD_ASSIMP_TOOLS=OFF \
                                -DASSIMP_BUILD_SAMPLES=OFF
cmake --build .

$CXX $CXXFLAGS $LIB_FUZZING_ENGINE -std=c++11 -I./include \
        fuzz/assimp_fuzzer.cc -o ./assimp_fuzzer  \
        ./lib/libassimp.a ./contrib/zlib/libzlibstatic.a

Reproduction

Run the fuzzer with a crafted input file:

./assimp_fuzzer poc

Observed Behavior

Program crashes with ASan/UBSan report:

==2126824==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000b2 at pc 0x000001487021 bp 0x7ffdccf5fcf0 sp 0x7ffdccf5fce8
WRITE of size 1 at 0x6020000000b2 thread T0
[Detaching after fork from child process 2126877]
    #0 0x1487020 in Assimp::Q3DImporter::InternReadFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, aiScene*, Assimp::IOSystem*) /root/assimp/code/AssetLib/Q3D/Q3DLoader.cpp:317:30
    #1 0x957941 in Assimp::BaseImporter::ReadFile(Assimp::Importer*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Assimp::IOSystem*) /root/assimp/code/Common/BaseImporter.cpp:131:9
    #2 0x522c01 in Assimp::Importer::ReadFile(char const*, unsigned int) /root/assimp/code/Common/Importer.cpp:709:30
    #3 0x52082b in Assimp::Importer::ReadFileFromMemory(void const*, unsigned long, unsigned int, char const*) /root/assimp/code/Common/Importer.cpp:507:9
    #4 0x51c8ba in LLVMFuzzerTestOneInput /root/assimp/fuzz/assimp_fuzzer.cc:57:34
    #5 0x4506f3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/assimp_fuzzer+0x4506f3)
    #6 0x43953f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/assimp_fuzzer+0x43953f)
    #7 0x43f7c0 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/assimp_fuzzer+0x43f7c0)
    ...

Root Cause Analysis

The crash occurs in Q3DImporter::InternReadFile() while allocating texture data:

unsigned int mul = tex->mWidth * tex->mHeight;
aiTexel *begin = tex->pcData = new aiTexel[mul];
aiTexel *const end = &begin[mul - 1] + 1;
for (; begin != end; ++begin) {
begin->r = stream.GetI1();
begin->g = stream.GetI1();
begin->b = stream.GetI1();
begin->a = 0xff;
}

When the file provides extremely large mWidth and mHeight, their product overflows the unsigned int range, causing mul to wrap around to a small number (observed as 0 during GDB debugging). Immediately afterward, the code calculates end = &begin[mul - 1] + 1, which underflows mul - 1 and creates an invalid pointer far beyond the allocated buffer. The subsequent loop then writes out of bounds, triggering a heap-buffer-overflow. Proper bounds checking and using 64-bit arithmetic before multiplication would prevent this vulnerability.

During debugging with GDB, we confirmed:

(gdb) p tex->mWidth
$1 = 17432576
(gdb) p tex->mHeight
$2 = 171704320
(gdb) p mul
$3 = 0

This confirms that the multiplication overflowed, leading directly to the invalid memory access.

The attached file contains a proof-of-concept.
poc.zip

Activity

  1. added
    Bug
    on Sep 19, 2025
  2. added
    Fuzzer
    Sanitizer
    on Sep 28, 2025
  3. carnil commented on Oct 5, 2025

    @carnil

    CVE-2025-11277 seems to have been assigned for this issue.

  4. added
    Security Risk
    on Oct 6, 2025
  5. added a commit that references this issue on Oct 14, 2025
    70d22f1
  6. added a commit that references this issue on Nov 4, 2025
    0978918
  7. added 2 commits that reference this issue on Dec 1, 2025
    2b21ddd
    ac0cfc8
  8. added 2 commits that reference this issue on Jul 1, 2026
    fef291c
    1e9bf1f
  9. added 2 commits that reference this issue on Jul 28, 2026
    6831489
    337bbf5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFuzzerSanitizerSecurity Risk

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions