Guard against NULL sub-enum table in upb_MiniTableEnum_CheckValue#28820
Open
Ashutosh0x wants to merge 1 commit into
Open
Guard against NULL sub-enum table in upb_MiniTableEnum_CheckValue#28820Ashutosh0x wants to merge 1 commit into
Ashutosh0x wants to merge 1 commit into
Conversation
A closed-enum field whose sub-enum table has not been linked resolves to a NULL upb_MiniTableEnum via upb_MiniTable_GetSubEnumTable(), which is a documented return value for unlinked fields. The varint and packed enum decode paths in upb/wire/decode.c call upb_MiniTableEnum_CheckValue() on that pointer without a NULL check, so decoding untrusted wire data against a MiniTable built from an untrusted mini descriptor dereferences NULL and crashes (reliably reproducible SIGSEGV; remote DoS for such callers). Add a NULL guard at the single chokepoint in CheckValue that reports every value as unrecognized, routing it to the unknown-field set exactly as an out-of-range closed-enum value already is. UPB_UNLIKELY keeps the hot decode path unaffected. Adds a regression test covering all three internal branches on a NULL table. Fixes protocolbuffers#26857.
Author
|
This is a one-line NULL guard at the single chokepoint. Context for review:
Happy to move the guard to the decode call sites instead if the team prefers that over the shared chokepoint. @haberman — this fixes #26857, which is assigned to you. The PR is from an external fork, so the full test matrix is gated behind the |
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.
A closed-enum field whose sub-enum table has not been linked resolves to a NULL upb_MiniTableEnum via upb_MiniTable_GetSubEnumTable(), which is a documented return value for unlinked fields. The varint and packed enum decode paths in upb/wire/decode.c call upb_MiniTableEnum_CheckValue() on that pointer without a NULL check, so decoding untrusted wire data against a MiniTable built from an untrusted mini descriptor dereferences NULL and crashes (reliably reproducible SIGSEGV; remote DoS for such callers).
Add a NULL guard at the single chokepoint in CheckValue that reports every value as unrecognized, routing it to the unknown-field set exactly as an out-of-range closed-enum value already is. UPB_UNLIKELY keeps the hot decode path unaffected. Adds a regression test covering all three internal branches on a NULL table.
Fixes #26857.