C++Severity: LowStatus: Fixed

Out-of-range face and material indices in the 3DS model loader

The 3DS model loader in src/cel3ds/3dsread.cpp does not bounds-check face vertex indices, material-group face indices, or accumulated point and face counts, so a crafted .3ds file can use out-of-range indices when Celestia loads it. Levin Li (levinli303) wrote and merged the fix in pull request 2788 on 2026-11-22; the pull request says it was reported by @ucsurf.

The loader

Celestia’s 3DS model loader, src/cel3ds/3dsread.cpp, does not check three kinds of index before it uses them:

  • A face can name a vertex index past that mesh’s vertex count.
  • A material group can name a face index past that mesh’s face count.
  • The running totals of points and faces can pass the 16-bit mesh limit.

A crafted .3ds file can therefore make the loader use an out-of-range index when the model is opened.

The fix

Levin Li (levinli303) wrote and merged pull request 2788, “Reject out-of-range indices in 3DS meshes”. The pull request body is “reported by @ucsurf”.

The change limits the accumulated counts in readPointArray and readFaceArray. validateTriangleMesh() rejects a face whose vertex index is out of range, and a material group whose face index is out of range.

Timeline

  1. Found
  2. Reported via email
  3. Disclosed publicly
  4. Entry last updated

Machine-readable: JSON · Markdown · ID security/cpp/CelestiaProject__Celestia/2026-11-22-3ds-mesh-out-of-range-indices

If this work is useful to you, you can support it on Buy Me a Coffee.