Repository navigation
Labels
BugGlobal flag to mark a deviation from expected behaviourFuzzerBugs found by a fuzzerSanitizerBug/build issue discovered using sanitizer e.g. ASANSecurity RiskBugs that could potentially be security vulnerabilities
Description
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:
assimp/code/AssetLib/Q3D/Q3DLoader.cpp
Lines 312 to 321 in 0581ed5
| 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
Metadata
Metadata
Assignees
Labels
BugGlobal flag to mark a deviation from expected behaviourFuzzerBugs found by a fuzzerSanitizerBug/build issue discovered using sanitizer e.g. ASANSecurity RiskBugs that could potentially be security vulnerabilities
Type
Projects
- StatusShow more project fields✅ Done
Activity
carnil commentedon Oct 5, 2025
CVE-2025-11277 seems to have been assigned for this issue.
Fix Heap-buffer-overflow in Q3DImporter::InternReadFile
Fix Heap-buffer-overflow in Q3DImporter::InternReadFile (#6370)
Fix Heap-buffer-overflow in Q3DImporter::InternReadFile (#6370)
Feature/pjoe fix fbx export (#6405)
Fix Heap-buffer-overflow in Q3DImporter::InternReadFile (#6370)
Feature/pjoe fix fbx export (#6405)
Fix Heap-buffer-overflow in Q3DImporter::InternReadFile (assimp#6370)
Feature/pjoe fix fbx export (assimp#6405)