Bug:Blender importer switches on unvalidated, file-controlled enum fields → UBSan invalid enum load / SIGILL (CWE-704)
Describe the bug
The Blender (.blend) importer in assimp decodes enum fields directly from untrusted binary file bytes and passes them into switch statements without range validation. Three distinct sites in BlenderLoader.cpp — ConvertLight (switches on lamp->type, legal values 0..4), ConvertNode (switches on obj->type, 10 legal discrete values), and ResolveTexture (switches on rtex->type, legal values 1..15) — all contain a switch with no default branch and no prior bounds check. A malformed .blend file that overwrites the corresponding struct regions with 0xFF causes the enum to load the value 0xFFFFFFFF. Loading an out-of-range value into a C++ enum is undefined behavior; under a trap-mode UBSAN build (-fsanitize-trap=undefined) this compiles to a ud1 trap instruction, crashing the process with SIGILL (exit 132).
To Reproduce
Download the seed file from assimp's repository: https://github.com/assimp/assimp/blob/master/test/models/Blender/BlenderDefault_248.blend (125,148 bytes, MD5
42c14b7788674fa8b81d3a00db1dfc11). Click "Download raw file" or use:wget https://raw.githubusercontent.com/assimp/assimp/master/test/models/Blender/BlenderDefault_248.blendGenerate the POC files by overwriting specific file offsets with 0xFF. These are small hex-patch operations that anyone can run with a single command:
# Trigger A — Lamp enum (offset 0x12480, 64 bytes to 0xFF): python3 -c "data=bytearray(open('BlenderDefault_248.blend','rb').read());[data.__setitem__(0x12480+i,0xFF) for i in range(64)];open('assimp_poc1_lamp_enum.bin','wb').write(data)" # Trigger B — Object enum (offset 0x12D00, 64 bytes to 0xFF): python3 -c "data=bytearray(open('BlenderDefault_248.blend','rb').read());[data.__setitem__(0x12D00+i,0xFF) for i in range(64)];open('assimp_poc2_object_enum.bin','wb').write(data)" # Trigger C — Tex enum (offset 0x13700, 128 bytes to 0xFF): python3 -c "data=bytearray(open('BlenderDefault_248.blend','rb').read());[data.__setitem__(0x13700+i,0xFF) for i in range(128)];open('assimp_poc3_tex_enum.bin','wb').write(data)"Or use the generator script (
generate_assimp_pocs.py, attached) to create all 4 POC files at once:python3 generate_assimp_pocs.py BlenderDefault_248.blendBuild assimp with UBSan trap mode (the project's
BUILD_FUZZ=ONCMake configuration does this by default).Run the fuzz harness on the POC file:
./out/assimp_harness assimp_poc1_lamp_enum.bin- The process crashes with SIGILL (exit 132). For a detailed stacktrace:
ASAN_OPTIONS=handle_sigill=1:print_stacktrace=1 ./out/assimp_harness assimp_poc1_lamp_enum.bin==3789068==ERROR: AddressSanitizer: ILL on unknown address 0x5555562c265d (pc 0x5555562c265d ...)
#0 0x5555562c265d in __clang_trap_msg$Loaded an invalid value for the type /src/assimp/code/AssetLib/Blender/BlenderLoader.cpp
#1 0x5555562c265d in Assimp::BlenderImporter::ConvertLight(...) BlenderLoader.cpp:1127:19
#2 0x55555629b7e7 in Assimp::BlenderImporter::ConvertNode(...) BlenderLoader.cpp:1223:29
#3 0x55555628f83d in Assimp::BlenderImporter::ConvertBlendFile(...) BlenderLoader.cpp:304:34
#4 0x55555628a556 in Assimp::BlenderImporter::InternReadFile(...) BlenderLoader.cpp:158:5
#8 0x5555558c1611 in LLVMFuzzerTestOneInput /task/harness.cpp:56:37
SUMMARY: AddressSanitizer: ILL /src/assimp/code/AssetLib/Blender/BlenderLoader.cpp in ConvertLightExpected behavior
When a .blend file contains an out-of-range value in the Lamp::type, Object::type, or Tex::type field, the importer should reject the value, log a warning or error, and skip the affected object (light, node, or texture) rather than switching on an invalid enum. A release build reading a valid .blend file should get the correct scene without UBSAN traps.
Affected code
/* code/AssetLib/Blender/BlenderLoader.cpp:1127 — ConvertLight */
switch (lamp->type) { /* no range check; legal values 0..4 */
case Blender::Lamp::Type::TYPE_LOCAL: ... break;
...
/* no default branch */
}
/* code/AssetLib/Blender/BlenderLoader.cpp:1203 — ConvertNode */
switch (obj->type) { /* legal: {0,1,2,3,4,5,10,11,21,22}; no range check */
/* code/AssetLib/Blender/BlenderLoader.cpp:450 — ResolveTexture (from BuildMaterials:688) */
switch (rtex->type) { /* legal: 1..15; no range check */Call chain:
Assimp::Importer::ReadFileFromMemory() (Importer.cpp:507)
└─ Assimp::Importer::ReadFile() (Importer.cpp:709)
└─ BlenderImporter::InternReadFile() (BlenderLoader.cpp:158)
└─ ConvertBlendFile() (BlenderLoader.cpp:304)
├─ ConvertNode() → switch(obj->type)
│ └─ ConvertLight() → switch(lamp->type)
└─ BuildMaterials() → ResolveTexture() → switch(rtex->type)Platform
- OS: Linux x86-64 (Ubuntu 22.04)
- Compiler: Clang 18 with
-fsanitize=address,undefined -fno-sanitize-recover=all - assimp version: commit
a433d5a(master, 2026-08) - Fuzzing engine: AFL++ via
LLVMFuzzerTestOneInputharness - Exit code: 132 (SIGILL, trap-mode UBSAN)
Additional context
- Deterministic: yes — same input always triggers. Three distinct crash sites confirmed, all sharing the same root cause (missing enum range validation).
- Reachability: any .blend input reaches these paths through the generic
ReadFileFromMemoryAPI. The fuzz harness does nothing special — it callsImporter::ReadFileFromMemory(buffer, size, 0, hint). - Impact in release builds: the out-of-range enum falls through a switch with no default, leaving light/texture/node struct fields uninitialized. This can corrupt downstream rendering or trigger further UB.
Source: assimp/assimp