[LOW] Reject definite maps whose item count overflows - #39
Open
OskarEichler wants to merge 1 commit into
Open
Conversation
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.
Summary
A definite map length greater than
SIZE_MAX / 2overflows the decoder's internal key/value item count. On 64-bit builds, a header declaring 2^63+1 pairs wraps to an item count of two, so cbor 0.5.10.3 accepts a one-pair map that is incomplete according to its own header.This saturates the internal count on overflow, allowing the existing incomplete-input path to reject the payload. The change closes a malformed-input validation gap that can create parser differentials when another component enforces the declared CBOR structure.
Reproduction
0.5.10.3 returns
{1 => 2}despite the header declaring 9,223,372,036,854,775,809 pairs. This branch raisesEOFErrorbecause the declared map is incomplete.Verification
No tests were changed because this repository asks contributors not to add or modify tests.
Scope and limitations
The malformed payload does not allocate or iterate 2^63 entries. The concrete issue is incorrect structural acceptance and the resulting parser differential; no standalone authorization bypass was demonstrated.
The overflow requires a 64-bit explicit map length on the reviewed 64-bit build.
Breaking changes
Malformed CBOR maps whose declared lengths overflow the internal key/value item count are rejected instead of being accepted after a wrapped number of pairs. Valid CBOR behavior is unchanged.