copy.c handling for RLS is insecure - Mailing list pgsql-hackers

From Robert Haas
Subject copy.c handling for RLS is insecure
Date
Msg-id CA+TgmoayuMpm70TryntaB3OA=FgmRDrtBqt94Zh_wDTNnKhuKg@mail.gmail.com
Whole thread Raw
Responses Re: copy.c handling for RLS is insecure
List pgsql-hackers
In DoCopy, some RLS-specific code constructs a SelectStmt to handle
the case where COPY TO is invoked on an RLS-protected relation.  But I
think this step is bogus in two ways:
           /* Build FROM clause */           from = makeRangeVar(NULL, RelationGetRelationName(rel), 1);

First, because relations are schema objects, there could be multiple
relations with the same name.  The RangeVar might end up referring to
a different one of those objects than the user originally specified.
That seems like it could be surprising at best and a security
vulnerability at worst.  So at the very list I think this needs to
pass the schema name as well as the relation name.  I'm not 100% sure
it's OK even then, because what about a concurrent rename of the
schema?

Second, the third argument to makeRangeVar is a parse location, and I
believe it it is conventional to use -1, rather than 1, when no
location can be identified.

Thanks,

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Fabrízio de Royes Mello
Date:
Subject: Re: Simplify calls of pg_class_aclcheck when multiple modes are used
Next
From: Peter Geoghegan
Date:
Subject: Re: Last Commitfest patches waiting review