Skip to content

Reject trailing data in SGL WKB inputs - #856

Merged
Maxxen merged 1 commit into
duckdb:v1.5-variegatafrom
matthiasgoergens:review/duckdb-spatial-wkb-trailing-data
Sep 22, 2026
Merged

Maxxen merged 1 commit into
duckdb:v1.5-variegatafrom
matthiasgoergens:review/duckdb-spatial-wkb-trailing-data

Conversation

@matthiasgoergens

Copy link
Copy Markdown
Contributor

Spatial's SGL reader returned success as soon as it finished the outermost WKB
geometry, even when bytes remained in the input. The 2D constructors,
ST_GeomFromHEXWKB, and statistics parsing could consequently accept a valid
geometry followed by arbitrary data or a second geometry.

Require the parser position to reach the end of the supplied buffer in both
the materialising and statistics paths, and report a specific trailing-data
error otherwise. The standalone regression also verifies the error category,
message, and successful reader reuse after a rejected input.

The standalone Clang ASan/UBSan suite and the full Spatial relassert build
pass. Focused SQL coverage exercises all three 2D constructors and HEX WKB;
the adjacent WKB round-trip suites also pass.

Related: duckdb/duckdb#24296 and duckdb/duckdb#24301 — the corresponding
DuckDB core ST_GeomFromWKB path is fixed separately in duckdb/duckdb#24559.


Verified (2026-08-05): test/sql/geometry/st_2d_fromwkb.test and
test/sql/geometry/st_ashexwkb.test fail on unpatched duckdb-spatial main
2b072abd2a (trailing bytes silently accepted, e.g. a point followed by
garbage still returns POINT_2D {'x': 1.0, 'y': 2.0}) and pass with this
branch (6 and 27 assertions).

@matthiasgoergens

Copy link
Copy Markdown
Contributor Author

Same CI failure as #855 — pre-existing build break against duckdb core main (PR #24278 changed table_function_bind_t signature), not caused by this PR. Details in the #855 comment.

@matthiasgoergens
matthiasgoergens force-pushed the review/duckdb-spatial-wkb-trailing-data branch from 33b69c0 to 3e19894 Compare September 17, 2026 01:57
@matthiasgoergens
matthiasgoergens changed the base branch from main to v1.5-variegata September 17, 2026 02:01
@matthiasgoergens

Copy link
Copy Markdown
Contributor Author

Retargeted to v1.5-variegata together with #855, see the note there. No overlap with #867, which handles empty or truncated input in the serialization reader; this one rejects trailing bytes after a complete WKB geometry in the SGL reader.

@Maxxen
Maxxen merged commit b88d791 into duckdb:v1.5-variegata Sep 22, 2026
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.

2 participants