Skip to content

Honor sliceAllocLimit: compare the flag against zero - #402

Open
AshSgDe29071999 wants to merge 1 commit into
vmihailenco:v5from
AshSgDe29071999:fix/alloc-limit-flag-check
Open

AshSgDe29071999 wants to merge 1 commit into
vmihailenco:v5from
AshSgDe29071999:fix/alloc-limit-flag-check

Conversation

@AshSgDe29071999

Copy link
Copy Markdown

disableAllocLimitFlag is 1<<3 (8), so flags&flag != 1 was always true and the 1,000,000-element cap never applied. DecodeSlice also preallocated capacity from the untrusted array length.

Compare the flag against zero, matching the rest of the decoder, and cap []interface{} capacity.

Fixes #401

Test

go test . -run TestAllocLimitFlagIsHonored -count=1

disableAllocLimitFlag is 8, so `flags&flag != 1` was always true and
the 1,000,000-element cap never applied. DecodeSlice also preallocated
capacity from the untrusted array length.

See vmihailenco#401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security vulnerability disclosure: unbounded memory allocation when decoding slices (msgpack v5, CVE pending)

1 participant