]> git.kaiwu.me - nginx.git/commit
GeoIP: rejected out-of-range coordinates from MMDB lookups
authorY.Horie <u5.horie@gmail.com>
Tue, 27 Oct 2026 22:25:20 +0000 (07:25 +0900)
committerNITIN SWAMI <n.swami@f5.com>
Thu, 5 Nov 2026 05:24:49 +0000 (10:54 +0530)
commit45ae79aa6aa1f2b322235f12e3c79111b5a7041f
tree1044b0378da57cbb924294ed95b95e65e8a13a16
parentf7504639fafe7dc1dbcefa76d039bff0cd12bbe9
GeoIP: rejected out-of-range coordinates from MMDB lookups

The $geoip_latitude and $geoip_longitude values are formatted with
ngx_sprintf(buf, "%.4f", value) into a buffer sized for a coordinate,
but the DOUBLE/FLOAT value is taken from the database with no range
check.  A crafted or corrupted MMDB can store a huge magnitude (e.g.
1e30 or an infinity), and ngx_sprintf, which is unbounded, then writes
past the buffer in the request or connection pool.

Coordinates outside [-180, 180] are now rejected, so the variables
report "not found" as they do for a missing entry.  The comparison also
rejects a NaN.

Closes: https://github.com/nginx/nginx/issues/1907
src/http/modules/ngx_http_geoip_module.c
src/stream/ngx_stream_geoip_module.c