Fix heap out-of-bounds read in dimensional pcpatch WKB parsing - #388
Open
HarshRajSinghania wants to merge 1 commit into
Open
HarshRajSinghania wants to merge 1 commit into
HarshRajSinghania wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Fixes #387.
The dimensional
pcpatchWKB parser trusted attacker-controlled per-dimension size fields and could read beyond the supplied WKB buffer inpc_bytes_deserialize(). The caller also advanced using the claimed size without tracking the remaining input length.What changed
bufsizeparameter topc_bytes_deserialize().int32_tand reject negative values.pc_bytes_deserialize()failures and clean up partially constructed patches.pc_patch_from_wkb()from continuing into extent/stat computation when a compression-specific parser returnsNULL.Regression coverage
Added CUnit coverage for:
The malformed 65536-byte case is the regression for the demonstrated AddressSanitizer heap-buffer-overflow.
Validation
The branch is one commit ahead of
masterand the diff is limited to the parser/API changes and regression tests. I did not run the full CUnit/PostgreSQL build through this integration, so CI should be treated as the final build/test validation.No RCE is claimed; the fix addresses the demonstrated out-of-bounds read and the associated oversized-allocation/DoS condition.