Skip to content

Fixes CVE-2025-2750: out of bounds write by assigning to wrong array element count tracking (closes #6011) - #6225

Merged
kimkulling merged 2 commits into
assimp:masterfrom
VinzSpring:fix-CVE-2025-2750
Jun 8, 2025
Merged

kimkulling merged 2 commits into
assimp:masterfrom
VinzSpring:fix-CVE-2025-2750

Conversation

@VinzSpring

@VinzSpring VinzSpring commented Jun 5, 2025 •

Copy link
Copy Markdown
Contributor

Closes #6011

description:

  • The current implementation has faulty reallocation logic when parsing a CSM file
  • Issue 1
    • s->mPositionKeys = new aiVectorKey[s->mNumPositionKeys = alloc*2];
    • By assigning s->mNumPositionKeys = alloc*2 right before resizing the buffer, making s->mNumPositionKeys equivalent to the max number of aiVectorKey that can be stored in s->mPositionKeys
    • the code later attempts to get the next write location by doing: aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys;
    • this points to the end of the array, not after the last element in the array
  • Issue 2
    • if (last != 0x00ffffff) {
      alloc = last-first;
      alloc += alloc>>2u; // + 25%
      for (unsigned int i = 0; i < anim->mNumChannels; ++i) {
      anim->mChannels[i]->mPositionKeys = new aiVectorKey[alloc];
      }
      }
    • if the CSM file does not declare last frame data, then mPositionKeys will never be initialized

fix:

  • we preserve s->mNumPositionKeys to still contain the actual number of aiVectorKeys and ensure that we will not write out of bounds
  • we initialize mPositionKeys with a default value and if we find last frame info, we just re-initialize it

…element count tracking (closes assimp#6011)

description:
- The current implementation has faulty reallocation logic when parsing a CSM file
- Issue 1
    - https://github.com/assimp/assimp/blob/4ad1d2aa3086517816716a50aa122342806736f9/code/AssetLib/CSM/CSMLoader.cpp#L205
    - By assigning s->mNumPositionKeys = alloc*2 right before resizing the buffer, making s->mNumPositionKeys equivalent to the
      max number of aiVectorKey that can be stored in s->mPositionKeys
    - the code later attempts to get the next write location by doing: aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys;
    - this points to the end of the array, not after the last element in the array
- Issue 2
    - https://github.com/assimp/assimp/blob/4ad1d2aa3086517816716a50aa122342806736f9/code/AssetLib/CSM/CSMLoader.cpp#L178-L184
    - if the CSM file does not declare last frame data, then mPositionKeys will never be initialized

fix:
- we preserve s->mNumPositionKeys to still contain the actual number of aiVectorKeys and ensure that we will not write out of bounds
- we initialize mPositionKeys with a default value and if we find last frame info, we just re-initialize it
@tellypresence

Copy link
Copy Markdown
Collaborator

Please add text "Closes #6011" in description of PR so github will associate PR with issue

@tellypresence tellypresence added Bug Global flag to mark a deviation from expected behaviour Fuzzer Bugs found by a fuzzer Security Risk Bugs that could potentially be security vulnerabilities labels Jun 5, 2025
@tellypresence

Copy link
Copy Markdown
Collaborator

@VinzSpring Looks like there's a quality issue flagged on your PR, please take a look and see if there's a suggestion to fix

@VinzSpring

Copy link
Copy Markdown
Contributor Author

Security scanner looks good. The code was using new and delete before. My pull request focuses on fixng the CVE.

@tellypresence

Copy link
Copy Markdown
Collaborator

The code was using new and delete before

Right, must have been the additional delete you added that triggered it -- but in any case expect there will be some delay getting this merged due to failing CI checks

@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.,

@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@kimkulling
kimkulling merged commit 2699870 into assimp:master Jun 8, 2025
@kimkulling

Copy link
Copy Markdown
Member

Merged, thanks a lot for your contribution.

kimkulling added a commit that referenced this pull request Jul 1, 2026
…element count tracking (closes #6011) (#6225)

description:
- The current implementation has faulty reallocation logic when parsing a CSM file
- Issue 1
    - https://github.com/assimp/assimp/blob/4ad1d2aa3086517816716a50aa122342806736f9/code/AssetLib/CSM/CSMLoader.cpp#L205
    - By assigning s->mNumPositionKeys = alloc*2 right before resizing the buffer, making s->mNumPositionKeys equivalent to the
      max number of aiVectorKey that can be stored in s->mPositionKeys
    - the code later attempts to get the next write location by doing: aiVectorKey* sub = s->mPositionKeys + s->mNumPositionKeys;
    - this points to the end of the array, not after the last element in the array
- Issue 2
    - https://github.com/assimp/assimp/blob/4ad1d2aa3086517816716a50aa122342806736f9/code/AssetLib/CSM/CSMLoader.cpp#L178-L184
    - if the CSM file does not declare last frame data, then mPositionKeys will never be initialized

fix:
- we preserve s->mNumPositionKeys to still contain the actual number of aiVectorKeys and ensure that we will not write out of bounds
- we initialize mPositionKeys with a default value and if we find last frame info, we just re-initialize it

Co-authored-by: Vinz Spring <[email protected]>
Co-authored-by: Kim Kulling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Global flag to mark a deviation from expected behaviour Fuzzer Bugs found by a fuzzer Security Risk Bugs that could potentially be security vulnerabilities

Projects

Development

Successfully merging this pull request may close these issues.

Bug: Out-of-bounds Write in Assimp::CSMImporter::InternReadFile

3 participants