diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-01-19 15:42:33 -0500 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-03 08:25:13 -0500 |
| commit | a14363102d98fa29b8cced578eb3a0fadaa5bcb7 (patch) | |
| tree | 2bdc10fc99f861027d3dcc8cd483d0030a2571c3 /django | |
| parent | f578acc8c54530fffabd52d2db654c8669b011af (diff) | |
[4.2.x] Fixed CVE-2026-1207 -- Prevented SQL injections in RasterField lookups via band index.
Thanks Tarek Nakkouch for the report, and Simon Charette for the initial
triage and review.
Backport of 81aa5292967cd09319c45fe2c1a525ce7b6684d8 from main.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/db/backends/postgis/operations.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index b68db377f8..d18ddab525 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -51,6 +51,9 @@ class PostGISOperator(SpatialOperator): # Look for band indices and inject them if provided. if lookup.band_lhs is not None and lhs_is_raster: + if not isinstance(lookup.band_lhs, int): + name = lookup.band_lhs.__class__.__name__ + raise TypeError(f"Band index must be an integer, but got {name!r}.") if not self.func: raise ValueError( "Band indices are not allowed for this operator, it works on bbox " @@ -62,6 +65,9 @@ class PostGISOperator(SpatialOperator): ) if lookup.band_rhs is not None and rhs_is_raster: + if not isinstance(lookup.band_rhs, int): + name = lookup.band_rhs.__class__.__name__ + raise TypeError(f"Band index must be an integer, but got {name!r}.") if not self.func: raise ValueError( "Band indices are not allowed for this operator, it works on bbox " |
