Make the Draco bufferView bounds check overflow-safe - #1449
Merged
j9liu merged 2 commits intoSep 24, 2026
Merged
Conversation
Both operands come straight from JSON, so adding them could overflow and wrap negative, letting the guard pass and handing Draco a span pointing outside the buffer.
j9liu
reviewed
Sep 21, 2026
j9liu
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @bjornblissing ! Can you fix the formatting by using npm run format on the base repo folder? Then this will be ready to go.
Cover the overflow-safe bounds check on Draco bufferViews: an offset near INT64_MAX combined with a byteLength must be rejected rather than wrapping past the guard and handing Draco a span outside the buffer. Without the accompanying fix, this reproduces as a crash instead of a warning.
bjornblissing
force-pushed
the
fix/draco-bounds-check-overflow
branch
from
September 24, 2026 17:28
b02d92c to
da5ebba
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
decodeBufferViewToDracoMesh(CesiumGltfReader/src/decodeDraco.cpp) validated a DracobufferViewagainst its owning buffer with:Both
byteOffsetandbyteLengthcome directly from untrusted JSON as signed 64-bit integers. Their sum can overflow and wrap around to a negative or small value, which would pass the>check even though the bufferView actually extends beyond (or entirely outside) the buffer. Draco would then be handed a span pointing outside the buffer's allocation.The fix rewrites the check to avoid the overflow-prone addition entirely: it first confirms
byteOffsetdoesn't exceed the buffer size, then comparesbyteLengthagainst the remaining space (bufferSize - byteOffset), which cannot overflow sincebyteOffset <= bufferSizeis already established at that point.Issue number or link
N/A
Author checklist
CHANGES.mdwith a short summary of my change (for user-facing changes).Testing plan
KHR_draco_mesh_compressionbufferView whosebyteOffsetandbyteLengthare both large, valid-lookingint64_tvalues that sum to an overflowed (negative or wrapped) result. Before the fix, the bounds check incorrectly passes and Draco is given an out-of-bounds span. After the fix, the check correctly rejects it and emits the "Draco bufferView extends beyond its buffer." warning.byteOffset == 0and a bufferView that exactly spans the whole buffer) still decode successfully with no false-positive warnings.This is a targeted arithmetic fix in the bounds-check path with no user-facing format or API changes.