Opened 4 years ago

Closed 3 years ago

#4915 closed defect (worksforme)

box2d_in() + bogus string crashes server

Reported by: robins Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.4
Component: postgis Version: 3.0.x
Keywords: box2d_in Cc:

Description

box2d_in() + bogus string crashes the server.

When box2d_in() is fed with a string that has a comma (,) and spaces, it just crashes the server. It does catch empty strings / nulls / "a,b" but a regular user could cause DoS by running something like this.

$ psql
psql (13beta2, server 13.3)
Type "help" for help.

regression=> \dx postgis
List of installed extensions
-[ RECORD 1 ]--------------------------------------------------------------------
Name        | postgis
Version     | 3.0.3
Schema      | public
Description | PostGIS geometry, geography, and raster spatial types and functions

regression=> SELECT plvdate.version();
                    version
-----------------------------------------------
 PostgreSQL PLVdate, version 3.7, October 2018
(1 row)

regression=> SELECT public.box2d_in(plvdate.version()::cstring);
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!?> \q

Change History (6)

comment:1 by pramsey, 4 years ago

Milestone: PostGIS 3.1.23.1.3

comment:2 by pramsey, 4 years ago

Milestone: 3.1.3PostGIS 3.1.3

Milestone renamed

comment:3 by robe, 3 years ago

Milestone: PostGIS 3.1.3PostGIS 3.1.4

In prep for 3.1.3 release

comment:4 by robe, 3 years ago

Where does this plvdate.version() function come from.

I tried to replicate with:

CREATE SCHEMA IF NOT EXISTS plvdate;
CREATE OR REPLACE FUNCTION plvdate.version() returns text AS 
$$ SELECT 'PostgreSQL PLVdate, version 3.7, October 2018'$$
language sql ;

SELECT box2d_in(plvdate.version()::cstring);

But it doesn't crash, just gives:

ERROR:  box2d parser - couldn't parse.  It should look like: BOX(xmin ymin,xmax ymax)

comment:5 by pramsey, 3 years ago

I also cannot replicate, in PostGIS 3.1, 3.0 or master.

SELECT public.box2d_in('PostgreSQL PLVdate, version 3.7, October 2018'::cstring);

comment:6 by pramsey, 3 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.