﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37532	GDALRaster._preprocess_input doesn't handle RecursionError from deeply nested JSON	rishaankgupta		"== Problem ==

`GDALRaster._preprocess_input` (django/contrib/gis/gdal/raster/source.py:243)
calls `json.loads(ds_input)` without catching `RecursionError`. While Python's
json C parser is mostly iterative, `json.loads()` may still raise
`RecursionError` rather than `JSONDecodeError` when input nesting exceeds the
interpreter's recursion limit (the same behavior that motivated the fix in
#37491 / CVE-2026-114582 for `ExternalCRSBlocker.check()` in
django/contrib/gis/gdal/geojson.py).

== Sibling already fixed ==

`ExternalCRSBlocker.check()` was patched 9 days ago (commit d3954c9, Nov 12)
to catch `RecursionError` and reraise as `ValueError(""GeoJSON input is nested
too deeply."")`. The form fields `JSONField` and `HStoreField` also catch
`RecursionError` (tests/forms_tests/field_tests/test_jsonfield.py:33-39 and
tests/postgres_tests/test_hstore.py:377-382).

`GDALRaster._preprocess_input` is the direct sibling in the same module area
and missed the same treatment.

== Proposed fix ==

Wrap `json.loads(ds_input)` in `try/except RecursionError` and reraise as
`ValueError(""Raster JSON input is nested too deeply."")`, mirroring the
geojson.py fix.

== Reproduction ==

Constructing `GDALRaster(deeply_nested_json_string)` (e.g. via direct API
call or any code path that passes attacker-controlled JSON to GDALRaster)
currently propagates an uncaught `RecursionError` to the caller. With the
proposed fix, callers receive a `ValueError` they can handle as a bad-input
condition (the form field already catches `ValueError`)."	Bug	new	GIS	6.1	Normal				Unreviewed	0	0	0	0	0	0
