Skip to content

Fix container overflow in MMD parser - #5309

Merged
kimkulling merged 2 commits into
assimp:masterfrom
aavenel:fix/MMDContainerOverflow
Nov 17, 2023
Merged

kimkulling merged 2 commits into
assimp:masterfrom
aavenel:fix/MMDContainerOverflow

Conversation

@aavenel

@aavenel aavenel commented Nov 4, 2023

Copy link
Copy Markdown
Contributor

Using reserve(), buffer size is not updated. Since data is directly inserted and not using push_pack, this can lead to a container overflow.

Unfortunatly, I don't have the test model that triggered the bug. I found this while fuzzing, and I deleted the wrong folder by mistake.

Using reserve, buffer size is not updated. Since data is directly inserted and not using push_pack,
this can lead to a container overflow.
@aavenel

aavenel commented Nov 4, 2023

Copy link
Copy Markdown
Contributor Author

Found the file that triggered the bug, it was an existing unit-test compiled with ASAN.

[ RUN      ] utPMXImporter.importTest
Info,  T23296: Load C:/Users/aavenel/Dev/assimp/test/models/../models-nonbsd/MMD/Alicia_blade.pmx
Debug, T23296: Assimp 5.3.2205027422 amd64 msvc shared singlethreadedsingle :
Info,  T23296: Found a matching importer for this file format: MMD Importer.
Info,  T23296: Import root directory is 'C:/Users/aavenel/Dev/assimp/test/models/../models-nonbsd/MMD\'
=================================================================
==3860==ERROR: AddressSanitizer: container-overflow on address 0x11412a8f58b0 at pc 0x7ffc5bdc3645 bp 0x0019e3b8d450 sp 0x0019e3b8d468
WRITE of size 32 at 0x11412a8f58b0 thread T0
==3860==WARNING: Failed to use and restart external symbolizer!
    #0 0x7ffc5bdc3674 in _asan_wrap_GlobalSize+0x407de (C:\Users\aavenel\Dev\assimp\build\bin\RelWithDebInfo\clang_rt.asan_dynamic-x86_64.dll+0x180043674)
    #1 0x7ffd260a95e2 in std::basic_streambuf<char,std::char_traits<char> >::xsgetn+0x62 (C:\WINDOWS\SYSTEM32\MSVCP140.dll+0x1800095e2)
    #2 0x7ffd260efbc1 in std::basic_istream<char,std::char_traits<char> >::read+0x81 (C:\WINDOWS\SYSTEM32\MSVCP140.dll+0x18004fbc1)
    #3 0x7ffc5d0cce97 in pmx::ReadString C:\Users\aavenel\Dev\assimp\code\AssetLib\MMD\MMDPmxParser.cpp:97
    #4 0x7ffc5d0c9e62 in pmx::PmxModel::Read C:\Users\aavenel\Dev\assimp\code\AssetLib\MMD\MMDPmxParser.cpp:528
    #5 0x7ffc5d0c2a3e in Assimp::MMDImporter::InternReadFile C:\Users\aavenel\Dev\assimp\code\AssetLib\MMD\MMDImporter.cpp:129
    #6 0x7ffc5c932f48 in Assimp::BaseImporter::ReadFile C:\Users\aavenel\Dev\assimp\code\Common\BaseImporter.cpp:135
    #7 0x7ffc5c95eee6 in Assimp::Importer::ReadFile C:\Users\aavenel\Dev\assimp\code\Common\Importer.cpp:709
    #8 0x7ff6ae61f3c0 in utPMXImporter::importerTest C:\Users\aavenel\Dev\assimp\test\unit\utPMXImporter.cpp:55
    #9 0x7ff6ae61f504 in utPMXImporter_importTest_Test::TestBody C:\Users\aavenel\Dev\assimp\test\unit\utPMXImporter.cpp:61

@kimkulling kimkulling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks, fine.

@kimkulling
kimkulling merged commit aae9369 into assimp:master Nov 17, 2023
@kimkulling

Copy link
Copy Markdown
Member

Merged, thanks a lot for your contribution.

@kimkulling

Copy link
Copy Markdown
Member

Good catch, thank you so much for your fix!

@aavenel
aavenel deleted the fix/MMDContainerOverflow branch November 20, 2023 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants