Handle Draco zero faces and short point mappings - #1448
Merged
j9liu merged 1 commit intoSep 24, 2026
Merged
Conversation
j9liu
reviewed
Sep 21, 2026
j9liu
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @bjornblissing for the PR! I just have two small comments that are doc-related.
Collaborator
There was a problem hiding this comment.
I think it's worth mentioning these fixes in CHANGES.md, e.g., something like "fixed potential out-of-bounds access while decoding Draco-compressed glTFs."
Contributor
Author
There was a problem hiding this comment.
Added a note in the changes.md
Comment on lines
+238
to
+239
| if (!pAttribute->is_mapping_identity() && | ||
| pAttribute->indices_map_size() < pMesh->num_points()) { |
Collaborator
There was a problem hiding this comment.
Would this comment be correct? I'm not familiar with how Draco works, but a small explainer would help:
Suggested change
| if (!pAttribute->is_mapping_identity() && | |
| pAttribute->indices_map_size() < pMesh->num_points()) { | |
| // For explicit index mapping, the remapped indices must match the | |
| // number of points in the mesh. | |
| if (!pAttribute->is_mapping_identity() && | |
| pAttribute->indices_map_size() < pMesh->num_points()) { |
Contributor
Author
There was a problem hiding this comment.
Added a comment explaining the check.
A crafted or corrupted Draco bitstream can decode to a mesh with zero faces or to a non-identity attribute mapping that covers fewer points than the mesh contains. Taking the address of the first face of an empty mesh is undefined behaviour and aborts under _GLIBCXX_ASSERTIONS, and the mapping is indexed by point index without any bounds check inside Draco, so a short mapping reads out of bounds and copies arbitrary memory into the decoded attribute. Keep the model consistent when data is skipped: a zero-face mesh produces a valid zero-count index accessor and only the copy is skipped, and an attribute with a short mapping is removed from the primitive with a warning, so consumers cannot read an accessor that still describes compressed data after the Draco extension is stripped.
bjornblissing
force-pushed
the
fix/draco-malformed-mesh-decoding
branch
from
September 24, 2026 17:24
b50c112 to
32ba13e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Hardens Draco mesh decoding against malformed data that can otherwise trigger
undefined behavior or leave stale compressed accessors in the decoded model.
The change handles two cases in
CesiumGltfReader/src/decodeDraco.cpp:constructing the decoded index buffer. The zero-length buffer and zero-count
index accessor are retained, and index copying is skipped safely.
mesh has points is rejected before Draco is indexed by point number. A warning
is emitted and the corresponding attribute is removed from the primitive,
rather than copying out-of-bounds data or leaving the original compressed
accessor advertised after the Draco extension is removed.
This keeps the resulting glTF model internally consistent even when decoding
crafted or corrupted Draco bitstreams.
Issue number or link
N/A
Author checklist
CHANGES.mdwith a short summary of my change (for user-facing changes).Testing plan
Exercise Draco decoding with malformed or edge-case meshes covering:
decoding does not access a nonexistent face and produces a zero-count index
accessor with an empty buffer.
point count. Verify that decoding emits a warning and removes the affected
attribute from the primitive instead of reading beyond the mapping.
that valid decoded attributes and indices are still copied as before.
The changes are defensive checks in the Draco decoding path; no user-facing
format or API changes are introduced.