Skip to content

reproject: validate lon/lat shape parity in geoid_height and itrf_transform (#2026)#2028

Open
brendancol wants to merge 2 commits into
mainfrom
deep-sweep-security-reproject-2026-05-17-01
Open

reproject: validate lon/lat shape parity in geoid_height and itrf_transform (#2026)#2028
brendancol wants to merge 2 commits into
mainfrom
deep-sweep-security-reproject-2026-05-17-01

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2026.

geoid_height and itrf_transform ravel lon and lat separately, then index them in a numba @njit(parallel=True) kernel using lon.shape[0]. If lat was shorter than lon, the kernel read past the end of lat and returned wrong numbers without raising. Both are public API, so the bug was invisible unless someone happened to test for it.

This adds an early shape check in both functions that rejects mismatched lon and lat with a ValueError naming both shapes. itrf_transform also pre-empts non-broadcastable h shapes so the error points at the public API instead of the broadcast call.

Spotted during the reproject security sweep on 2026-05-17 (Cat 4 OOB read plus Cat 6 missing input validation).

Test plan

  • pytest xrspatial/tests/test_reproject.py::TestGeoidShapeMismatch -v, 6 new tests, all pass
  • pytest xrspatial/tests/test_reproject.py::TestItrfShapeMismatch -v, 6 new tests, all pass
  • pytest xrspatial/tests/test_reproject.py -k "geoid or itrf", 57 tests, no regressions
  • CI green

…nsform (#2026)

Both public APIs ravel lon and lat independently and then index them in
a numba @njit(parallel=True) kernel using lon.shape[0]. A shorter lat
array used to silently read past its end and return wrong numbers
without raising IndexError.

Add an early shape check in geoid_height and itrf_transform that
rejects mismatched lon and lat with a ValueError naming both shapes.
For itrf_transform, also pre-empt non-broadcastable h shapes so the
error message points at the public API rather than the broadcast call.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reproject: geoid_height and itrf_transform silently accept mismatched lon/lat array shapes

1 participant